misc: add a cancel button to interactive global action form (#76076) #659
|
@ -1157,17 +1157,28 @@ def test_backoffice_multi_actions_interactive(pub):
|
|||
form_action.by = trigger.roles
|
||||
workflow.store()
|
||||
|
||||
resp = app.get(formdef.get_url(backoffice=True) + '?limit=20')
|
||||
ids = []
|
||||
for checkbox in resp.forms[0].fields['select[]'][1:6]:
|
||||
ids.append(checkbox._value)
|
||||
checkbox.checked = True
|
||||
for check in ('cancel', 'submit'):
|
||||
resp = app.get(formdef.get_url(backoffice=True) + '?limit=20')
|
||||
ids = []
|
||||
for checkbox in resp.forms[0].fields['select[]'][1:6]:
|
||||
ids.append(checkbox._value)
|
||||
checkbox.checked = True
|
||||
|
||||
resp = resp.forms[0].submit('button-action-1')
|
||||
assert '/actions/' in resp.location
|
||||
resp = resp.follow()
|
||||
assert '5 selected forms' in resp.text
|
||||
if check == 'cancel':
|
||||
resp = resp.form.submit('cancel')
|
||||
assert (
|
||||
resp.location
|
||||
== 'http://example.net/backoffice/management/test-multi-actions-interactive/?limit=20'
|
||||
)
|
||||
else:
|
||||
# click
|
||||
resp = resp.form.submit('submit')
|
||||
# and continue to the rest of the test
|
||||
|
||||
resp = resp.forms[0].submit('button-action-1')
|
||||
assert '/actions/' in resp.location
|
||||
resp = resp.follow()
|
||||
assert '5 selected forms' in resp.text
|
||||
resp = resp.form.submit('submit')
|
||||
assert resp.pyquery('#form_error_fblah_1').text() == 'required field'
|
||||
resp.form['fblah_1'] = 'GLOBAL INTERACTIVE ACTION'
|
||||
resp = resp.form.submit('submit')
|
||||
|
@ -1735,6 +1746,13 @@ def test_backoffice_global_interactive_action(pub):
|
|||
|
||||
assert 'HELLO GLOBAL INTERACTIVE ACTION' in resp.text
|
||||
|
||||
# check cancel button
|
||||
resp = app.get(formdata.get_url(backoffice=True))
|
||||
resp = resp.form.submit('button-action-1')
|
||||
resp = resp.follow()
|
||||
resp = resp.form.submit('cancel')
|
||||
assert resp.location == formdata.get_url(backoffice=True)
|
||||
|
||||
|
||||
def test_backoffice_global_interactive_action_manual_jump(pub):
|
||||
create_user(pub)
|
||||
|
|
|
@ -165,8 +165,12 @@ class GlobalInteractiveActionDirectory(Directory, FormTemplateMixin):
|
|||
% self.action.name,
|
||||
formdata=self.formdata,
|
||||
)
|
||||
|
||||
return redirect(self.token.context['return_url'])
|
||||
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
if form.get_submit() == 'cancel':
|
||||
return redirect(self.token.context['return_url'])
|
||||
|
||||
if not form.is_submitted() or form.has_errors():
|
||||
messages = self.action.get_messages()
|
||||
form.attrs['data-live-url'] = (
|
||||
|
|
Loading…
Reference in New Issue