From 08c67c8eedf992348dde084356db04c71c983889 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 18 Mar 2014 18:31:52 +0000 Subject: [PATCH] update accounts list and fix "add account" action on tree --- admin/inc/class.admin_account.inc.php | 2 + admin/inc/class.admin_ui.inc.php | 13 ++----- admin/js/app.js | 54 ++++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/admin/inc/class.admin_account.inc.php b/admin/inc/class.admin_account.inc.php index 5bbe640704..4f9a0fc1a5 100644 --- a/admin/inc/class.admin_account.inc.php +++ b/admin/inc/class.admin_account.inc.php @@ -129,6 +129,8 @@ class admin_account $cmd = new admin_cmd_edit_user((int)$content['account_id'], $account); $cmd->run(); + egw_json_response::get()->call('egw.refresh', '', 'admin', $cmd->account, $content['account_id'] ? 'edit' : 'add'); + // for a new account a new contact was created, need to merge that data with $content if (!$content['account_id']) { diff --git a/admin/inc/class.admin_ui.inc.php b/admin/inc/class.admin_ui.inc.php index 2081b0e977..fee593ced2 100644 --- a/admin/inc/class.admin_ui.inc.php +++ b/admin/inc/class.admin_ui.inc.php @@ -91,11 +91,7 @@ class admin_ui 'enableId' => '^/groups/-\\d+', 'icon' => 'lock', ), - 'add' => array( - 'caption' => 'Add user', - 'url' => egw::link('/index.php?menuaction=admin.uiaccounts.edit_user'), - 'onExecute' => 'javaScript:app.admin.iframe_location', - ), + 'add' => $content['nm']['actions']['add'], 'delete' => array( 'onExecute' => 'javaScript:app.admin.group', 'confirm' => 'Delete this group', @@ -133,16 +129,13 @@ class admin_ui 'caption' => 'Open', 'default' => true, 'allowOnMultiple' => false, - 'popup' => egw_link::is_popup('addressbook', 'edit'), - 'url' => '', + 'onExecute' => 'javaScript:app.admin.account', 'group' => $group=0, ), 'add' => array( 'caption' => 'Add user', - 'url' => 'menuaction=admin.uiaccounts.edit_user', + 'onExecute' => 'javaScript:app.admin.account', 'group' => $group, - 'popup' => egw_link::is_popup('addressbook', 'add'), - 'url' => '', ), 'acl' => array( 'caption' => 'Access control', diff --git a/admin/js/app.js b/admin/js/app.js index 03629f0f19..84d61fd657 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -103,21 +103,40 @@ app.classes.admin = AppJS.extend( */ refresh: function(_msg, _app, _id, _type) { + var refresh_done = false; + // Try for intelligent et2 refresh inside iframe - var node = null; - if(_app && _id && this.iframe != null && - (node = this.iframe.getDOMNode(this.iframe)) && - node && node.contentWindow && node.contentWindow.etemplate2) + var node = _app && _id && this.iframe ? this.iframe.getDOMNode(this.iframe) : null; + if(node && node.contentWindow && node.contentWindow.etemplate2) { var templates = node.contentWindow.etemplate2.getByApplication('admin'); for(var i = 0; i < templates.length; i++) { templates[i].refresh(_msg,_app,_id,_type); + refresh_done = true; } } - else + + // update of account list eg. from addressbook.edit + if(!refresh_done && _app == 'admin' && _id) { - this.linkHandler(window.framework.getApplicationByName(_app).browser.currentLocation); + var templates = etemplate2.getByApplication('admin'); + for(var i = 0; i < templates.length; i++) + { + templates[i].refresh(_msg,_app,_id,_type); + refresh_done = true; + } + } + + // update iframe + if (!refresh_done && framework) + { + var app = framework.getApplicationByName(_app); + + if (app && app.browser && app.browser.currentLocation) + { + this.linkHandler(app.browser.currentLocation); + } } }, @@ -378,5 +397,28 @@ app.classes.admin = AppJS.extend( { img.set_src(widget.getValue()); } + }, + + + /** + * Add / edit an account + * + * @param {object} _action egwAction + * @param {array} _senders egwActionObject _senders[0].id holds account_id + */ + account: function(_action, _senders) + { + var params = jQuery.extend({}, this.egw.link_get_registry('addressbook', 'edit')); + var popup = this.egw.link_get_registry('addressbook', 'edit_popup'); + + if (_action.id == 'add') + { + params.owner = '0'; + } + else + { + params.account_id = _senders[0].id.substr(7); // remove admin:: + } + this.egw.open_link(this.egw.link('/index.php', params), 'admin', popup); } });