From c50c3763b1b5eabcff25c57c030964d075e0f648 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 12 Oct 2016 11:01:59 -0400 Subject: [PATCH] (js) Add automatic refresh of calendar view We were only refreshing the selected component list, we now also refresh the calendar view. --- NEWS | 1 + .../js/Scheduler/CalendarController.js | 6 ++++++ .../js/Scheduler/CalendarListController.js | 2 +- .../js/Scheduler/Component.service.js | 10 ++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index aeda7bf80..c4cc71102 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ Enhancements Bug fixes - [web] fixed tasks list when some weekdays are disabled + - [web] fixed automatic refresh of calendar view 3.2.0 (2016-10-03) diff --git a/UI/WebServerResources/js/Scheduler/CalendarController.js b/UI/WebServerResources/js/Scheduler/CalendarController.js index 5bbde4c24..b0755ba6f 100644 --- a/UI/WebServerResources/js/Scheduler/CalendarController.js +++ b/UI/WebServerResources/js/Scheduler/CalendarController.js @@ -111,6 +111,12 @@ changeDate($event, date); } + /** + * Format a date according to the current view. + * - Day/Multicolumn: name of weekday + * - Week: week number + * - Month: name of month + */ function _formatDate(date) { if ($stateParams.view == 'month') { date.setDate(1); diff --git a/UI/WebServerResources/js/Scheduler/CalendarListController.js b/UI/WebServerResources/js/Scheduler/CalendarListController.js index 475ea661b..6c909095a 100644 --- a/UI/WebServerResources/js/Scheduler/CalendarListController.js +++ b/UI/WebServerResources/js/Scheduler/CalendarListController.js @@ -41,7 +41,7 @@ vm.selectedList = 1; type = 'tasks'; } - selectComponentType(type, { reload: true }); + selectComponentType(type, { reload: true }); // fetch events/tasks lists }); // Refresh current list when the list of calendars is modified diff --git a/UI/WebServerResources/js/Scheduler/Component.service.js b/UI/WebServerResources/js/Scheduler/Component.service.js index 2c0a3a9b9..edbcaf8b1 100644 --- a/UI/WebServerResources/js/Scheduler/Component.service.js +++ b/UI/WebServerResources/js/Scheduler/Component.service.js @@ -31,12 +31,13 @@ * @desc The factory we'll use to register with Angular * @returns the Component constructor */ - Component.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'sgComponent_STATUS', 'Preferences', 'Card', 'Gravatar', 'Resource', function($q, $timeout, $log, Settings, Component_STATUS, Preferences, Card, Gravatar, Resource) { + Component.$factory = ['$q', '$timeout', '$log', '$rootScope', 'sgSettings', 'sgComponent_STATUS', 'Preferences', 'Card', 'Gravatar', 'Resource', function($q, $timeout, $log, $rootScope, Settings, Component_STATUS, Preferences, Card, Gravatar, Resource) { angular.extend(Component, { STATUS: Component_STATUS, $q: $q, $timeout: $timeout, $log: $log, + $rootScope: $rootScope, $Preferences: Preferences, $Card: Card, $gravatar: Gravatar, @@ -119,7 +120,8 @@ /** * @function $startRefreshTimeout * @memberof Component - * @desc Starts the refresh timeout for the current selected component type, for all calendars + * @desc Starts the refresh timeout for the current selected list (events or tasks) and + * current view. */ Component.$startRefreshTimeout = function(type) { var _this = this; @@ -131,7 +133,7 @@ // Restart the refresh timer, if needed var refreshViewCheck = Component.$Preferences.defaults.SOGoRefreshViewCheck; if (refreshViewCheck && refreshViewCheck != 'manually') { - var f = angular.bind(_this, Component.$filter, type); + var f = angular.bind(Component.$rootScope, Component.$rootScope.$emit, 'calendars:list'); Component.$refreshTimeout = Component.$timeout(f, refreshViewCheck.timeInterval()*1000); } }); @@ -194,8 +196,8 @@ angular.extend(_this[queryKey], _this.$query)); // Invalidate cached results of other type if $query has changed - otherType = (type == 'tasks')? '$events' : '$tasks'; if (dirty) { + otherType = (type == 'tasks')? '$events' : '$tasks'; delete Component[otherType]; Component.$log.debug('force reload of ' + otherType); }