From ffad978c81ffbd097c1c126097861f5b8a762952 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 22 Dec 2015 23:34:53 +0000 Subject: [PATCH] Move consolidation limit from config to preference, and split it into two for day & week views --- calendar/inc/class.calendar_bo.inc.php | 7 ------ calendar/inc/class.calendar_hooks.inc.php | 20 +++++++++++++++ calendar/inc/class.calendar_uiviews.inc.php | 4 +-- calendar/js/app.js | 28 +++++++++++++++------ calendar/templates/default/config.tpl | 4 --- calendar/templates/pixelegg/app.css | 18 ++++++------- calendar/templates/pixelegg/app.less | 2 +- 7 files changed, 53 insertions(+), 30 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 111d8d80f9..31c3f55197 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -207,12 +207,6 @@ class calendar_bo */ public $require_acl_invite = null; - /** - * if the number of selected users for a view exeeds this number a view is consolidated (5 is set as default) - * @var int - */ - public $calview_no_consolidate = 5; - /** * Warnings to show in regular UI * @@ -264,7 +258,6 @@ class calendar_bo //echo "registered resources="; _debug_array($this->resources); $this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi - $this->calview_no_consolidate = ($GLOBALS['egw_info']['server']['calview_no_consolidate']?$GLOBALS['egw_info']['server']['calview_no_consolidate']:5); $this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite']; $this->categories = new categories($this->user,'calendar'); diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index 275bcaa721..924ab2931c 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -171,6 +171,10 @@ class calendar_hooks $muliple_weeks[$i] = lang('%1 weeks',$i); } + for ($i = 2; $i <= 9; $i++) + { + $consolidated[$i] = $i; + } $intervals = array( 5 => '5', 10 => '10', @@ -283,6 +287,22 @@ class calendar_hooks 'admin' => False, 'default'=> 30, ), + 'day_consolidate' => array( + 'type' => 'select', + 'label' => 'Minimum number of users for showing day view as consolidated.', + 'name' => 'day_consolidate', + 'values'=> $consolidated, + 'help' => 'How many seperate calendars to show before merging them together', + 'default'=> 5 + ), + 'week_consolidate' => array( + 'type' => 'select', + 'label' => 'Minimum number of users for showing week view as consolidated.', + 'name' => 'week_consolidate', + 'values'=> $consolidated, + 'help' => 'How many seperate calendars to show before merging them together', + 'default'=> 3 + ), 'display_holidays_event' => array( 'type' => 'select', 'label' => 'Display holidays or birthdays as events in dayview', diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index af0eedd09d..804a63cc2d 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -663,7 +663,7 @@ class calendar_uiviews extends calendar_ui // Always do 7 days for a week so scrolling works properly $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1); - if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate) // for more then X users, show all in one row + if (count($users) == 1 || count($users) > $this->cal_prefs['week_consolidate']) // for more then X users, show all in one row { $content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) + array('owner' => $users); @@ -719,7 +719,7 @@ class calendar_uiviews extends calendar_ui if (!is_array($users)) $users = array($users); // for more then X users, show all in one row - if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate) + if (count($users) == 1 || count($users) > $this->cal_prefs['day_consolidate']) { $dayEvents =& $this->bo->search($this->search_params); $owner = 0; diff --git a/calendar/js/app.js b/calendar/js/app.js index e35feafeb2..5651e9c97d 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -272,7 +272,8 @@ app.classes.calendar = AppJS.extend( { var multiple_owner = typeof this.state.owner != 'string' && this.state.owner.length > 1 && - this.state.owner.length < parseInt(this.egw.config('calview_no_consolidate','phpgwapi') || 5); + (this.state.view == 'day' && this.state.owner.length <= parseInt(this.egw.preference('day_consolidate','calendar')) || + this.state.view == 'week' && this.state.owner.length <= parseInt(this.egw.preference('week_consolidate','calendar'))); // Make sure it's a string if(_id) _id = ''+_id; @@ -453,8 +454,10 @@ app.classes.calendar = AppJS.extend( } // Enable or disable - if((state.view == 'day' || state.view == 'week') && - state.owner.length > 1 && state.owner.length < egw.config('calview_no_consolidate','phpgwapi')) + if(state.owner.length > 1 && ( + state.view == 'day' && state.owner.length <= parseInt(egw.preference('day_consolidate','calendar')) || + state.view == 'week' && state.owner.length <= parseInt(egw.preference('week_consolidate','calendar')) + )) { sortable.sortable('enable') .sortable("refresh") @@ -1816,10 +1819,21 @@ app.classes.calendar = AppJS.extend( // Show the correct number of grids - var grid_count = state.state.view === 'weekN' ? parseInt(this.egw.preference('multiple_weeks','calendar')) || 3 : - state.state.view === 'month' ? 0 : // Calculate based on weeks in the month - state.state.owner.length > (this.egw.config('calview_no_consolidate','phpgwapi') || 5) ? 1 : state.state.owner.length; - + var grid_count = 0; + switch(state.state.view) + { + case 'day': + grid_count = state.state.owner.length > parseInt(this.egw.preference('day_consolidate','calendar')) ? 1 : state.state.owner.length; + break; + case 'week': + grid_count = state.state.owner.length > parseInt(this.egw.preference('week_consolidate','calendar')) ? 1 : state.state.owner.length; + break; + case 'weekN': + grid_count = parseInt(this.egw.preference('multiple_weeks','calendar')) || 3; + break; + // Month is calculated individually for the month + } + var grid = view.etemplates[0].widgetContainer.getWidgetById('view'); /* diff --git a/calendar/templates/default/config.tpl b/calendar/templates/default/config.tpl index 4187e0779b..65e5d1a713 100644 --- a/calendar/templates/default/config.tpl +++ b/calendar/templates/default/config.tpl @@ -51,10 +51,6 @@ - -  {lang_While_selecting_up_to_X_users_day-_and_weekview_is_not_consolidated_(5_is_used_when_not_set)}: - -  {lang_Allow_users_to_prevent_change_notifications_('Do_not_notify')}: diff --git a/calendar/templates/pixelegg/app.css b/calendar/templates/pixelegg/app.css index 38b02ff5bb..a391572489 100755 --- a/calendar/templates/pixelegg/app.css +++ b/calendar/templates/pixelegg/app.css @@ -394,7 +394,7 @@ div.calendar { height: 16px; background-size: 12px auto !important; margin-left: 32px; - padding: 0px; + padding-top: 0px; } #calendar-edit #calendar-edit_id { float: right; @@ -1202,10 +1202,10 @@ button#series { -o-transition-timing-function: linear; transition-timing-function: linear; background-color: #b4b4b4; - padding-left: 30px !important; - background-position: 6px center !important; - background-repeat: no-repeat !important; - background-size: 20px auto !important; + padding-left: 30px; + background-position: 6px center; + background-repeat: no-repeat; + background-size: 20px auto; /*.Button_size_h32_auto;*/ height: 24px; } @@ -1259,10 +1259,10 @@ button#exception { -o-transition-timing-function: linear; transition-timing-function: linear; background-color: #b4b4b4; - padding-left: 30px !important; - background-position: 6px center !important; - background-repeat: no-repeat !important; - background-size: 20px auto !important; + padding-left: 30px; + background-position: 6px center; + background-repeat: no-repeat; + background-size: 20px auto; /*.Button_size_h32_auto;*/ height: 24px; } diff --git a/calendar/templates/pixelegg/app.less b/calendar/templates/pixelegg/app.less index 8ac50463fa..be4a0f7cd2 100755 --- a/calendar/templates/pixelegg/app.less +++ b/calendar/templates/pixelegg/app.less @@ -444,7 +444,7 @@ div.calendar { position: relative; } height: 16px; background-size: 12px auto !important; margin-left: 32px; - padding: 0px; + padding-top: 0px; } // ID