From 2976d910dbb840abb4b412ce0b94144967eae33a Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 16 May 2016 14:32:03 -0600 Subject: [PATCH] Some bugfixes for planner view in sitemgr: - Add check on sel_options arrayMgr for missing owner names, since sidebox is not there - Pre-fill sel_options for above, so they can be found - Fix clicking on an event could alter the calendar state --- ...lass.calendar_owner_etemplate_widget.inc.php | 2 +- calendar/js/app.js | 4 ++++ calendar/js/et2_widget_planner.js | 2 +- calendar/js/et2_widget_view.js | 13 +++++++++++-- .../class.module_calendar_planner.inc.php | 17 ++++++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php index e28f95ae4a..ba81e17c08 100644 --- a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php +++ b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php @@ -199,7 +199,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist * Get just the label for a single owner * @param string $id */ - protected static function get_owner_label($id) + public static function get_owner_label($id) { static $bo; if(!$bo) $bo = new calendar_bo(); diff --git a/calendar/js/app.js b/calendar/js/app.js index 21f1be447d..2bc3375f3b 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -3446,7 +3446,11 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( * hidden. */ _set_autorefresh: function() { + // Listview not loaded + if(typeof app.classes.calendar.views.listview.etemplates[0] == 'string') return; + var nm = app.classes.calendar.views.listview.etemplates[0].widgetContainer.getWidgetById('nm'); + // nextmatch missing if(!nm) return; var refresh_preference = "nextmatch-" + nm.options.settings.columnselection_pref + "-autorefresh"; diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 63f1e9cbc0..b51d378525 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -1779,7 +1779,7 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e } return result; } - else if (!jQuery.isEmptyObject(_ev.target.dataset)) + else if (this.gridHeader.has(_ev.target).length > 0 && !jQuery.isEmptyObject(_ev.target.dataset)) { // Click on a header, we can go there _ev.data = jQuery.extend({},_ev.target.parentNode.dataset, _ev.target.dataset); diff --git a/calendar/js/et2_widget_view.js b/calendar/js/et2_widget_view.js index f04a46ad48..8553523e8d 100644 --- a/calendar/js/et2_widget_view.js +++ b/calendar/js/et2_widget_view.js @@ -329,10 +329,19 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend } if(typeof label === 'undefined') { - // Not found? Ask the sidebox owner widget, it gets updated + // Not found? Ask the sidebox owner widget (it gets updated) or the original arrayMgr + var options = false if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner')) { - user = app.calendar.sidebox_et2.getWidgetById('owner').options.select_options.find(function(element) {return element.id == user;}) || {}; + options = app.calendar.sidebox_et2.getWidgetById('owner').options.select_options; + } + else + { + options = this.getArrayMgr("sel_options").getRoot().getEntry('owner'); + } + if(options && options.find) + { + user = options.find(function(element) {return element.id == user;}) || {}; label = user.label; } else diff --git a/calendar/sitemgr/class.module_calendar_planner.inc.php b/calendar/sitemgr/class.module_calendar_planner.inc.php index 165f0a2ecf..f5db38798b 100644 --- a/calendar/sitemgr/class.module_calendar_planner.inc.php +++ b/calendar/sitemgr/class.module_calendar_planner.inc.php @@ -306,6 +306,9 @@ class module_calendar_planner extends Module $search_params['end'] = $ui->last; $search_params['owner'] = $ui->owner; $search_params['enum_groups'] = $ui->sortby == 'user'; + + $content = array(); + $sel_options = array(); $content['planner'] = $ui->bo->search($search_params); foreach($content['planner'] as &$event) { @@ -318,7 +321,19 @@ class module_calendar_planner extends Module $tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2)); $tmpl->setElementAttribute('planner','owner', $search_params['owner']); $tmpl->setElementAttribute('planner','group_by', $ui->sortby); - $tmpl->exec(__METHOD__, $content,array(), array('__ALL__' => true),array(),2); + + // Make sure all used owners are there, faking + // calendar_owner_etemplate_widget::beforeSendToClient() since the + // rest of the calendar app is probably missing. + foreach($search_params['owner'] as $owner) + { + $sel_options['owner'][] = Array( + 'id' => $owner, + 'value' => $owner, + 'label' => calendar_owner_etemplate_widget::get_owner_label($owner) + ); + } + $tmpl->exec(__METHOD__, $content,$sel_options, array('__ALL__' => true),array(),2); $html .= ob_get_contents(); $html .= '