{% from 'global_macros.html' import button, input, switch %} {% macro INIFormInfoBtn(doc_name, key, top, subvariable_header=False) %}
{% if subvariable_header %} add {% endif %} info
{% endmacro %} {% macro INIForm(ini_dict, doc_dict=None, location=None, app_templates=None, ds_selector=None) %}
{% if not ds_selector %} {{ button( float="left", target_blank=True, href=doc_dict['docs_url'], icon="info", text="Docs" ) }} {{ button( class="ini-form-save-btn", data={"url": url_for('main.save_ini_form_to_config'), "location": location}, float="left", icon="save", text="Save" ) }} {% endif %} {{ button( class="ini-form-cancel-btn hide theme-secondary", float="left", icon="close", text="cancel" ) }}
{# DATA SOURCE SELECT #} {% if ds_selector %}
{% endif %} {# APP TEMPLATES#} {% if app_templates %}
{% for app_template in app_templates %}
{% endfor %}
search
{% endif %}
{% for variable_dict in doc_dict['variables'] %}
{% for subvariable_dict in variable_dict['variables'] %}
{% endfor %} {% endfor %} {% for key, value in ini_dict.items() %} {% if key == "id" %} {% elif value[0] == "list" %}
{{ key }}
{{ INIFormInfoBtn(doc_name=doc_dict['name']|replace(" ", "-"), key=key, subvariable_header=True, top="4px") }}
{% for v in value[1:] %}
{% set v_id = "-" + range(1, 99999)|random|string %} {% for v_key, v_value in v.items() %}
{{ input( id=key + "-" + v_key + v_id, size="s11", label=v_key, name=key + "-" + v_key + v_id, val=v_value|string, class="ini-form-subvariable-input ini-form-" + doc_dict['name']|replace(" ", "-") + "-" + key + "-" + v_key ) }}
{{ INIFormInfoBtn(doc_name=doc_dict['name']|replace(" ", "-"), key=key + "-" + v_key, top="14px") }}
{% endfor %}
delete
{% endfor %}
{% elif value in ['True', 'False'] %}
{{ switch( size="s11 pt-2", value=value|string, label_left=key, name=key, id="ini-form-" + doc_dict['name']|replace(" ", "-") + "-" + key ) }}
{{ INIFormInfoBtn(doc_dict['name']|replace(" ", "-"), key=key, top="6px") }}
{% else %}
{{ input( size="s11", name=key, label=key, val=value|string, id="ini-form-" + doc_dict['name']|replace(" ", "-") + "-" + key ) }}
{{ INIFormInfoBtn(doc_dict['name']|replace(" ", "-"), key=key, top="14px") }}
{% endif %}
{% endfor %}
{% endmacro %}