forms: include titles and subtitles in summary page (#18779)

This commit is contained in:
Frédéric Péters 2018-05-28 12:53:30 +02:00
parent 0f19aab60b
commit f6e89c2a25
3 changed files with 53 additions and 2 deletions

View File

@ -1017,6 +1017,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 '<h3>1st page/h3>' in resp.body
assert '<h4>subtitle of 1st page</h4>' in resp.body
resp.form['f1'] = 'foo'
resp = resp.form.submit('submit')
assert '<h3>title of second page</h3>' in resp.body
resp = resp.form.submit('submit') # -> validation page
assert '<h3>1st page</h3>' in resp.body
assert '<h4>subtitle of 1st page</h4>' in resp.body
assert '<h3>title of second page</h3>' in resp.body
resp = resp.form.submit('submit').follow() # -> submit
assert '<h3>1st page</h3>' in resp.body
assert not '<div class="title "><h3>1st page</h3></div>' in resp.body
assert '<div class="subtitle "><h4>subtitle of 1st page</h4></div>' in resp.body
assert '<div class="title "><h3>title of second page</h3></div>' in resp.body
def test_form_visit_existing(pub):
user = create_user(pub)
formdef = create_formdef()

View File

@ -330,7 +330,7 @@ class FormStatusPage(Directory):
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):
@ -357,7 +357,20 @@ class FormStatusPage(Directory):
r += htmltext('<div class="page">')
r += htmltext('<h3>%s</h3>') % f.label
r += htmltext('<div>')
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('<div class="title %s"><h3>%s</h3></div>') % (f.extra_css_class or '', f.label)
continue
if f.type == 'subtitle':
r += htmltext('<div class="subtitle %s"><h4>%s</h4></div>') % (f.extra_css_class or '', f.label)
continue
if not hasattr(f, str('get_view_value')):

View File

@ -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;
}