workflows: make "display form" associated button label configurable (#16816)
This commit is contained in:
parent
53420efd4b
commit
6374822ff8
|
@ -3113,6 +3113,17 @@ def test_backoffice_workflow_display_form(pub):
|
|||
assert formdef.data_class().get(formdata.id).workflow_data == {
|
||||
'blah_var_str': 'blah', 'blah_var_radio': 'c', 'blah_var_radio_raw': 'c'}
|
||||
|
||||
# test alternate button label
|
||||
display_form.button_label = 'CLICK ME'
|
||||
wf.store()
|
||||
|
||||
for formdata in formdef.data_class().select():
|
||||
if formdata.status == 'wf-new':
|
||||
break
|
||||
app = login(get_app(pub))
|
||||
resp = app.get(formdata.get_url(backoffice=True))
|
||||
assert 'CLICK ME' in resp.body
|
||||
|
||||
def test_backoffice_criticality_in_formdef_listing(pub):
|
||||
if not pub.is_using_postgresql():
|
||||
pytest.skip('this requires SQL')
|
||||
|
|
|
@ -214,6 +214,10 @@ def test_display_form_action(pub):
|
|||
# formdef.max_field_id is recalculated when importing a FormWorkflowStatusItem
|
||||
assert wf2.possible_status[0].items[0].formdef.max_field_id == len(display_form.formdef.fields)
|
||||
|
||||
display_form.button_label = 'Test'
|
||||
display_form.backoffice_info_text = 'Lorem ipsum long description.'
|
||||
wf2 = assert_import_export_works(wf)
|
||||
|
||||
|
||||
def test_export_to_model_action(pub):
|
||||
wf = Workflow(name='status')
|
||||
|
|
|
@ -78,6 +78,8 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
|
|||
by = []
|
||||
formdef = None
|
||||
varname = None
|
||||
button_label = None
|
||||
backoffice_info_text = None
|
||||
|
||||
@classmethod
|
||||
def init(cls):
|
||||
|
@ -93,6 +95,14 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
|
|||
element_kwargs = {'render_br': False,
|
||||
'options': [(None, '---', None)] +
|
||||
self.get_list_of_roles(include_logged_in_users=False)})
|
||||
if 'button_label' in parameters:
|
||||
form.add(StringWidget, '%sbutton_label' % prefix, title=_('Button Label'),
|
||||
value=self.button_label or _('Submit'),
|
||||
required=True)
|
||||
if 'backoffice_info_text' in parameters:
|
||||
form.add(WysiwygTextWidget, '%sbackoffice_info_text' % prefix,
|
||||
title=_('Information Text for Backoffice'),
|
||||
value=self.backoffice_info_text)
|
||||
if 'varname' in parameters:
|
||||
form.add(VarnameWidget, '%svarname' % prefix, required=True,
|
||||
title=_('Identifier'), value=self.varname,
|
||||
|
@ -101,7 +111,7 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
|
|||
form.widgets.append(HtmlWidget(htmltext('<p><a href="fields/">%s</a></p>') % _('Edit Fields')))
|
||||
|
||||
def get_parameters(self):
|
||||
return ('by', 'varname')
|
||||
return ('by', 'button_label', 'backoffice_info_text', 'varname')
|
||||
|
||||
def export_to_xml(self, charset, include_id=False):
|
||||
item = WorkflowStatusItem.export_to_xml(self, charset, include_id=include_id)
|
||||
|
@ -144,7 +154,8 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
|
|||
if not self.formdef:
|
||||
return
|
||||
self.formdef.add_fields_to_form(form)
|
||||
form.add_submit('submit', _('Submit'))
|
||||
form.add_submit('submit', self.button_label or _('Submit'))
|
||||
form.get_widget('submit').backoffice_info_text = self.backoffice_info_text
|
||||
|
||||
formdata.feed_session()
|
||||
|
||||
|
|
Loading…
Reference in New Issue