Move descriptions for hidden fields on top of dynamic_ui forms

Hidden fields can have descriptions and they would be displayed just
like every other fields description in dynamic-ui. However they're
usually used to display some generic information. Since they're included
in the 'right' panel in the modal dialog, it breaks the flow of the
dialog.
This commit moves them before all the fields and removes duplicated
{{service_name}} from the form.

Change-Id: I1b01bd0fda395aebd1b39bef92990d702b71ba8b
Partial-Bug: #1596979
This commit is contained in:
Kirill Zaitsev 2016-06-28 19:25:28 +03:00
parent 82ca1334c4
commit b1c55c79fd
3 changed files with 13 additions and 5 deletions

View File

@ -439,8 +439,9 @@ class Wizard(generic_views.PageTitleMixin, views.ModalFormMixin, LazyWizard):
else:
env_name = get_next_quick_environment_name(self.request)
context['field_descriptions'] = services.get_app_field_descriptions(
field_descr, extended_descr = services.get_app_field_descriptions(
self.request, app_id, self.steps.index)
context.update({'type': app.fully_qualified_name,
'service_name': app.name,
'app_id': app_id,
@ -449,6 +450,8 @@ class Wizard(generic_views.PageTitleMixin, views.ModalFormMixin, LazyWizard):
'do_redirect': self.get_wizard_flag('do_redirect'),
'drop_wm_form': self.get_wizard_flag('drop_wm_form'),
'prefix': self.prefix,
'field_descriptions': field_descr,
'extended_descriptions': extended_descr,
})
return context

View File

@ -242,9 +242,13 @@ def get_app_field_descriptions(request, app_id, index):
form_cls = app.forms[index]
descriptions = []
no_field_descriptions = []
for name, field in six.iteritems(form_cls.base_fields):
title = field.description_title
description = field.description
if description:
descriptions.append((name, title, description))
return descriptions
if field.widget.is_hidden:
no_field_descriptions.extend([description, title])
else:
descriptions.append((name, title, description))
return descriptions, no_field_descriptions

View File

@ -28,6 +28,9 @@
{% endblock %}
{% block modal-body %}
{% for ext_description in extended_descriptions %}
<p>{{ ext_description }}</p>
{% endfor %}
<div class="left">
{{ wizard.management_form }}
{% if wizard.form.forms %}
@ -42,10 +45,8 @@
{% endwith %}
</fieldset>
{% endif %}
<p>{{ extended_description }}</p>
</div>
<div class="right">
<h3>{{ service_name }}</h3>
{% for name, title, description in field_descriptions %}
<p>
{% if title %}