From b7a8e417789f67dc369860141067767eb8eda08b Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 19 Mar 2015 15:30:34 +0000 Subject: [PATCH] Get calendar view working with orgs again --- addressbook/inc/class.addressbook_ui.inc.php | 11 +++-- addressbook/js/app.js | 51 ++++++++++++++++++++ 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index e143a7a12c..56be05c193 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -579,15 +579,16 @@ class addressbook_ui extends addressbook_bo 'calendar_view' => array( 'caption' => 'Show', 'icon' => 'view', - 'url' => 'menuaction=calendar.calendar_uilist.listview&filter=all&owner=0,c$id&ajax=true', - 'targetapp' => 'calendar', // open in calendar tab + 'url' => 'menuaction=calendar.calendar_uiforms.edit&participants=c$id', + 'onExecute' => 'javaScript:app.addressbook.view_calendar', + 'targetapp' => 'calendar', // open in calendar tab, + 'hideOnDisabled' => true, ), 'calendar_add' => array( 'caption' => 'Add appointment', 'icon' => 'new', - 'url' => 'menuaction=calendar.calendar_uiforms.edit&participants=c$id', 'popup' => egw_link::get_registry('calendar', 'add_popup'), - 'onExecute' => 'javaScript:app.addressbook.add_cal', // call server for org-view only + 'onExecute' => 'javaScript:app.addressbook.add_cal', ), ), ); @@ -1076,7 +1077,7 @@ window.egw_LAB.wait(function() { $msg = ''; // no message, as we send none in javascript too and users sees opening popup return false; - case 'calendar_view': // show calendar for org-views, other views are handled directly in javascript + case 'calendar_view': // show calendar for org-views, although all views are handled directly in javascript list($width,$height) = explode('x',egw_link::get_registry('calendar', 'add_popup')); egw::redirect_link('/index.php',array( 'menuaction' => 'calendar.calendar_uiviews.index', diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 6c004000e4..a480742ae3 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -157,6 +157,57 @@ app.classes.addressbook = AppJS.extend( } }, + /** + * Open the calender to view the selected contacts + * @param {egwAction} _action + * @param {egwActionObject[]} _senders + */ + view_calendar: function(_action, _senders) + { + var extras = { + filter: 'all', + owner: [] + }; + var orgs = []; + for(var i = 0; i < _senders.length; i++) + { + // Remove UID prefix for just contact_id + var ids = _senders[i].id.split('::'); + ids.shift(); + ids = ids.join('::'); + + // Orgs need to get all the contact IDs first + if (ids.substr(0,9) == 'org_name:') + { + orgs.push(ids); + } + else + { + extras.owner.push('c'+ids); + } + } + + if(orgs.length > 0) + { + // Get organisation contacts, then show infolog list + this.egw.json('addressbook.addressbook_ui.ajax_organisation_contacts', + [orgs], + function(contacts) { + for(var i = 0; i < contacts.length; i++) + { + extras.owner.push('c'+contacts[i]); + } + extras.owner = extras.owner.join(','); + this.egw.open('','calendar','list',extras,'calendar'); + },this,true,this + ).sendRequest(); + } + else + { + extras.owner = extras.owner.join(','); + egw.open('', 'calendar', 'list', extras, 'calendar'); + } + }, /** * Add appointment or show calendar for selected contacts, call default nm_action after some checks *