From edccd9403ecb96fc303c3c58f04251992be9bba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 28 May 2018 12:53:30 +0200 Subject: [PATCH] forms: include titles and subtitles in summary page (#18779) --- tests/test_form_pages.py | 29 +++++++++++++++++++++++++++++ wcs/forms/common.py | 17 +++++++++++++++-- wcs/qommon/static/css/qommon.css | 9 +++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/tests/test_form_pages.py b/tests/test_form_pages.py index e2062eba..421e5744 100644 --- a/tests/test_form_pages.py +++ b/tests/test_form_pages.py @@ -1018,6 +1018,35 @@ def test_form_submit_with_user(pub, emails): assert emails.emails.get('New form (test)') assert emails.emails.get('New form (test)')['email_rcpt'] == ['foo@localhost'] +def test_form_titles(pub): + formdef = create_formdef() + formdef.fields = [ + fields.PageField(id='0', label='1st page', type='page'), + fields.TitleField(id='4', label='1st page', type='title'), + fields.SubtitleField(id='5', label='subtitle of 1st page', type='subtitle'), + fields.StringField(id='1', label='string'), + fields.PageField(id='2', label='2nd page', type='page'), + fields.TitleField(id='6', label='title of second page', type='title'), + fields.StringField(id='3', label='string 2', required=False)] + formdef.store() + formdef.data_class().wipe() + + resp = get_app(pub).get('/test/') + assert not '

1st page/h3>' in resp.body + assert '

subtitle of 1st page

' in resp.body + resp.form['f1'] = 'foo' + resp = resp.form.submit('submit') + assert '

title of second page

' in resp.body + resp = resp.form.submit('submit') # -> validation page + assert '

1st page

' in resp.body + assert '

subtitle of 1st page

' in resp.body + assert '

title of second page

' in resp.body + resp = resp.form.submit('submit').follow() # -> submit + assert '

1st page

' in resp.body + assert not '

1st page

' in resp.body + assert '

subtitle of 1st page

' in resp.body + assert '

title of second page

' in resp.body + def test_form_visit_existing(pub): user = create_user(pub) formdef = create_formdef() diff --git a/wcs/forms/common.py b/wcs/forms/common.py index 806f6a95..920a8c68 100644 --- a/wcs/forms/common.py +++ b/wcs/forms/common.py @@ -332,7 +332,7 @@ class FormStatusPage(Directory, FormTemplateMixin): r = TemplateIO(html=True) on_page = False on_disabled_page = False - for f in fields: + for i, f in enumerate(fields): if f.type == 'page': on_disabled_page = False if not f.is_visible(self.filled.data, self.formdef): @@ -359,7 +359,20 @@ class FormStatusPage(Directory, FormTemplateMixin): r += htmltext('
') r += htmltext('

%s

') % f.label r += htmltext('
') - on_page = True + on_page = f + continue + + if f.type == 'title' and on_page and fields[i-1] is on_page and on_page.label == f.label: + # don't include first title of a page if that title has the + # same text as the page. + continue + + if f.type == 'title': + r += htmltext('

%s

') % (f.extra_css_class or '', f.label) + continue + + if f.type == 'subtitle': + r += htmltext('

%s

') % (f.extra_css_class or '', f.label) continue if not hasattr(f, str('get_view_value')): diff --git a/wcs/qommon/static/css/qommon.css b/wcs/qommon/static/css/qommon.css index a26f7816..a98c86e4 100644 --- a/wcs/qommon/static/css/qommon.css +++ b/wcs/qommon/static/css/qommon.css @@ -324,6 +324,15 @@ div.dataview div.page h3 { margin-bottom: 1ex; } +div.dataview div.title h3 { + font-size: 115%; +} + +div.dataview div.subtitle h4{ + font-size: 110%; + border: none; +} + a#display-exception { display: none; } -- 2.17.0