{#- One record's row of the list, drawn by the list and again when a value changed in place is saved. `upward` opens the row's menu towards the page, for the last rows of a long page. -#} {% import "adminsite/_icons.html" as icons %} {% import "adminsite/_values.html" as values %} {% set key = view._fields.identity_of(row) %} {#- The cells this user may change in place, on this record. -#} {% set changes = (editable|default({})).get(key, ()) %} {% if actions %} {#- The whole cell ticks the row, not only the box in it. -#} {% endif %} {% with allowed = row_actions.get(key, []) if row_actions else [], title = view.get_record_title(row), edit_url = urls.edit(view, key) if can_edit else "", upward = upward|default(false) %} {% include "adminsite/_row_actions.html" %} {% endwith %} {% for path in columns %} {% set item = view._fields.field_for(path) %} {% set widget = item.widget %} {% set text = view._fields.display(row, path) %} {% set amount = widget == 'number' and path not in view._schema.primary_key %} {% if loop.first %} {#- The first cell opens the record, or the form where a view has no record page, or is plain text where it has neither. -#} {% set opens = urls.detail(view, key) if can_detail else (urls.edit(view, key) if can_edit else "") %} {% set is_key = widget == "number" and path in view._schema.primary_key %} {% set shown = ("#" ~ text if is_key and text else (text or view.get_record_title(row))) %} {% if opens %} {{ shown }} {% else %} {{ shown }} {% endif %} {% else %} {%- set shown -%} {% if view._fields.hides(row, path) %} {#- Read through a record its own view keeps from this user. -#} {{ text }} {% elif not text %} {% include "adminsite/_empty.html" %} {% elif widget == "image" %} {% set stored = view._fields.value_at(row, path) %} {{ text }} {% elif widget == "file" %} {{ text }} {% elif widget in ("select", "checkbox") %} {{ values.badge(item, view._fields.value_at(row, path), text) }} {% else %} {#- Cut short where it is long, as a note, a list of values or the names of many linked records can be, so no value makes its column wider than this. An amount keeps to the end. -#} {{ text }} {% endif %} {%- endset -%} {% if path in changes %} {#- A value this user may change opens an editor under it, so a keyboard reaches it as well as a click. It looks like any other value until hover or focus brings up a background and a pencil, so a table of such cells stays quiet. -#} {% else %} {{ shown }} {% endif %} {% endif %} {% endfor %}