Feature: The list elements render their view modes 

Description 

The list, list-and-detail, selected profiles and selected contracts elements offered a View Mode Default and a View Mode Toggle that no template read. Both take effect now:

  • View Mode Default renders the tile grid - the item keeps its stored value list and is labelled Tiles - or a table. The table has one row per profile, one per contract in the selected contracts element, and the columns name, position, e-mail, phone and room.
  • View Mode Toggle offers the visitor a switch between the allowed modes. The active mode is marked as current, and the pagination and the letter navigation keep the chosen mode.
  • Two site settings, plugin.tx_academicpersons.viewMode.allowed (default list,table) and plugin.tx_academicpersons.table.columns (default name,position,emailAddresses,phoneNumbers,room), decide which modes exist and what the table shows. A requested mode outside the allowed ones, or requested while the switch is off, renders the default mode.
  • The route enhancers List.yaml and ListAndDetail.yaml give a mode other than the default a speaking URL, /view-mode/table, also with a page or a letter behind it.

A project adds a mode without a template override: a partial Profile/ViewMode/<Mode>.html, the mode in the allowed modes, and an item of View Mode Default in page TSconfig. Its links carry it as a query argument until the site adds it to the map of the route enhancer.

See View modes, View modes, Adding a view mode and A view mode of your own in the URL.

Impact 

A content element saved with the default Tiles, or before the field existed, renders as before. One that an editor set to Table renders a table from now on, and one with the toggle switched on shows the switch.

Partials/Profile/List/ItemList.html and the selected profiles and contracts templates render the items through Profile/ViewMode/<Mode>.html instead of Profile/List/Items.html, and the list template renders the switch. A project copy of ItemList.html or of a selected template keeps rendering the grid whatever the mode; a copy of the list template shows the mode ItemList.html renders, without a switch. Adopt the shipped files to use the view modes. A project's own table or listener for these fields can be removed.

The table honours the fields of the content element: a contract field left out of Show only selected Fields is left out of the table as well.

A site that imports the route enhancers gets the three new routes of each enhancer. The existing URLs do not change.