Make sure listview start & end dates stay valid

This commit is contained in:
Nathan Gray 2015-11-24 17:21:37 +00:00
parent e9e6d8f5ab
commit c91b4af435
2 changed files with 25 additions and 3 deletions

View File

@ -1592,6 +1592,10 @@ app.classes.calendar = AppJS.extend(
delete state.date; delete state.date;
delete state.first; delete state.first;
delete state.last; delete state.last;
delete state.startdate;
delete state.enddate;
delete state.start_date;
delete state.end_date;
return state; return state;
}, },
@ -1895,11 +1899,19 @@ app.classes.calendar = AppJS.extend(
if(state.state.view === 'listview') if(state.state.view === 'listview')
{ {
state.state.startdate = state.state.date; state.state.startdate = state.state.date;
if(state.state.startdate.toJSON)
{
state.state.startdate = state.state.startdate.toJSON();
}
if(state.state.end_date) if(state.state.end_date)
{ {
state.state.enddate = state.state.end_date; state.state.enddate = state.state.end_date;
} }
if(state.state.enddate && state.state.enddate.toJSON)
{
state.state.enddate = state.state.enddate.toJSON();
}
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;
@ -1908,6 +1920,16 @@ app.classes.calendar = AppJS.extend(
delete state.state.filter; delete state.state.filter;
var nm = view.etemplates[0].widgetContainer.getWidgetById('nm'); var nm = view.etemplates[0].widgetContainer.getWidgetById('nm');
// 'Custom' filter needs an end date
if(nm.activeFilters.filter === 'custom' && !state.state.end_date)
{
state.state.enddate = state.state.last;
}
if(state.state.enddate && state.state.startdate && state.state.startdate > state.state.enddate)
{
state.state.enddate = state.state.startdate;
}
nm.applyFilters(state.state); nm.applyFilters(state.state);
if(!state.state.end_date && nm.activeFilters.enddate) if(!state.state.end_date && nm.activeFilters.enddate)
{ {

View File

@ -5,9 +5,9 @@
<template id="calendar.list.dates" template="" lang="" group="0" version="1.3.001"> <template id="calendar.list.dates" template="" lang="" group="0" version="1.3.001">
<hbox> <hbox>
<description value="Start"/> <description value="Start"/>
<date id="startdate"/> <date id="startdate" onchange="app.calendar.update_state({date: widget.getValue()}); return false;"/>
<description value="End"/> <description value="End"/>
<date id="enddate"/> <date id="enddate" onchange="app.calendar.update_state({end_date: widget.getValue()}); return false;"/>
</hbox> </hbox>
</template> </template>
<template id="calendar.list.rows" template="" lang="" group="0" version="1.9.004"> <template id="calendar.list.rows" template="" lang="" group="0" version="1.9.004">