From a4113da3283abd834f7530b59f2e67b4fa3fc0bd Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 12 Mar 2014 22:42:06 +0000 Subject: [PATCH] Set up addressbook CRM view to display infolog or tracker, by preference. Tracker list filtering not yet implemented. --- .../inc/class.addressbook_hooks.inc.php | 17 +++++++++++++++++ addressbook/inc/class.addressbook_ui.inc.php | 19 ++++++++++++++----- addressbook/js/app.js | 15 +++++++++------ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index 905aea953d..6740708e82 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -206,6 +206,23 @@ class addressbook_hooks 'admin' => false, 'default'=> 'org_name: n_family, n_given', ); + $crm_list_options = array( + 'infolog' => lang('infolog') + ); + if($GLOBALS['egw_info']['user']['apps']['tracker']) + { + $crm_list_options['tracker'] = lang('tracker'); + } + $settings['crm_list'] = array( + 'type' => 'select', + 'label' => 'CRM view list', + 'name' => 'crm_list', + 'values' => $crm_list_options, + 'help' => 'When viewing a contact, show linked entries from the selected application', + 'xmlrpc' => True, + 'admin' => false, + 'default'=> 'infolog', + ); $settings[] = array( 'type' => 'section', 'title' => lang('Data exchange settings'), diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index bc25dc4772..8e02a7974f 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -2163,12 +2163,21 @@ window.egw_LAB.wait(function() { } $content['index'] = $query['start']; - // Infolog nextmatch is already there, just update the filter + // List nextmatch is already there, just update the filter if($contact_id && egw_json_request::isJSONRequest()) { - egw_json_response::get()->apply('app.addressbook.view_set_infolog',Array($contact_id)); + switch($GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']) + { + case 'infolog': + egw_json_response::get()->apply('app.addressbook.view_set_list',Array('linked',$contact_id)); + break; + case 'tracker': + // TODO - what's the filter? + //egw_json_response::get()->apply('app.addressbook.view_set_list',Array('linked',$contact_id)); + break; + } - // Clear contact_id, it's used as a flag to send infolog + // Clear contact_id, it's used as a flag to send the list unset($contact_id); } break; @@ -2345,10 +2354,10 @@ window.egw_LAB.wait(function() { // Sending it again (via ajax) will break the addressbook.view etemplate2 if($contact_id) { - $GLOBALS['egw']->hooks->process(array( + $GLOBALS['egw']->hooks->single(array( 'location' => 'addressbook_view', 'ab_id' => $content['id'] - )); + ),$GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); } } diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 79beca3f1b..a9ca34b53c 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -93,21 +93,24 @@ app.classes.addressbook = AppJS.extend( }, /** - * Set link filter for the already open & rendered infolog list + * Set link filter for the already open & rendered list * + * @param {string} col_filter_name Name of the column filter to set * @param {string} contact_id New contact ID */ - view_set_infolog: function(contact_id) + view_set_list: function(col_filter_name, contact_id) { // Find the infolog list - var infolog = etemplate2.getById( + var list = etemplate2.getById( $j(this.et2.getInstanceManager().DOMContainer).nextAll('.et2_container').attr('id') ); - var nm = infolog ? infolog.widgetContainer.getWidgetById('nm') : null; - if(nm) + var nm = null; + if(list != null && (nm = list.widgetContainer.getWidgetById('nm'))) { // Update the link filter to new contact - nm.applyFilters({col_filter: {linked: 'addressbook:'+contact_id}}); + var filter = {col_filter:{}}; + filter.col_filter[col_filter_name] = 'addressbook:'+contact_id; + nm.applyFilters(filter); } },