Files
notifications-admin/app/templates/components/radios.html
Alexey Bezhan 194756bc2e Make radio form components reusable for nested checkboxes
For the template folders permission editing we need a nested
checkboxes form that is similar to "move folder" input, except
it's using checkboxes instead of radio buttons.

This moves most of the macros into a shared "select-input" components
file, which are wrapped by the existing radios.html by setting the
required input type.
2019-03-05 11:44:34 +00:00

69 lines
2.3 KiB
HTML

{% from "components/select-input.html" import select, select_list, select_nested, select_wrapper %}
{% macro radios(field, hint=None, disable=[], option_hints={}, hide_legend=False) %}
{{ select(field, hint=None, disable=[], option_hints={}, hide_legend=False, input="radio") }}
{% endmacro %}
{% macro radio_list(options, child_map, disable=[], option_hints={}) %}
{{ select_list(options, child_map, disable=[], option_hints={}, input="radio") }}
{% endmacro %}
{% macro radios_nested(field, child_map, hint=None, disable=[], option_hints={}, hide_legend=False) %}
{{ select_nested(field, child_map, hint=None, disable=[], option_hints={}, hide_legend=False, input="radio") }}
{% endmacro %}
{% macro radios_wrapper(field, hint=None, disable=[], option_hints={}, hide_legend=False) %}
{{ select_wrapper(field, hint=None, disable=[], option_hints={}, hide_legend=False, input="radio") }}
{% endmacro %}
{% macro radio(option, disable=[], option_hints={}, data_target=None, as_list_item=False) %}
{{ select_input(option, disable=[], option_hints={}, data_target=None, as_list_item=False, input="radio") }}
{% endmacro %}
{% macro radio_select(
field,
hint=None,
wrapping_class='form-group'
) %}
<div class="{{ wrapping_class }} {% if field.errors %} form-group-error{% endif %}">
<fieldset>
<legend class="form-label">
{{ field.label.text }}
{% if field.errors %}
<span class="error-message" data-module="track-error" data-error-type="{{ field.errors[0] }}" data-error-label="{{ field.name }}">
{{ field.errors[0] }}
</span>
{% endif %}
</legend>
<div class="radio-select" data-module="radio-select" data-categories="{{ field.categories|join(',') }}">
<div class="radio-select-column">
{% for option in field %}
<div class="multiple-choice">
{{ option }}
<label for="{{ option.id }}">
{{ option.label.text }}
</label>
</div>
{% if loop.first %}
</div>
<div class="radio-select-column">
{% endif %}
{% endfor %}
</div>
</div>
</fieldset>
</div>
{% endmacro %}
{% macro conditional_radio_panel(id) %}
<div class="conditional-radios-panel" id="panel-{{ id }}">
{{ caller() }}
</div>
{% endmacro %}