{# The admin's forms from a JSON schema: one macro per kind of field, forms.py picks it. Autoescaped: titles, descriptions, options and values come from a module's author. A value in a JS string goes through tojson, since the browser decodes HTML escapes before the JS runs. #} {% macro label(f, with_for=true) -%}
{{ f.title }}

{{ f.description }}

{%- endmacro %} {% macro options(prop, current) -%} {% set titles = prop.get("enum_titles") or prop.get("enumNames") %} {%- for opt in prop["enum"] %} {%- endfor %} {%- endmacro %} {% macro toggle(f) -%}
{{ label(f) }}
{%- endmacro %} {% macro select(f) -%}
{{ label(f) }}
{%- endmacro %} {% macro checkboxes(f) -%} {% set chosen = f.stored_value if f.stored_value is sequence and f.stored_value is not string and f.stored_value is not mapping else [] %}
{{ label(f, false) }}
{%- for opt in f.schema["items"]["enum"] %} {%- endfor %}
{%- endmacro %} {% macro array(f, cards, item_title) -%} {% set container = "array-container-" ~ f.key %}
{{ label(f, false) }}
{{ cards }}
{%- endmacro %} {% macro accordion(f, inner) -%}
{{ f.title }}

{{ f.description }}

{{ inner }}
{%- endmacro %} {% macro slider(f) -%}
{{ label(f) }}
{{ f.value }}
{%- endmacro %} {% macro number(f) -%}
{{ label(f) }}
{%- endmacro %} {% macro color(f) -%}
{{ label(f) }}
{%- endmacro %} {% macro password(f) -%}
{{ label(f) }}
{%- endmacro %} {% macro textarea(f) -%}
{{ label(f) }}
{%- endmacro %} {% macro text(f) -%}
{{ label(f) }}
{%- endmacro %} {# "HH:MM" or blank, in the browser's own time picker (24h or 12h as the phone has it) #} {% macro time(f) -%}
{{ label(f) }}
{%- endmacro %} {# An address at home the module may reach (client.py lets the module host through to it). The schema's default is only a hint, never filled in: saving the form must not open an address the owner didn't type. #} {% macro lan_url(f) -%}
{{ label(f) }}

MirrorDash lets this module reach this address on your home network, and nothing else there.

{%- endmacro %} {# A Lucide icon's name, drawn beside it as it is typed; admin.js suggests the names of the page's Lucide. #} {% macro icon_input(f, size="") -%}
{%- endmacro %} {% macro icon(f) -%}
{{ label(f) }} {{ icon_input(f) }}
{%- endmacro %} {# Files the owner uploads (features/modules/files.py): admin.js lists them as thumbnails, shrinks an image on the phone before sending it, and says why when it can't (settings not saved yet, a kind of file this version doesn't take). Nothing of it goes into the form: the files live in the module's cache folder. #} {% macro files(f) -%}
{{ label(f, false) }} {%- if f.instance_id %}

Loading…

{%- else %}

Files can't sit in a list or a group of settings.

{%- endif %}
{%- endmacro %} {# The fields of a list item (render_array_item) #} {% macro sub_swatches(f) -%}
{%- for title, value, preview_hex_color in SWATCHES %} {%- endfor %}
{%- endmacro %} {% macro sub_icons(f) -%}
{%- for icon in ICONS %} {%- endfor %}
Custom Name:
{%- endmacro %} {% macro sub_icon(f) -%}
{{ icon_input(f, " form-control-sm") }}
{%- endmacro %} {% macro sub_select(f) -%}
{%- endmacro %} {% macro sub_text(f) -%}
{%- endmacro %} {# One card in a list setting (e.g. a calendar), folded to one line (admin.js arrayItemSummary fills it in) #} {% macro array_item(index, item_title, fields, is_open) -%}
# {{ index + 1 }}: {{ item_title }}
{{ fields }}
{%- endmacro %}