From 7ef6a2968a94cd8831cd5465f17f23590e8002d7 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 5 Jun 2018 12:57:01 -0600 Subject: [PATCH] * Calendar - Add preference to update calendar view immediately when navigation calendar in sidebox is changed --- calendar/inc/class.calendar_hooks.inc.php | 7 +++++++ calendar/js/app.js | 18 ++++++++++++++---- calendar/lang/egw_de.lang | 1 + calendar/lang/egw_en.lang | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index d7dee047d7..b811e5ff0f 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -362,6 +362,13 @@ class calendar_hooks 'admin' => False, 'default' => ['weekN', 'month'], ), + 'auto_update_on_sidebox_change' => array( + 'type' => 'check', + 'label' => 'Update calendar view immediately when navigation calendar in sidebox is changed', + 'name' => 'auto_update_on_sidebox_change', + 'help' => 'When changing the month', + 'default'=> false + ), 'link_title' => array( 'type' => 'multiselect', 'label' => 'Link title for events to show', diff --git a/calendar/js/app.js b/calendar/js/app.js index 8a9609fc08..7c865f5de5 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -3348,6 +3348,8 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( // Dynamic resize of sidebox calendar to fill sidebox var preferred_width = jQuery('#calendar-sidebox_date .ui-datepicker-inline').outerWidth(); var font_ratio = 12 / parseFloat(jQuery('#calendar-sidebox_date .ui-datepicker-inline').css('font-size')); + var go_button_widget = date_widget.getRoot().getWidgetById('header_go'); + var auto_update = this.egw.preference('auto_update_on_sidebox_change', 'calendar') === '1'; var calendar_resize = function() { try { var percent = 1+((jQuery(date_widget.getDOMNode()).width() - preferred_width) / preferred_width); @@ -3356,6 +3358,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( .css('font-size',(percent*100)+'%'); // Position go and today + go_button_widget.set_disabled(false); var buttons = jQuery('#calendar-sidebox_date .ui-datepicker-header a span'); if(today.length && go_button.length) { @@ -3367,6 +3370,10 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( buttons.position({my: 'center', at: 'center', of: go_button}) .css('left', ''); } + if(auto_update) + { + go_button_widget.set_disabled(true); + } } catch (e){ // Resize didn't work } @@ -3377,16 +3384,19 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( onChangeMonthYear: function(year, month, inst) { // Update month button label - var go_button = date_widget.getRoot().getWidgetById('header_go'); - if(go_button) + if(go_button_widget) { var temp_date = new Date(year, month-1, 1,0,0,0); //temp_date.setUTCMinutes(temp_date.getUTCMinutes() + temp_date.getTimezoneOffset()); - go_button.btn.attr('title',egw.lang(date('F',temp_date))); + go_button_widget.btn.attr('title',egw.lang(date('F',temp_date))); // Store current _displayed_ date in date button for clicking temp_date.setUTCMinutes(temp_date.getUTCMinutes() - temp_date.getTimezoneOffset()); - go_button.btn.attr('data-date', temp_date.toJSON()); + go_button_widget.btn.attr('data-date', temp_date.toJSON()); + } + if(auto_update) + { + go_button_widget.click(); } window.setTimeout(calendar_resize,0); }, diff --git a/calendar/lang/egw_de.lang b/calendar/lang/egw_de.lang index 209c1a516b..f5e25724aa 100644 --- a/calendar/lang/egw_de.lang +++ b/calendar/lang/egw_de.lang @@ -587,6 +587,7 @@ two weeks calendar de zwei Wochen type of planner calendar de Planer Typ unable to save calendar de Speichern nicht möglich uninvited calendar de Ausgeladen +update calendar view immediately when navigation calendar in sidebox is changed calendar de Kalenderansicht sofort aktualisieren, wenn der Navigationskalender in der Sidebox geändert wird. update timezones common de Zeitzonen aktualisieren updated calendar de Aktualisiert use end date calendar de Enddatum benutzen diff --git a/calendar/lang/egw_en.lang b/calendar/lang/egw_en.lang index 660f0f62df..c7029dba82 100644 --- a/calendar/lang/egw_en.lang +++ b/calendar/lang/egw_en.lang @@ -584,6 +584,7 @@ tue calendar en Tue two weeks calendar en Two weeks type of planner calendar en Type of planner unable to save calendar en Unable to save +update calendar view immediately when navigation calendar in sidebox is changed calendar en Update calendar view immediately when navigation calendar in sidebox is changed update timezones common en Update time zones updated calendar en Updated use end date calendar en Use end date