admin: allow changing sender roles in a popup
This commit is contained in:
parent
3526c982a7
commit
aff50fc5d7
|
@ -274,7 +274,8 @@ class FormDefPage(Directory):
|
|||
_q_exports = ['', 'fields', 'edit', 'delete', 'duplicate', 'export',
|
||||
'archive', 'invite', 'enable', 'workflow', 'category',
|
||||
'recipient', ('workflow-options', 'workflow_options'),
|
||||
('workflow-status-remapping', 'workflow_status_remapping'),]
|
||||
('workflow-status-remapping', 'workflow_status_remapping'),
|
||||
'roles']
|
||||
|
||||
def __init__(self, component):
|
||||
try:
|
||||
|
@ -288,6 +289,7 @@ class FormDefPage(Directory):
|
|||
def _q_index [html] (self):
|
||||
html_top('forms', title = self.formdef.name)
|
||||
get_response().filter['sidebar'] = self.get_sidebar()
|
||||
get_response().add_javascript(['jquery.js', 'widget_list.js'])
|
||||
|
||||
'<h2>%s - ' % _('Form')
|
||||
self.formdef.name
|
||||
|
@ -347,6 +349,8 @@ class FormDefPage(Directory):
|
|||
' (%s)' % _('Always advertise')
|
||||
else:
|
||||
'-'
|
||||
' '
|
||||
'(<a href="roles" rel="popup">%s</a>)' % _('change')
|
||||
'</li>'
|
||||
|
||||
if self.formdef.acl_read:
|
||||
|
@ -450,6 +454,29 @@ class FormDefPage(Directory):
|
|||
self.formdef.store()
|
||||
redirect('.')
|
||||
|
||||
def roles [html] (self):
|
||||
form = Form(enctype='multipart/form-data')
|
||||
form.add(WidgetList, 'roles', title=_('Sender Roles'), element_type=SingleSelectWidget,
|
||||
value=self.formdef.roles,
|
||||
add_element_label = _('Add Role'),
|
||||
element_kwargs = {str('render_br'): False,
|
||||
str('options'): [(None, str('---')),
|
||||
(logged_users_role().id, logged_users_role().name)] + get_user_roles()})
|
||||
form.add_submit('submit', _('Submit'))
|
||||
form.add_submit('cancel', _('Cancel'))
|
||||
if form.get_widget('cancel').parse():
|
||||
return redirect('.')
|
||||
|
||||
if not form.is_submitted() or form.has_errors():
|
||||
get_response().breadcrumb.append( ('recipient', _('Recipient Role')) )
|
||||
html_top('forms', title=self.formdef.name)
|
||||
'<p>%s</p>' % _('Select the roles that can access this form.')
|
||||
form.render()
|
||||
else:
|
||||
self.formdef.roles = [x for x in form.get_widget('roles').parse() if x]
|
||||
self.formdef.store()
|
||||
redirect('.')
|
||||
|
||||
def workflow [html] (self):
|
||||
form = Form(enctype='multipart/form-data')
|
||||
workflows = get_workflows(condition=lambda x: x.possible_status)
|
||||
|
|
|
@ -55,6 +55,9 @@ function displayPopup(event)
|
|||
popup.css('top', '50%').css('left', '50%')
|
||||
popup.fadeIn('fast').focus();
|
||||
$('div.popup-content input:visible')[0].focus();
|
||||
if (popup.find('input[name$=add_element]')) {
|
||||
prepare_widget_list_elements();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
$(document).ready(
|
||||
function () {
|
||||
function prepare_widget_list_elements() {
|
||||
$('input[name$=add_element]').click(
|
||||
function() {
|
||||
/* get prefix from clicked element */
|
||||
|
@ -53,4 +52,5 @@ $(document).ready(
|
|||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$(document).ready(prepare_widget_list_elements);
|
||||
|
|
Loading…
Reference in New Issue