Change move folder form to not have default radio btn and to show hint

Updated the move folder form to add a hint for the radio button for the
current folder saying 'current folder'. This hint does not get shown if
you are viewing all folders (so you are not inside a folder).

Also stopped a default radio button from being selected on the form.
This commit is contained in:
Katie Smith
2019-01-02 17:12:18 +00:00
parent 501ec2a534
commit 3cf36c592f
5 changed files with 61 additions and 4 deletions

View File

@@ -1287,6 +1287,7 @@ class TemplateAndFoldersSelectionForm(Form):
])
move_to = NestedRadioField(
'Choose a folder',
default='',
validators=[
Optional(),
required_for_ops('move-to-new-folder', 'move-to-existing-folder')

View File

@@ -122,6 +122,7 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
len(user_api_client.get_service_ids_for_user(current_user)) > 1
),
)
option_hints = {template_folder_id: 'current folder'}
if request.method == 'POST' and templates_and_folders_form.validate_on_submit():
if not can_manage_folders():
@@ -149,7 +150,8 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
template_type=template_type,
search_form=SearchTemplatesForm(),
templates_and_folders_form=templates_and_folders_form,
move_to_children=templates_and_folders_form.move_to.children()
move_to_children=templates_and_folders_form.move_to.children(),
option_hints=option_hints
)

View File

@@ -43,11 +43,10 @@
option_hints={},
hide_legend=False
) %}
{% set disable = [current_option_id] %}
{% call radios_wrapper(
field, hint, disable, option_hints, hide_legend
) %}
{{ radio_list(child_map[None], child_map, disable) }}
{{ radio_list(child_map[None], child_map, disable, option_hints) }}
{% endcall %}
{% endmacro %}

View File

@@ -6,7 +6,7 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
{% if templates_and_folders_form.move_to.choices and template_list.templates_to_show %}
<div id="move_to_folder_radios">
{{ radios_nested(templates_and_folders_form.move_to, move_to_children, current_option) }}
{{ radios_nested(templates_and_folders_form.move_to, move_to_children, option_hints=option_hints) }}
{{ page_footer('Move', button_name='operation', button_value='move-to-existing-folder') }}
</div>
<div id="move_to_new_folder_form">