0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-30 01:46:24 +01:00

Add a create_tab.html include for both the create form and the select-task-type view

This way, the logic for deciding which view to show only happens in one place, rather than being duplicated between the chooser.html template and the TaskChooserCreateView view.
This commit is contained in:
Matt Westcott 2021-12-07 22:03:38 +00:00 committed by LB (Ben Johnston)
parent ef31e160d9
commit e48e34d8cf
3 changed files with 11 additions and 15 deletions

View File

@ -12,11 +12,7 @@
<div class="tab-content">
{% if can_create %}
<section id="new" class="active nice-padding">
{% if create_form %}
{% include "wagtailadmin/workflows/task_chooser/includes/create_form.html" %}
{% else %}
{% include "wagtailadmin/workflows/task_chooser/includes/select_task_type.html" %}
{% endif %}
{% include "wagtailadmin/workflows/task_chooser/includes/create_tab.html" %}
</section>
{% endif %}
<section id="existing" class="nice-padding{% if not can_create %} active{% endif %}">

View File

@ -0,0 +1,5 @@
{% if create_form %}
{% include "wagtailadmin/workflows/task_chooser/includes/create_form.html" %}
{% else %}
{% include "wagtailadmin/workflows/task_chooser/includes/select_task_type.html" %}
{% endif %}

View File

@ -629,16 +629,11 @@ class TaskChooserCreateView(BaseTaskChooserView):
return self.render_to_response()
def render_to_response(self):
if self.create_form:
tab_html = render_to_string("wagtailadmin/workflows/task_chooser/includes/create_form.html", {
'create_form': self.create_form,
'add_url': reverse('wagtailadmin_workflows:task_chooser_create') + '?' + self.request.GET.urlencode() if self.create_model else None,
'task_types': self.get_task_type_options(),
}, self.request)
else:
tab_html = render_to_string("wagtailadmin/workflows/task_chooser/includes/select_task_type.html", {
'task_types': self.get_task_type_options(),
}, self.request)
tab_html = render_to_string("wagtailadmin/workflows/task_chooser/includes/create_tab.html", {
'create_form': self.create_form,
'add_url': reverse('wagtailadmin_workflows:task_chooser_create') + '?' + self.request.GET.urlencode() if self.create_model else None,
'task_types': self.get_task_type_options(),
}, self.request)
js_context = self.get_form_js_context()
js_context['step'] = 'reshow_create_tab'