Fix calendar list view custom date filter always switched to another filter & hid the dates

This commit is contained in:
nathangray 2016-06-01 15:50:09 -06:00
parent 87fb94a496
commit 033ba0159f
2 changed files with 8 additions and 7 deletions

View File

@ -244,20 +244,21 @@ class calendar_uilist extends calendar_ui
{ {
unset($readonlys); // not used; unset($readonlys); // not used;
//echo "uilist::get_rows() params="; _debug_array($params); //echo "uilist::get_rows() params="; _debug_array($params);
$this->filter = $params['filter'];
if ($params['filter'] == 'custom') if ($params['filter'] == 'custom')
{ {
if (!$params['startdate'] && !$params['enddate']) if (!$params['startdate'] && !$params['enddate'])
{ {
$params['filter'] = 'all'; $this->filter = 'all';
} }
elseif (!$params['startdate']) elseif (!$params['startdate'])
{ {
$params['filter'] = 'before'; $this->filter = 'before';
$this->manage_states(array('date' => $this->bo->date2string($params['enddate']))); $this->manage_states(array('date' => $this->bo->date2string($params['enddate'])));
} }
elseif (!$params['enddate']) elseif (!$params['enddate'])
{ {
$params['filter'] = 'after'; $this->filter = 'after';
$this->manage_states(array('date' => $this->bo->date2string($params['startdate']))); $this->manage_states(array('date' => $this->bo->date2string($params['startdate'])));
} }
} }
@ -293,7 +294,7 @@ class calendar_uilist extends calendar_ui
} }
$search_params = array( $search_params = array(
'cat_id' => $params['cat_id'] ? $params['cat_id'] : 0, 'cat_id' => $params['cat_id'] ? $params['cat_id'] : 0,
'filter' => isset($params['filter']) ? $params['filter'] : $this->filter, 'filter' => $this->filter,
'query' => $params['search'], 'query' => $params['search'],
'offset' => (int) $params['start'], 'offset' => (int) $params['start'],
'num_rows'=> $params['num_rows'], 'num_rows'=> $params['num_rows'],
@ -303,7 +304,7 @@ class calendar_uilist extends calendar_ui
// Non-blocking events above blocking // Non-blocking events above blocking
$search_params['order'] .= ', cal_non_blocking DESC'; $search_params['order'] .= ', cal_non_blocking DESC';
switch($params['filter']) switch($this->filter)
{ {
case 'all': case 'all':
break; break;

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" onchange="app.calendar.update_state({date: widget.getValue()}); return false;"/> <date id="startdate" onchange="widget.getParent().getWidgetById('enddate').set_min(widget.getValue()); app.calendar.update_state({date: widget.getValue()}); return false;"/>
<description value="End"/> <description value="End"/>
<date id="enddate" onchange="app.calendar.update_state({end_date: widget.getValue()}); return false;"/> <date id="enddate" onchange="widget.getParent().getWidgetById('startdate').set_max(widget.getValue()); 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">