Files
notifications-admin/app/templates/components/radios.html
Chris Hill-Scott 83156bd16e Let users choose when to end a broadcast
Different emergencies will need broadcasts to last for a variable amount
of time. We give users some control over this by letting them stop a
broadcast early. But we should also let them set a maximum broadcast
time, for:
- when the duration of the danger is known
- when the broadcast has been live long enough to alert everyone who
  needs to know about it

This code re-uses the pattern for scheduling jobs, which has some
constraints that are probably OK for now:
- end time is limited to an hour
- longest duration is 3 whole days (eg if you start broadcasting Friday
  you have the choice of Saturday, Sunday and all of Monday, up to
  midnight)
2020-07-17 08:23:10 +01:00

65 lines
2.1 KiB
HTML

{% from "components/select-input.html" import select, select_list, select_nested, select_wrapper, select_input %}
{% macro radios(field, hint=None, disable=[], option_hints={}, hide_legend=False, inline=False) %}
{{ select(field, hint, disable, option_hints, hide_legend, input="radio", inline=inline) }}
{% 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, disable, option_hints, hide_legend, input="radio") }}
{% endmacro %}
{% macro radio(option, disable=[], option_hints={}, data_target=None, as_list_item=False) %}
{{ select_input(option, disable, option_hints, data_target, as_list_item, input="radio") }}
{% endmacro %}
{% macro radio_select(
field,
hint=None,
wrapping_class='form-group',
show_now_as_default=True
) %}
<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(',') }}" data-show-now-as-default="{{ show_now_as_default }}">
<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 js-hidden" id="{{ id }}">
{{ caller() }}
</div>
{% endmacro %}