From d599cadf8aaf6defb1db7495198dfabc19270cda Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 11 May 2015 21:03:29 +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 30e179a44b..f9cebf3539 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1044,8 +1044,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 7717e52358..6596c01d35 100644 --- a/infolog/js/app.js +++ b/infolog/js/app.js @@ -488,6 +488,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 @@ -514,6 +535,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 || "",