mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Completely remove any planner_days and switch to using other views for calculation
This commit is contained in:
parent
32e00d420b
commit
edf60ac0f8
@ -111,6 +111,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
$this->actions =& $etemplate->getElementAttribute('planner', 'actions');
|
||||
// Don't notify the calendar app of date changes
|
||||
$etemplate->setElementAttribute('planner','onchange',false);
|
||||
$ui->planner_view = $this->favorite['state']['planner_view'];
|
||||
$ui->planner(array(), $etemplate);
|
||||
return;
|
||||
case 'year':
|
||||
|
@ -127,7 +127,7 @@ class calendar_ui
|
||||
/**
|
||||
* @var array $states_to_save all states that will be saved to the user prefs
|
||||
*/
|
||||
var $states_to_save = array('owner','status_filter','filter','cat_id','view','sortby','planner_days','weekend');
|
||||
var $states_to_save = array('owner','status_filter','filter','cat_id','view','sortby','planner_view','weekend');
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -293,7 +293,7 @@ class calendar_ui
|
||||
'owner' => $this->user,
|
||||
'save_owner' => 0,
|
||||
'sortby' => 'category',
|
||||
'planner_days'=> 0, // full month
|
||||
'planner_view'=> 'month', // full month
|
||||
'view' => ($this->bo->cal_prefs['defaultcalendar']?$this->bo->cal_prefs['defaultcalendar']:'day'), // use pref, if exists else use the dayview
|
||||
'listview_days'=> '', // no range
|
||||
'test' => 'false',
|
||||
|
@ -468,43 +468,35 @@ class calendar_uiviews extends calendar_ui
|
||||
$this->last = $this->first;
|
||||
$this->last['year']++;
|
||||
$this->last = $this->bo->date2ts($this->last)-1;
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('yearly planner').' '.
|
||||
lang(egw_time::to($this->first,'F')).' '.egw_time::to($this->first,'Y').' - '.
|
||||
lang(egw_time::to($this->last,'F')).' '.egw_time::to($this->last,'Y');
|
||||
}
|
||||
elseif (!$this->planner_days) // planner monthview
|
||||
elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview
|
||||
{
|
||||
if ($this->day < 15) // show one complete month
|
||||
{
|
||||
$this->_week_align_month($this->first,$this->last);
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
|
||||
}
|
||||
else // show 2 half month
|
||||
{
|
||||
$this->_week_align_month($this->first,$this->last,15);
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(adodb_date('F',$this->first)).' / '.lang(adodb_date('F',$this->last)).' '.$this->year;
|
||||
}
|
||||
}
|
||||
elseif ($this->planner_days >= 5) // weeekview
|
||||
elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview
|
||||
{
|
||||
$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
|
||||
$this->last = $this->bo->date2array($this->first);
|
||||
$this->last['day'] += (int) $this->planner_days - 1;
|
||||
$this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1;
|
||||
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
||||
unset($this->last['raw']);
|
||||
$this->last = $this->bo->date2ts($this->last);
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first,$this->last);
|
||||
}
|
||||
else // dayview
|
||||
{
|
||||
$this->first = $this->bo->date2ts($this->date);
|
||||
$this->last = $this->bo->date2array($this->first);
|
||||
$this->last['day'] += (int) $this->planner_days - 1;
|
||||
$this->last['day'] += 0;
|
||||
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
||||
unset($this->last['raw']);
|
||||
$this->last = $this->bo->date2ts($this->last);
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.($this->planner_days == 1 ? lang(date('l',$this->first)).', ' : '').
|
||||
$this->bo->long_date($this->first,$this->planner_days > 1 ? $this->last : 0);
|
||||
}
|
||||
|
||||
$merge = $this->merge();
|
||||
|
@ -63,7 +63,7 @@ app.classes.calendar = AppJS.extend(
|
||||
owner: egw.user('account_id')
|
||||
},
|
||||
|
||||
states_to_save: ['owner','status_filter','filter','cat_id','view','sortby','planner_days','weekend'],
|
||||
states_to_save: ['owner','status_filter','filter','cat_id','view','sortby','planner_view','weekend'],
|
||||
|
||||
// If you are in one of these views and select a date in the sidebox, the view
|
||||
// will change as needed to show the date. Other views will only change the
|
||||
@ -404,7 +404,11 @@ app.classes.calendar = AppJS.extend(
|
||||
// Most can just provide state change data
|
||||
if(action.data && action.data.state)
|
||||
{
|
||||
this.update_state(action.data.state);
|
||||
var state = jQuery.extend({},action.data.state);
|
||||
if(state.view == 'planner' && app.calendar.state.view != 'planner') {
|
||||
state.planner_view = app.calendar.state.view;
|
||||
}
|
||||
this.update_state(state);
|
||||
}
|
||||
// Special handling
|
||||
switch(action.id)
|
||||
@ -418,7 +422,6 @@ app.classes.calendar = AppJS.extend(
|
||||
var tempDate = new Date();
|
||||
var today = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(),0,-tempDate.getTimezoneOffset(),0);
|
||||
var change = {date: today.toJSON()};
|
||||
if(app.calendar.state.view == 'planner') { change.planner_days = Math.ceil((new Date(app.calendar.state.last) - new Date(app.calendar.state.first)) / (24*3600000));}
|
||||
app.calendar.update_state(change);
|
||||
break;
|
||||
case 'next':
|
||||
@ -1804,13 +1807,6 @@ app.classes.calendar = AppJS.extend(
|
||||
state.keywords = listview.activeFilters.search;
|
||||
}
|
||||
}
|
||||
else if (state.view == 'planner')
|
||||
{
|
||||
// Normally we don't use the planner days, but we'll set it so
|
||||
// favorites can come back to the current view
|
||||
var timeDiff = Math.abs(new Date(state.last).getTime() - new Date(state.first).getTime());
|
||||
state.planner_days = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||
}
|
||||
|
||||
// Don't store date or first and last
|
||||
delete state.date;
|
||||
@ -1883,7 +1879,7 @@ app.classes.calendar = AppJS.extend(
|
||||
}
|
||||
|
||||
// Check for valid cache
|
||||
var cachable_changes = ['date','weekend','view','days','planner_days','sortby'];
|
||||
var cachable_changes = ['date','weekend','view','days','planner_view','sortby'];
|
||||
var keys = jQuery.unique(Object.keys(this.state).concat(Object.keys(state.state)));
|
||||
for(var i = 0; i < keys.length; i++)
|
||||
{
|
||||
@ -3175,7 +3171,7 @@ app.classes.calendar = AppJS.extend(
|
||||
else if (view == 'planner')
|
||||
{
|
||||
// Clicked a week, show just a week
|
||||
app.calendar.update_state({date: date, planner_days: 7});
|
||||
app.calendar.update_state({date: date, planner_view: 'week'});
|
||||
}
|
||||
else if (view == 'listview')
|
||||
{
|
||||
@ -3581,7 +3577,7 @@ jQuery.extend(app.classes.calendar,{
|
||||
|
||||
var d = app.calendar.date.start_of_week(app.calendar.View.start_date.call(this,state));
|
||||
// Always 7 days, we just turn weekends on or off
|
||||
d.setUTCHours(24*7-1);
|
||||
d.setUTCHours(24*7*(parseInt(this.egw.preference('multiple_weeks','calendar')) || 3)-1);
|
||||
return d;
|
||||
}
|
||||
}),
|
||||
@ -3629,19 +3625,9 @@ jQuery.extend(app.classes.calendar,{
|
||||
group_by: function(state) {
|
||||
return state.sortby ? state.sortby : 0;
|
||||
},
|
||||
// Note: Planner has no inherent timespan as day or week does, so
|
||||
// it's a little more messy to determine what timespan to show. For
|
||||
// best results, we either leave the dates as set (planner_days = 0)
|
||||
// to inherit from the previous view, or set either planner_days or
|
||||
// start & end date.
|
||||
// Note: Planner uses the additional value of planner_view to determine
|
||||
// the start & end dates using other view's functions
|
||||
start_date: function(state) {
|
||||
// If there is no planner_days and a start date, just keep it
|
||||
if(!state.planner_days && state.first && (
|
||||
!state.date || state.first < state.date && state.last > state.date
|
||||
))
|
||||
{
|
||||
return state.first;
|
||||
}
|
||||
// Start here, in case we can't find anything better
|
||||
var d = app.calendar.View.start_date.call(this, state);
|
||||
|
||||
@ -3649,21 +3635,11 @@ jQuery.extend(app.classes.calendar,{
|
||||
{
|
||||
d.setUTCDate(1);
|
||||
}
|
||||
else if (state.planner_days && [28,30,31].indexOf(state.planner_days||0) >= 0)
|
||||
else if (state.planner_view && app.classes.calendar.views[state.planner_view])
|
||||
{
|
||||
d = app.classes.calendar.views.month.start_date.call(this,state);
|
||||
d = app.classes.calendar.views[state.planner_view].start_date.call(this,state);
|
||||
}
|
||||
else if (state.planner_days % 7 == 0)
|
||||
{
|
||||
// Week
|
||||
d = app.classes.calendar.views.week.start_date.call(this,state);
|
||||
}
|
||||
else if (state.days)
|
||||
{
|
||||
// Don't jump to start of week, coming from day or day4
|
||||
return d;
|
||||
}
|
||||
else if (!state.planner_days)
|
||||
else
|
||||
{
|
||||
d = app.calendar.date.start_of_week(d);
|
||||
d.setUTCHours(0);
|
||||
@ -3675,54 +3651,16 @@ jQuery.extend(app.classes.calendar,{
|
||||
return d;
|
||||
},
|
||||
end_date: function(state) {
|
||||
// If no planner days and an end date, just keep it
|
||||
if(!state.planner_days && state.last && state.last > state.first)
|
||||
{
|
||||
// Handle listview before / after a little more nicely
|
||||
if(app.calendar.state.view == 'listview' && (
|
||||
state.filter == 'before' || state.filter == 'after'
|
||||
))
|
||||
{
|
||||
var d = app.calendar.View.end_date.call(this, state);
|
||||
d.setUTCDate(d.getUTCDate() + 30);
|
||||
d = app.calendar.date.end_of_week(d);
|
||||
return d;
|
||||
}
|
||||
return state.last;
|
||||
}
|
||||
// Avoid end date before start date
|
||||
if(state.last && state.first && state.last <= state.first && !state.planner_days)
|
||||
{
|
||||
state.planner_days = 30;
|
||||
}
|
||||
|
||||
var d = app.calendar.View.end_date.call(this, state);
|
||||
if(state.planner_days)
|
||||
{
|
||||
state.planner_days = parseInt(state.planner_days);
|
||||
}
|
||||
if(state.sortby && state.sortby === 'month')
|
||||
{
|
||||
d.setUTCDate(0);
|
||||
d.setUTCFullYear(d.getUTCFullYear() + 1);
|
||||
}
|
||||
else if (state.planner_days)
|
||||
else if (state.planner_view && app.classes.calendar.views[state.planner_view])
|
||||
{
|
||||
if([28,30,31].indexOf(state.planner_days||0) >= 0)
|
||||
{
|
||||
// Month view
|
||||
d = app.classes.calendar.views.month.end_date.call(this,state);
|
||||
}
|
||||
else
|
||||
{
|
||||
d = new Date(state.first);
|
||||
d.setUTCDate(d.getUTCDate() + parseInt(state.planner_days)-1);
|
||||
if (state.planner_days % 7 == 0)
|
||||
{
|
||||
// Week
|
||||
d = app.calendar.date.end_of_week(d);
|
||||
}
|
||||
}
|
||||
delete state.planner_days;
|
||||
d = app.classes.calendar.views[state.planner_view].end_date.call(this,state);
|
||||
}
|
||||
else if (state.days)
|
||||
{
|
||||
@ -3730,13 +3668,7 @@ jQuery.extend(app.classes.calendar,{
|
||||
d.setUTCDate(d.getUTCDate() + parseInt(state.days)-1);
|
||||
delete state.days;
|
||||
}
|
||||
// Avoid killing the view by not showing more than 100 days
|
||||
else if (state.last && state.last > state.first && (new Date(state.last) - new Date(state.first)) < (100 * 24 * 3600 * 1000) )
|
||||
{
|
||||
d = new Date(state.last);
|
||||
d = app.calendar.date.end_of_week(d);
|
||||
}
|
||||
else if (!state.planner_days)
|
||||
else
|
||||
{
|
||||
d = app.calendar.date.end_of_week(d);
|
||||
}
|
||||
@ -3744,6 +3676,10 @@ jQuery.extend(app.classes.calendar,{
|
||||
},
|
||||
scroll: function(delta)
|
||||
{
|
||||
if(app.calendar.state.planner_view)
|
||||
{
|
||||
return app.classes.calendar.views[app.calendar.state.planner_view].scroll.call(this,delta);
|
||||
}
|
||||
var d = new Date(app.calendar.state.date);
|
||||
|
||||
// Yearly view, grouped by month - scroll 1 month
|
||||
@ -3760,10 +3696,10 @@ jQuery.extend(app.classes.calendar,{
|
||||
if(app.calendar.state.first && app.calendar.state.last)
|
||||
{
|
||||
var diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first);
|
||||
app.calendar.state.planner_days = Math.round(diff / (1000*3600*24));
|
||||
var days = Math.round(diff / (1000*3600*24));
|
||||
}
|
||||
d.setUTCDate(d.getUTCDate() + (app.calendar.state.planner_days*delta));
|
||||
if(app.calendar.state.planner_days > 8)
|
||||
d.setUTCDate(d.getUTCDate() + (days*delta));
|
||||
if(days > 8)
|
||||
{
|
||||
d = app.calendar.date.start_of_week(d);
|
||||
}
|
||||
|
@ -953,7 +953,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
|
||||
{
|
||||
title = ' ';
|
||||
}
|
||||
content += '<div class="calendar_plannerMonthScale et2_clickable et2_link" data-date="'+first.toJSON()+ '" data-planner_days="'+u.getUTCDate()+
|
||||
content += '<div class="calendar_plannerMonthScale et2_clickable et2_link" data-date="'+first.toJSON()+ '" data-planner_view="month' +
|
||||
'" style="left: '+left+'%; width: '+(day_width*days_in_month)+'%;">'+
|
||||
title+"</div>";
|
||||
}
|
||||
@ -972,7 +972,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
|
||||
_header_weeks: function(start, days)
|
||||
{
|
||||
|
||||
var content = '<div class="calendar_plannerScale" data-planner_days=7>';
|
||||
var content = '<div class="calendar_plannerScale" data-planner_view="week">';
|
||||
var state = ''
|
||||
|
||||
// we're not using UTC so date() formatting function works
|
||||
@ -1036,7 +1036,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
|
||||
_header_days: function(start, days)
|
||||
{
|
||||
var day_width = 100 / days;
|
||||
var content = '<div class="calendar_plannerScale'+(days > 3 ? 'Day' : '')+'" data-planner_days="1" >';
|
||||
var content = '<div class="calendar_plannerScale'+(days > 3 ? 'Day' : '')+'" data-planner_view="day" >';
|
||||
|
||||
// we're not using UTC so date() formatting function works
|
||||
var t = new Date(start.valueOf() + start.getTimezoneOffset() * 60 * 1000);
|
||||
@ -1100,7 +1100,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi
|
||||
}
|
||||
var cell_width = 100 / hours * decr;
|
||||
|
||||
var content = '<div class="calendar_plannerScale">';
|
||||
var content = '<div class="calendar_plannerScale" data-planner_view="day">';
|
||||
|
||||
// we're not using UTC so date() formatting function works
|
||||
var t = new Date(start.valueOf() + start.getTimezoneOffset() * 60 * 1000);
|
||||
|
@ -19,12 +19,11 @@ Egroupware
|
||||
var tempDate = new Date();
|
||||
var today = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(),0,-tempDate.getTimezoneOffset(),0);
|
||||
var change = {date: today.toJSON()};
|
||||
if(app.calendar.state.view == 'planner') { change.planner_days = Math.ceil((new Date(app.calendar.state.last) - new Date(app.calendar.state.first)) / (24*3600000));}
|
||||
app.calendar.update_state(change);return false;"/>
|
||||
<buttononly id="header_go" label="↵" icon="nope" class="ui-corner-all" onclick="var change = {date: widget.btn.attr('data-date')}; if(app.calendar.state.view == 'planner') { change.planner_days = 0;change.first=change.date;var d = new Date(change.date);d = new Date(d.getFullYear(),d.getUTCMonth() + 1, 0);change.last=d.toJSON();} else if ( app.calendar.state.view == 'listview') {change.filter='month';} else {change.view = 'month';}app.calendar.update_state(change);" />
|
||||
<buttononly id="header_go" label="↵" icon="nope" class="ui-corner-all" onclick="var change = {date: widget.btn.attr('data-date')}; if ( app.calendar.state.view == 'listview') {change.filter='month';} else {change.view = 'month';}app.calendar.update_state(change);" />
|
||||
<date id="date" class="et2_fullWidth" inline="true" onchange="var view_change = app.calendar.sidebox_changes_views.indexOf(app.calendar.state.view);
|
||||
var update = {date:widget.getValue()};
|
||||
if(view_change >= 0) {update.view = app.calendar.sidebox_changes_views[view_change ? view_change - 1 : view_change];} else if (app.calendar.state.view == 'listview') {update.filter = 'after';} else if (app.calendar.state.view =='planner') { update.planner_days = 1; } app.calendar.update_state(update);"/>
|
||||
if(view_change >= 0) {update.view = app.calendar.sidebox_changes_views[view_change ? view_change - 1 : view_change];} else if (app.calendar.state.view == 'listview') {update.filter = 'after';} else if (app.calendar.state.view =='planner') { update.planner_view = 'day'; } app.calendar.update_state(update);"/>
|
||||
<textbox type="hidden" id="first"/>
|
||||
<textbox type="hidden" id="last"/>
|
||||
<select-cat id="cat_id" empty_label="All categories" width="86%" onchange="app.calendar.update_state({cat_id: widget.getValue()});" expand_multiple_rows="4"/>
|
||||
|
Loading…
Reference in New Issue
Block a user