{# a plugin's fields as its schema on the computer gives them: credentials typed blind and kept when left blank, models and efforts from what the runtime reports, choices in the plugin's own words; changing the model redraws the form through `refresh`, its efforts following #} {% macro fields(schema, item, values, typed, models, refresh, computer) %} {% set props = schema.get("properties") or {} %} {% set required = schema.get("required") or [] %} {% set ns = namespace(model=none, secrets=false) %} {% for name, field in props.items() %}{% if field.get("x-inspect") == "models" %}{% set ns.model = name %}{% endif %}{% if field.get("writeOnly") %}{% set ns.secrets = true %}{% endif %}{% endfor %} {% set model = ((models | selectattr("id", "equalto", values.get(ns.model)) | first | default(none)) or (models | selectattr("default") | first | default(none))) if ns.model else none %} {% for name, field in props.items() %} {% set types = [field.get("type")] + ((field.get("anyOf") or []) | map(attribute="type") | list) %} {% set choices = field.get("enum") or ((field.get("anyOf") or []) | selectattr("enum", "defined") | map(attribute="enum") | first | default(none)) %} {% set value = values.get(name) %}