Move consolidation limit from config to preference, and split it into two for day & week views

This commit is contained in:
Nathan Gray 2015-12-22 23:34:53 +00:00
parent a13f9cd3c9
commit ffad978c81
7 changed files with 53 additions and 30 deletions

View File

@ -207,12 +207,6 @@ class calendar_bo
*/ */
public $require_acl_invite = null; 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 * Warnings to show in regular UI
* *
@ -264,7 +258,6 @@ class calendar_bo
//echo "registered resources="; _debug_array($this->resources); //echo "registered resources="; _debug_array($this->resources);
$this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi $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->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
$this->categories = new categories($this->user,'calendar'); $this->categories = new categories($this->user,'calendar');

View File

@ -171,6 +171,10 @@ class calendar_hooks
$muliple_weeks[$i] = lang('%1 weeks',$i); $muliple_weeks[$i] = lang('%1 weeks',$i);
} }
for ($i = 2; $i <= 9; $i++)
{
$consolidated[$i] = $i;
}
$intervals = array( $intervals = array(
5 => '5', 5 => '5',
10 => '10', 10 => '10',
@ -283,6 +287,22 @@ class calendar_hooks
'admin' => False, 'admin' => False,
'default'=> 30, '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( 'display_holidays_event' => array(
'type' => 'select', 'type' => 'select',
'label' => 'Display holidays or birthdays as events in dayview', 'label' => 'Display holidays or birthdays as events in dayview',

View File

@ -663,7 +663,7 @@ class calendar_uiviews extends calendar_ui
// Always do 7 days for a week so scrolling works properly // 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); $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)) + $content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) +
array('owner' => $users); array('owner' => $users);
@ -719,7 +719,7 @@ class calendar_uiviews extends calendar_ui
if (!is_array($users)) $users = array($users); if (!is_array($users)) $users = array($users);
// for more then X users, show all in one row // 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); $dayEvents =& $this->bo->search($this->search_params);
$owner = 0; $owner = 0;

View File

@ -272,7 +272,8 @@ app.classes.calendar = AppJS.extend(
{ {
var multiple_owner = typeof this.state.owner != 'string' && var multiple_owner = typeof this.state.owner != 'string' &&
this.state.owner.length > 1 && 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 // Make sure it's a string
if(_id) _id = ''+_id; if(_id) _id = ''+_id;
@ -453,8 +454,10 @@ app.classes.calendar = AppJS.extend(
} }
// Enable or disable // Enable or disable
if((state.view == 'day' || state.view == 'week') && if(state.owner.length > 1 && (
state.owner.length > 1 && state.owner.length < egw.config('calview_no_consolidate','phpgwapi')) 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.sortable('enable')
.sortable("refresh") .sortable("refresh")
@ -1816,10 +1819,21 @@ app.classes.calendar = AppJS.extend(
// Show the correct number of grids // Show the correct number of grids
var grid_count = state.state.view === 'weekN' ? parseInt(this.egw.preference('multiple_weeks','calendar')) || 3 : var grid_count = 0;
state.state.view === 'month' ? 0 : // Calculate based on weeks in the month switch(state.state.view)
state.state.owner.length > (this.egw.config('calview_no_consolidate','phpgwapi') || 5) ? 1 : state.state.owner.length; {
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'); var grid = view.etemplates[0].widgetContainer.getWidgetById('view');
/* /*

View File

@ -51,10 +51,6 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr class="row_off">
<td>&nbsp;{lang_While_selecting_up_to_X_users_day-_and_weekview_is_not_consolidated_(5_is_used_when_not_set)}:</td>
<td><input name="newsettings[calview_no_consolidate]" value="{value_calview_no_consolidate}" size="10"></td>
</tr>
<tr class="row_on"> <tr class="row_on">
<td>&nbsp;{lang_Allow_users_to_prevent_change_notifications_('Do_not_notify')}:</td> <td>&nbsp;{lang_Allow_users_to_prevent_change_notifications_('Do_not_notify')}:</td>
<td> <td>

View File

@ -394,7 +394,7 @@ div.calendar {
height: 16px; height: 16px;
background-size: 12px auto !important; background-size: 12px auto !important;
margin-left: 32px; margin-left: 32px;
padding: 0px; padding-top: 0px;
} }
#calendar-edit #calendar-edit_id { #calendar-edit #calendar-edit_id {
float: right; float: right;
@ -1202,10 +1202,10 @@ button#series {
-o-transition-timing-function: linear; -o-transition-timing-function: linear;
transition-timing-function: linear; transition-timing-function: linear;
background-color: #b4b4b4; background-color: #b4b4b4;
padding-left: 30px !important; padding-left: 30px;
background-position: 6px center !important; background-position: 6px center;
background-repeat: no-repeat !important; background-repeat: no-repeat;
background-size: 20px auto !important; background-size: 20px auto;
/*.Button_size_h32_auto;*/ /*.Button_size_h32_auto;*/
height: 24px; height: 24px;
} }
@ -1259,10 +1259,10 @@ button#exception {
-o-transition-timing-function: linear; -o-transition-timing-function: linear;
transition-timing-function: linear; transition-timing-function: linear;
background-color: #b4b4b4; background-color: #b4b4b4;
padding-left: 30px !important; padding-left: 30px;
background-position: 6px center !important; background-position: 6px center;
background-repeat: no-repeat !important; background-repeat: no-repeat;
background-size: 20px auto !important; background-size: 20px auto;
/*.Button_size_h32_auto;*/ /*.Button_size_h32_auto;*/
height: 24px; height: 24px;
} }

View File

@ -444,7 +444,7 @@ div.calendar { position: relative; }
height: 16px; height: 16px;
background-size: 12px auto !important; background-size: 12px auto !important;
margin-left: 32px; margin-left: 32px;
padding: 0px; padding-top: 0px;
} }
// ID // ID