{#- A JSON document on the record page, read through its schema: each value
under its title, lists of objects and maps as small tables, and a part
the form writes as JSON as JSON. JSON shows the document itself, laid
out and folding.
Takes `shown`, from Document.shown, and `outline` and `pretty` for the
JSON view. -#}
{% import "adminsite/_values.html" as values %}
{%- macro value_text(part) -%}
{%- if part.kind == "code" -%}
{%- if part.empty -%}{{ _('Not set') }}
{%- else -%}{{ part.code }}{%- endif -%}
{%- elif part.kind == "key" -%}
{{ part.text }}
{%- elif part.empty -%}
{{ _('Not set') }}
{%- elif part.field.widget in ("select", "checkbox") and not part.field.multiple|default(false) -%}
{{ values.badge(part.field, part.value, part.text) }}
{%- elif part.field.widget == "number" -%}
{{ part.text }}
{%- else -%}
{{ part.text }}
{%- endif -%}
{%- endmacro -%}
{%- macro table(part, headers) -%}
{%- if part.missing -%}
{{ _('Not set') }}
{%- elif part.rows -%}
| {{ header }} | {% endfor %}
|---|
| {{ value_text(cell) }} | {% endfor %}