mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
Show form elements for templates and folders
This commit adds: - checkboxes to let you select a template or folder - radio buttons to let you select where to move those template(s) and/or folder(s) to It only does the `get` part of this work; handling the `post` and calling API will be done in a subsequent commit.
This commit is contained in:
@@ -4,12 +4,7 @@
|
||||
width='2-3'
|
||||
) %}
|
||||
<div class="multiple-choice">
|
||||
<input
|
||||
id="{{ field.id }}" name="{{ field.name }}" type="checkbox" value="y"
|
||||
{% if field.data %}
|
||||
checked
|
||||
{% endif %}
|
||||
>
|
||||
{{ checkbox_input(field.id, field.name, field.data) }}
|
||||
<label for="{{ field.id }}">
|
||||
{{ field.label.text }}
|
||||
{% if hint %}
|
||||
@@ -22,6 +17,22 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro checkbox_input(id, name, data=None, value="y") %}
|
||||
<input
|
||||
id="{{ id }}" name="{{ name }}" type="checkbox" value="{{ value }}"
|
||||
{% if data %}
|
||||
checked
|
||||
{% endif %}
|
||||
>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro unlabelled_checkbox(id, name, data=None, value="y") %}
|
||||
<div class="multiple-choice">
|
||||
{{ checkbox_input(id, name, data, value) }}
|
||||
<label></label>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro checkbox_group(
|
||||
legend,
|
||||
fields
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{% macro page_footer(
|
||||
button_text=None,
|
||||
button_name=None,
|
||||
button_value=None,
|
||||
destructive=False,
|
||||
back_link=False,
|
||||
back_link_text="Back",
|
||||
@@ -11,7 +13,12 @@
|
||||
<div class="page-footer">
|
||||
{% if button_text %}
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<button type="submit" class="button{% if destructive %}-destructive{% endif %}">{{ button_text }}</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="button{% if destructive %}-destructive{% endif %}"
|
||||
>
|
||||
{{- button_text -}}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if back_link %}
|
||||
<a class="page-footer-back-link" href="{{ back_link }}">{{ back_link_text }}</a>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% if templates_and_folders_form.move_to.choices %}
|
||||
{{ radios(templates_and_folders_form.move_to) }}
|
||||
{{ page_footer('Move selected', button_name='operation', button_value='move') }}
|
||||
{% endif %}
|
||||
@@ -0,0 +1,38 @@
|
||||
{% from "components/checkbox.html" import unlabelled_checkbox %}
|
||||
|
||||
<nav id=template-list>
|
||||
{% for template_folder in template_folders %}
|
||||
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %}">
|
||||
{% if can_manage_folders %}
|
||||
{{ unlabelled_checkbox(
|
||||
id='templates-or-folder-{}'.format(template_folder.id),
|
||||
name='templates_and_folders',
|
||||
value=template_folder.id,
|
||||
) }}
|
||||
{% endif %}
|
||||
<h2 class="message-name">
|
||||
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=template_folder.id) }}">
|
||||
{{ template_folder.name }}
|
||||
</a>
|
||||
</h2>
|
||||
<p class="message-type">Folder containing {{ template_count }} template{% if template_count != 1 %}s{% endif %}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for template in templates %}
|
||||
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %}">
|
||||
{% if can_manage_folders %}
|
||||
{{ unlabelled_checkbox(
|
||||
id='templates-or-folder-{}'.format(template.id),
|
||||
name='templates_and_folders',
|
||||
value=template.id,
|
||||
) }}
|
||||
{% endif %}
|
||||
<h2 class="message-name">
|
||||
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=template.id) }}">{{ template.name }}</a>
|
||||
</h2>
|
||||
<p class="message-type">
|
||||
{{ message_count_label(1, template.template_type, suffix='')|capitalize }} template
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
@@ -75,30 +75,22 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ live_search(target_selector='#template-list .column-whole', show=show_search_box, form=search_form) }}
|
||||
{{ live_search(target_selector='#template-list .template-list-item', show=show_search_box, form=search_form) }}
|
||||
|
||||
<nav class="grid-row" id=template-list>
|
||||
{% for template_folder in template_folders %}
|
||||
<div class="column-whole">
|
||||
<h2 class="message-name">
|
||||
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=template_folder.id) }}">
|
||||
{{ template_folder.name }}
|
||||
</a>
|
||||
</h2>
|
||||
<p class="message-type">Folder containing {{ template_count }} template{% if template_count != 1 %}s{% endif %}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for template in templates %}
|
||||
<div class="column-whole">
|
||||
<h2 class="message-name">
|
||||
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=template.id) }}">{{ template.name }}</a>
|
||||
</h2>
|
||||
<p class="message-type">
|
||||
{{ message_count_label(1, template.template_type, suffix='')|capitalize }} template
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
{% if can_manage_folders %}
|
||||
<form method="post">
|
||||
{% with templates=templates, template_folders=template_folders %}
|
||||
{% include 'views/templates/_template_list.html' %}
|
||||
{% endwith %}
|
||||
{% with templates_and_folders_form=templates_and_folders_form %}
|
||||
{% include 'views/templates/_move_to.html' %}
|
||||
{% endwith %}
|
||||
</form>
|
||||
{% else %}
|
||||
{% with templates=templates, template_folders=template_folders %}
|
||||
{% include 'views/templates/_template_list.html' %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user