From 5b002b4b0b091a07d0085181d61f9a4cf0f22279 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 11 May 2015 21:05:38 +0000 Subject: [PATCH] Pre-set contact in new infologs opened from context menu. Contact taken from link filter, or current contact when in CRM view. --- infolog/inc/class.infolog_ui.inc.php | 3 +-- infolog/js/app.js | 32 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 8dbe7306f6..ac1c95172f 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1045,8 +1045,7 @@ class infolog_ui 'icon' => $type, ); $types_add[$type] = $data + array( - 'url' => 'menuaction=infolog.infolog_ui.edit&type='.$type, - 'popup' => egw_link::get_registry('infolog', 'add_popup'), + 'onExecute' => "javaScript:app.infolog.add_action_handler" ); } diff --git a/infolog/js/app.js b/infolog/js/app.js index 8cf7a2e217..0627f1aa42 100644 --- a/infolog/js/app.js +++ b/infolog/js/app.js @@ -481,6 +481,27 @@ app.classes.infolog = AppJS.extend( egw.open('','infolog','add'); }, + /** + * Wrapper so add -> New actions in the context menu can pass current + * filter values into new edit dialog + * + * @see add_with_extras + * + * @param {egwAction} action + * @param {egwActionObject[]} selected + */ + add_action_handler: function(action, selected) + { + var nm = action.getManager().data.nextmatch || false; + if(nm) + { + this.add_with_extras(nm,action.id, + nm.getArrayMgr('content').getEntry('action'), + nm.getArrayMgr('content').getEntry('action_id') + ); + } + }, + /** * Opens a new edit dialog with some extra url parameters pulled from * standard locations. Done with a function instead of hardcoding so @@ -507,6 +528,17 @@ app.classes.infolog = AppJS.extend( // Need a real array here action_id = jQuery.map(action_id,function(val) {return val;}); } + + // No action? Try the linked filter, in case it's set + if(!_action && !_action_id) + { + if(nm_value.col_filter && nm_value.col_filter.linked) + { + var split = nm_value.col_filter.linked.split(':') || ''; + _action = split[0] || ''; + action_id = split[1] || ''; + } + } var extras = { type: _type || nm_value.filter || "", cat_id: nm_value.cat_id || "",