Use et2_dialog to edit acls instead of separate popup.

This commit is contained in:
Nathan Gray 2014-04-02 18:32:52 +00:00
parent d5c810d5c4
commit f78cbb5c52
3 changed files with 69 additions and 19 deletions

View File

@ -324,6 +324,52 @@ app.classes.admin = AppJS.extend(
if (app != 'admin') app = 'preferences'; if (app != 'admin') app = 'preferences';
var className = app+'_acl'; var className = app+'_acl';
// Select options are already here, just pull them and pass along
var sel_options = jQuery.extend({}, this.et2.getArrayMgr('sel_options').data||{}, {
'apps': this.et2.getArrayMgr('sel_options').getEntry('acl_appname')
});
// For add and edit, set some data from the list since it's already there
var acl_rights = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('acl_rights')||{};
var content = _senders[0].id ? jQuery.extend({}, egw.dataGetUIDdata(_senders[0].id).data) : {};
if(!content.acl_appname)
{
// Pre-set appname to currently selected
content.acl_appname = this.et2.getWidgetById('filter2').getValue();
}
if(!content.acl_location)
{
content.acl_location = this.et2.getWidgetById('filter2').getValue() == 'run' ? 'run' : null;
}
if(!content.acl_account)
{
content.acl_account = this.et2.getWidgetById('nm').getArrayMgr('content').getEntry('account_id');
}
if(content.acl_appname)
{
content.apps = content.acl_appname;
content.acl_rights = content.acl_rights ? parseInt(acl_rights) : null;
jQuery.extend(content, {acl:[],right:[],label:[]});
for( var right in acl_rights[content.acl_appname])
{
content.acl.push(content.acl_rights & right);
content.right.push(right);
content.label.push(egw.lang(acl_rights[content.acl_appname][right]));
}
// These aren't actually there
if(content.acl_account)
{
sel_options.acl_account = {};
this.egw.link_title('home-accounts', content.acl_account, function(title) {sel_options.acl_account[content.acl_account] = title;});
}
if(content.acl_location)
{
sel_options.acl_location = {};
this.egw.link_title('home-accounts', content.acl_location, function(title) {sel_options.acl_location[content.acl_location] = title;});
}
}
switch(_action.id) switch(_action.id)
{ {
case 'delete': case 'delete':
@ -332,20 +378,28 @@ app.classes.admin = AppJS.extend(
break; break;
case 'edit': case 'edit':
// need to specify window to get correct opener, as admin has multiple windows open!
egw('admin', window).open_link(egw.link('/index.php', {
menuaction: app+'.'+className+'.acl',
id: ids[0]
}), 'acl', '300x300');
break;
case 'add': case 'add':
var current = ids[0].split(':'); return et2_createWidget("dialog", {
egw('admin', window).open_link(egw.link('/index.php', { callback: jQuery.proxy(function(_button_id, _value) {
menuaction: app+'.'+className+'.acl', if(_button_id != et2_dialog.OK_BUTTON) return;
app: current[0],
account: current[1] var id = _value.acl_appname+':'+_value.acl_account+':'+_value.acl_location;
}), 'acl', '250x250'); var rights = 0;
for(var i in _value.acl)
{
rights += parseInt(_value.acl[i]);
}
this.egw.json(className+'::ajax_change_acl', [id, rights], this._acl_callback,this,false,this)
.sendRequest();
},this),
title: egw.lang('Access control'),
buttons: et2_dialog.BUTTONS_OK_CANCEL,
value: {
content: content,
sel_options: sel_options
},
template: egw.webserverUrl+'/admin/templates/default/acl.edit.xet'
}, et2_dialog._create_parent(app));
break; break;
} }
}, },

View File

@ -45,9 +45,5 @@
</row> </row>
</rows> </rows>
</grid> </grid>
<hbox>
<button label="Save" id="save"/>
<button label="Cancel" id="cancel" onclick="window.close();"/>
</hbox>
</template> </template>
</overlay> </overlay>

View File

@ -45,7 +45,7 @@
</template> </template>
<template id="admin.index" template="" lang="" group="0" version="1.9.001"> <template id="admin.index" template="" lang="" group="0" version="1.9.001">
<tree autoloading="admin_ui::ajax_tree" id="tree" onclick="app.admin.run" parent_node="admin_tree_target" std_images="bullet"/> <tree autoloading="admin_ui::ajax_tree" id="tree" onclick="app.admin.run" parent_node="admin_tree_target" std_images="bullet"/>
<nextmatch id="nm" template="admin.index.rows"/> <nextmatch id="nm" template="admin.index.rows" disabled="true"/>
<iframe frameborder="1" height="100%" id="iframe" scrolling="auto" width="100%" disabled="true"/> <iframe frameborder="1" height="100%" id="iframe" scrolling="auto" width="100%"/>
</template> </template>
</overlay> </overlay>