add new folder from the choose template page

This commit is contained in:
Leo Hemsted
2018-11-14 17:30:22 +00:00
parent b872ba21a7
commit 9dec9ed626
2 changed files with 25 additions and 3 deletions

View File

@@ -117,6 +117,7 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
template_type=template_type,
current_folder_id=template_folder_id,
)
add_folder_form = TemplateFolderForm()
if is_valid_template_operation('move', templates_and_folders_form):
current_service.move_to_folder(
@@ -125,6 +126,16 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
)
return redirect(request.url)
if is_valid_template_operation('add_new_folder', add_folder_form):
template_folder_api_client.create_template_folder(
current_service.id,
name=add_folder_form.name.data,
parent_id=template_folder_id
)
return redirect(
url_for('.choose_template', service_id=service_id, template_folder_id=template_folder_id)
)
return render_template(
'views/templates/choose.html',
current_template_folder_id=template_folder_id,
@@ -140,6 +151,7 @@ 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,
add_folder_form=add_folder_form,
)

View File

@@ -3,6 +3,8 @@
{% from "components/message-count-label.html" import message_count_label %}
{% from "components/textbox.html" import textbox %}
{% from "components/live-search.html" import live_search %}
{% from "components/form.html" import form_wrapper %}
{% from "components/page-footer.html" import page_footer %}
{% extends "withnav_template.html" %}
@@ -76,10 +78,18 @@
{{ live_search(target_selector='#template-list .template-list-item', show=show_search_box, form=search_form) }}
{% if can_manage_folders %}
<form method="post">
{% call form_wrapper() %}
{% include 'views/templates/_template_list.html' %}
{% include 'views/templates/_move_to.html' %}
</form>
{% with templates=templates, template_folders=template_folders, templates_and_folders_form=templates_and_folders_form %}
{% include 'views/templates/_move_to.html' %}
{% endwith %}
{% endcall %}
{% call form_wrapper() %}
{{ textbox(add_folder_form.name) }}
{{ page_footer('New folder', button_name='operation', button_value='add_new_folder') }}
{% endcall %}
{% else %}
{% include 'views/templates/_template_list.html' %}
{% endif %}