Add some exceptions to Month header button

- Planner & list view stay, they just update their date to that month
This commit is contained in:
Nathan Gray 2015-12-16 19:54:22 +00:00
parent 66321e8527
commit 6236c7e1ca
3 changed files with 16 additions and 14 deletions

View File

@ -91,9 +91,9 @@ class calendar_ui
*/ */
var $cat_id; var $cat_id;
/** /**
* @var int $filter session-state: selected filter, at the moment all or hideprivate * @var int $status_filter session-state: selected filter, at the moment all or hideprivate
*/ */
var $filter; var $status_filter;
/** /**
* @var int/array $owner session-state: selected owner(s) of shown calendar(s) * @var int/array $owner session-state: selected owner(s) of shown calendar(s)
*/ */
@ -127,7 +127,7 @@ class calendar_ui
/** /**
* @var array $states_to_save all states that will be saved to the user prefs * @var array $states_to_save all states that will be saved to the user prefs
*/ */
var $states_to_save = array('owner','filter','cat_id','view','sortby','planner_days','weekend'); var $states_to_save = array('owner','status_filter','filter','cat_id','view','sortby','planner_days','weekend');
/** /**
* Constructor * Constructor
@ -248,7 +248,7 @@ class calendar_ui
* - cat_id: the selected category * - cat_id: the selected category
* - owner: the owner of the displayed calendar * - owner: the owner of the displayed calendar
* - save_owner: the overriden owner of the planner * - save_owner: the overriden owner of the planner
* - filter: the used filter: all or hideprivate * - status_filter: the used filter: all or hideprivate
* - sortby: category or user of planner * - sortby: category or user of planner
* - view: the actual view, where dialogs should return to or which they refresh * - view: the actual view, where dialogs should return to or which they refresh
* @param array $set_states array to manualy set / change one of the states, default NULL = use $_REQUEST * @param array $set_states array to manualy set / change one of the states, default NULL = use $_REQUEST
@ -289,7 +289,7 @@ class calendar_ui
foreach(array( foreach(array(
'date' => $this->bo->date2string($this->bo->now_su), 'date' => $this->bo->date2string($this->bo->now_su),
'cat_id' => 0, 'cat_id' => 0,
'filter' => 'default', 'status_filter' => 'default',
'owner' => $this->user, 'owner' => $this->user,
'save_owner' => 0, 'save_owner' => 0,
'sortby' => 'category', 'sortby' => 'category',
@ -710,7 +710,7 @@ class calendar_ui
'value' => $data['value'] 'value' => $data['value']
); );
} }
$sel_options['filter'] = array( $sel_options['status_filter'] = array(
array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')), array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')),
array('value' => 'accepted', 'label' => lang('Accepted'), 'title' => lang('Show only accepted events')), array('value' => 'accepted', 'label' => lang('Accepted'), 'title' => lang('Show only accepted events')),
array('value' => 'unknown', 'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')), array('value' => 'unknown', 'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')),
@ -726,7 +726,7 @@ class calendar_ui
); );
if($GLOBALS['egw_info']['server']['calendar_delete_history']) if($GLOBALS['egw_info']['server']['calendar_delete_history'])
{ {
$sel_options['filter'][] = array('value' => 'deleted', 'label' => lang('Deleted'), 'title' => lang('Show events that have been deleted')); $sel_options['status_filter'][] = array('value' => 'deleted', 'label' => lang('Deleted'), 'title' => lang('Show events that have been deleted'));
} }
// Merge print // Merge print

View File

@ -63,7 +63,7 @@ app.classes.calendar = AppJS.extend(
owner: egw.user('account_id') owner: egw.user('account_id')
}, },
states_to_save: ['owner','filter','cat_id','view','sortby','planner_days','weekend'], states_to_save: ['owner','status_filter','filter','cat_id','view','sortby','planner_days','weekend'],
// If you are in one of these views and select a date in the sidebox, the view // 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 // will change as needed to show the date. Other views will only change the
@ -1982,9 +1982,6 @@ app.classes.calendar = AppJS.extend(
state.state.col_filter = {participant: state.state.owner}; state.state.col_filter = {participant: state.state.owner};
state.state.search = state.state.keywords; state.state.search = state.state.keywords;
// Pass status filter in as status filter, avoids conflicts with nm filter
state.state.status_filter = state.state.filter;
delete state.state.filter;
var nm = view.etemplates[0].widgetContainer.getWidgetById('nm'); var nm = view.etemplates[0].widgetContainer.getWidgetById('nm');
@ -2433,7 +2430,7 @@ app.classes.calendar = AppJS.extend(
// Participant must be an array or it won't work // Participant must be an array or it won't work
col_filter: {participant: (typeof state.owner == 'string' || typeof state.owner == 'number' ? [state.owner] : state.owner)}, col_filter: {participant: (typeof state.owner == 'string' || typeof state.owner == 'number' ? [state.owner] : state.owner)},
filter:'custom', // Must be custom to get start & end dates filter:'custom', // Must be custom to get start & end dates
status_filter: state.filter, status_filter: state.status_filter,
cat_id: cat_id, cat_id: cat_id,
csv_export: false csv_export: false
}); });
@ -2870,8 +2867,13 @@ app.classes.calendar = AppJS.extend(
if(month_button) if(month_button)
{ {
var temp_date = new Date(date_widget.get_value()); var temp_date = new Date(date_widget.get_value());
temp_date.setUTCDate(1);
temp_date.setUTCMinutes(temp_date.getUTCMinutes() + temp_date.getTimezoneOffset()); temp_date.setUTCMinutes(temp_date.getUTCMinutes() + temp_date.getTimezoneOffset());
month_button.set_label(egw.lang(date('F',temp_date))); month_button.set_label(egw.lang(date('F',temp_date)));
// Store current _displayed_ date in date button for clicking
temp_date.setUTCMinutes(temp_date.getUTCMinutes() - temp_date.getTimezoneOffset());
month_button.btn.attr('data-date', temp_date.toJSON());
} }
// Dynamic resize to fill sidebox // Dynamic resize to fill sidebox

View File

@ -43,7 +43,7 @@ Egroupware
<buttononly id="header_today" label="Today" onclick="var tempDate = new Date(); <buttononly id="header_today" label="Today" onclick="var tempDate = new Date();
var today = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(),0,-tempDate.getTimezoneOffset(),0); var today = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(),0,-tempDate.getTimezoneOffset(),0);
app.calendar.update_state({date: today.toJSON()});return false;"/> app.calendar.update_state({date: today.toJSON()});return false;"/>
<buttononly id="header_month" label="Month" onclick="app.calendar.update_state({date: widget.btn.attr('data-date'), view:'month'});" /> <buttononly id="header_month" label="Month" onclick="var change = {date: widget.btn.attr('data-date')}; if(app.calendar.state.view == 'planner') { change.planner_days = 0;change.last=false;} else if ( app.calendar.state.view == 'listview') {change.filter='month';} else {change.view = 'month';}app.calendar.update_state(change);" />
</hbox> </hbox>
<date id="date" class="et2_fullWidth" inline="true" onchange="var view_change = app.calendar.sidebox_changes_views.indexOf(app.calendar.state.view); <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()}; var update = {date:widget.getValue()};
@ -56,7 +56,7 @@ if(view_change >= 0) {update.view = app.calendar.sidebox_changes_views[view_chan
<!-- <!--
<taglist id="owner" class="et2_fullWidth" onchange="app.calendar.update_state({owner: widget.getValue()});" autocomplete_params=''/> <taglist id="owner" class="et2_fullWidth" onchange="app.calendar.update_state({owner: widget.getValue()});" autocomplete_params=''/>
--> -->
<select id="filter" no_lang="true" class="et2_fullWidth" onchange="app.calendar.update_state({filter: widget.getValue()});"/> <select id="status_filter" no_lang="true" class="et2_fullWidth" onchange="app.calendar.update_state({status_filter: widget.getValue()});"/>
<select id="merge" empty_label="Insert in document" onchange="app.calendar.sidebox_merge" class="et2_fullWidth"/> <select id="merge" empty_label="Insert in document" onchange="app.calendar.sidebox_merge" class="et2_fullWidth"/>
</vbox> </vbox>
<iframe id="iframe" width="100%" height="100%"/> <iframe id="iframe" width="100%" height="100%"/>