0001-workflows-add-possibility-of-confirmation-dialogs-67.patch
wcs/qommon/static/js/qommon.js | ||
---|---|---|
28 | 28 |
}); |
29 | 29 |
} |
30 | 30 | |
31 |
function prepare_confirmation_buttons() { |
|
32 |
$('input[data-ask-for-confirmation]').click(function() { |
|
33 |
if (confirm(WCS_I18N.confirmation) != true) { |
|
34 |
return false; |
|
35 |
} else { |
|
36 |
return true; |
|
37 |
} |
|
38 |
}); |
|
39 |
} |
|
40 | ||
31 | 41 |
$('[data-content-url]').each(function(idx, elem) { |
32 | 42 |
$.ajax({url: $(elem).data('content-url'), |
33 | 43 |
xhrFields: { withCredentials: true }, |
... | ... | |
42 | 52 |
function prepare_widgets() { |
43 | 53 |
prepare_dynamic_widgets(); |
44 | 54 |
prepate_select_or_other_widgets(); |
55 |
prepare_confirmation_buttons(); |
|
45 | 56 |
} |
46 | 57 | |
47 | 58 |
prepare_widgets(); |
wcs/root.py | ||
---|---|---|
198 | 198 |
_q_exports = ['admin', 'backoffice', 'forms', 'login', 'logout', 'saml', |
199 | 199 |
'ident', 'register', 'afterjobs', 'themes', 'myspace', 'user', 'roles', |
200 | 200 |
'pages', ('tmp-upload', 'tmp_upload'), 'api', '__version__', |
201 |
'tryauth', 'auth', 'preview', ('reload-top', 'reload_top'), 'fargo'] |
|
201 |
'tryauth', 'auth', 'preview', ('reload-top', 'reload_top'), |
|
202 |
'fargo', ('i18n.js', 'i18n_js')] |
|
202 | 203 | |
203 | 204 |
api = ApiDirectory() |
204 | 205 |
themes = template.ThemesDirectory() |
... | ... | |
319 | 320 |
get_response().filter = {} |
320 | 321 |
return htmltext('<html><body><script>window.top.document.location.reload();</script></body></html>') |
321 | 322 | |
323 |
def i18n_js(self): |
|
324 |
get_response().set_content_type('text/javascript') |
|
325 |
strings = { |
|
326 |
'confirmation': _('Are you sure?'), |
|
327 |
} |
|
328 |
return 'WCS_I18N = %s;\n' % json.dumps(strings) |
|
329 | ||
322 | 330 |
admin = None |
323 | 331 |
backoffice = None |
324 | 332 |
wcs/workflows.py | ||
---|---|---|
1714 | 1714 |
label = None |
1715 | 1715 |
by = [] |
1716 | 1716 |
backoffice_info_text = None |
1717 |
require_confirmation = False |
|
1717 | 1718 | |
1718 | 1719 |
def render_as_line(self): |
1719 | 1720 |
if self.label: |
... | ... | |
1728 | 1729 | |
1729 | 1730 |
def fill_form(self, form, formdata, user): |
1730 | 1731 |
form.add_submit('button%s' % self.id, self.label) |
1732 |
if self.require_confirmation: |
|
1733 |
get_response().add_javascript(['jquery.js', '../../i18n.js', 'qommon.js']) |
|
1734 |
widget = form.get_widget('button%s' % self.id) |
|
1735 |
widget.attrs = {'data-ask-for-confirmation': 'true'} |
|
1731 | 1736 |
form.get_widget('button%s' % self.id).backoffice_info_text = self.backoffice_info_text |
1732 | 1737 | |
1733 | 1738 |
def submit_form(self, form, formdata, user, evo): |
... | ... | |
1748 | 1753 |
add_element_label = _('Add Role'), |
1749 | 1754 |
element_kwargs={'render_br': False, |
1750 | 1755 |
'options': [(None, '---', None)] + self.get_list_of_roles()}) |
1756 |
if 'require_confirmation' in parameters: |
|
1757 |
form.add(CheckboxWidget, '%srequire_confirmation' % prefix, |
|
1758 |
title=_('Require confirmation'), |
|
1759 |
value=self.require_confirmation) |
|
1751 | 1760 |
if 'backoffice_info_text' in parameters: |
1752 | 1761 |
form.add(WysiwygTextWidget, '%sbackoffice_info_text' % prefix, |
1753 | 1762 |
title=_('Information Text for Backoffice'), |
1754 | 1763 |
value=self.backoffice_info_text) |
1755 | 1764 | |
1756 | 1765 |
def get_parameters(self): |
1757 |
return ('by', 'status', 'label', 'backoffice_info_text') |
|
1766 |
return ('by', 'status', 'label', 'backoffice_info_text', 'require_confirmation')
|
|
1758 | 1767 | |
1759 | 1768 |
register_item_class(ChoiceWorkflowStatusItem) |
1760 | 1769 | |
1761 |
- |