Skip to content

Commit 444070c

Browse files
caseysoftwareclaude
andcommitted
Make the filter checkboxes on the To Do Gantt chart work
On index.php?m=tasks&a=todo&tab=1 none of the checkboxes changed the chart: - The checkboxes had no value, so the browser posted "on". That was saved as the filter state and put in the chart URL, and gantt.php casts it with (int), which turns "on" into 0. A checked box therefore meant "off". - Every checkbox was duplicated in a hidden #ganttoptions block inside the same form. Hidden inputs are still submitted, so a box that had been checked could never be cleared. "Projects on Hold" only existed in the hidden copy. - The Gantt form used different field names (showArcProjs...) from the My Tasks tab (show_arc_proj...). todo.php processes show_form before the tab is drawn and only knows the My Tasks names, so each Gantt submit first reset every filter (including Empty Dates and In Progress, which this tab does not show) and computed the task list from the reset values. - The user picker form also posted show_form, so choosing another user cleared all filters. The Gantt form now uses the shared field names with value="1", shows all five filters once (including Projects on Hold), carries the two My Tasks filters it does not show as hidden fields, and passes 1/0 to the chart. The user picker no longer posts show_form. Fixes #352 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016CP89WVmGZ1VVCCZMS6ntN
1 parent 48352dc commit 444070c

2 files changed

Lines changed: 28 additions & 54 deletions

File tree

‎modules/tasks/todo_gantt_sub.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$canDelete = $perms->checkModuleItem($m, 'delete');
1111
?>
1212
<form name="form_buttons" method="post" action="index.php?<?php echo 'm=' . $m . '&a=' . $a . '&date=' . $date; ?>" accept-charset="utf-8">
13-
<input type="hidden" name="show_form" value="1" />
13+
<?php // No show_form here: changing the user must not reset the filters (todo.php). ?>
1414
<div class="mb-2">
1515
<?php
1616
if ($other_users) {

‎modules/tasks/viewgantt.php‎

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,15 @@
3939
$showhgrid = '';
4040

4141
if ($a == 'todo') {
42-
if (isset($_POST['show_form'])) {
43-
$AppUI->setState('TaskDayShowArc', w2PgetParam($_POST, 'showArcProjs', 0));
44-
$AppUI->setState('TaskDayShowLow', w2PgetParam($_POST, 'showLowTasks', 0));
45-
$AppUI->setState('TaskDayShowHold', w2PgetParam($_POST, 'showHoldProjs', 0));
46-
$AppUI->setState('TaskDayShowDyn', w2PgetParam($_POST, 'showDynTasks', 0));
47-
$AppUI->setState('TaskDayShowPin', w2PgetParam($_POST, 'showPinned', 0));
48-
}
49-
50-
$showArcProjs = $AppUI->getState('TaskDayShowArc', 0);
51-
$showLowTasks = $AppUI->getState('TaskDayShowLow', 1);
52-
$showHoldProjs = $AppUI->getState('TaskDayShowHold', 0);
53-
$showDynTasks = $AppUI->getState('TaskDayShowDyn', 0);
54-
$showPinned = $AppUI->getState('TaskDayShowPin', 0);
42+
// todo.php has already saved the posted filters (the form below uses the
43+
// same field names as the My Tasks tab). The values go into the chart URL,
44+
// where gantt.php casts them to int, so pass them as 1/0 rather than the
45+
// checkbox value "on".
46+
$showArcProjs = $AppUI->getState('TaskDayShowArc', 0) ? 1 : 0;
47+
$showLowTasks = $AppUI->getState('TaskDayShowLow', 1) ? 1 : 0;
48+
$showHoldProjs = $AppUI->getState('TaskDayShowHold', 0) ? 1 : 0;
49+
$showDynTasks = $AppUI->getState('TaskDayShowDyn', 0) ? 1 : 0;
50+
$showPinned = $AppUI->getState('TaskDayShowPin', 0) ? 1 : 0;
5551
} else {
5652
$showPinned = w2PgetParam($_POST, 'showPinned', '0');
5753
$showPinned = (($showPinned != '0') ? '1' : $showPinned);
@@ -270,49 +266,27 @@ function submitIt() {
270266
</div>
271267
<?php if ($a == 'todo') { ?>
272268
<input type="hidden" name="show_form" value="1" />
269+
<?php // Not shown on this tab, but todo.php resets any filter that is not posted. ?>
270+
<input type="hidden" name="show_empty_date" value="<?php echo $AppUI->getState('TaskDayShowEmptyDate', 0) ? 1 : 0; ?>" />
271+
<input type="hidden" name="show_inprogress" value="<?php echo $AppUI->getState('TaskDayShowInProgress', 0) ? 1 : 0; ?>" />
273272
<div class="d-flex flex-wrap justify-content-center gap-3 mt-2">
274-
<span class="text-nowrap">
275-
<input type="checkbox" name="showPinned" id="showPinned" <?php echo $showPinned ? 'checked="checked"' : ''; ?> />
276-
<label for="showPinned"><?php echo $AppUI->_('Pinned Only'); ?></label>
277-
</span>
278-
<span class="text-nowrap">
279-
<input type="checkbox" name="showArcProjs" id="showArcProjs" <?php echo $showArcProjs ? 'checked="checked"' : ''; ?> />
280-
<label for="showArcProjs"><?php echo $AppUI->_('Archived/Template Projects'); ?></label>
281-
</span>
282-
<span class="text-nowrap">
283-
<input type="checkbox" name="showDynTasks" id="showDynTasks" <?php echo $showDynTasks ? 'checked="checked"' : ''; ?> />
284-
<label for="showDynTasks"><?php echo $AppUI->_('Dynamic Tasks'); ?></label>
285-
</span>
286-
<span class="text-nowrap">
287-
<input type="checkbox" name="showLowTasks" id="showLowTasks" <?php echo $showLowTasks ? 'checked="checked"' : ''; ?> />
288-
<label for="showLowTasks"><?php echo $AppUI->_('Low Priority Tasks'); ?></label>
289-
</span>
290-
</div>
291-
<div id="ganttoptions" style="display:none">
292-
<input type="hidden" name="show_form" value="1" />
293-
<div class="d-flex flex-wrap gap-3">
294-
<span>&nbsp;To Do Options:&nbsp;</span>
295-
<span class="text-nowrap">
296-
<input type="checkbox" name="showPinned" id="showPinned" <?php echo $showPinned ? 'checked="checked"' : ''; ?> />
297-
<label for="showPinned"><?php echo $AppUI->_('Pinned Only'); ?></label>
298-
</span>
299-
<span class="text-nowrap">
300-
<input type="checkbox" name="showArcProjs" id="showArcProjs" <?php echo $showArcProjs ? 'checked="checked"' : ''; ?> />
301-
<label for="showArcProjs"><?php echo $AppUI->_('Archived Projects'); ?></label>
302-
</span>
303-
<span class="text-nowrap">
304-
<input type="checkbox" name="showHoldProjs" id="showHoldProjs" <?php echo $showHoldProjs ? 'checked="checked"' : ''; ?> />
305-
<label for="showHoldProjs"><?php echo $AppUI->_('Projects on Hold'); ?></label>
306-
</span>
307-
<span class="text-nowrap">
308-
<input type="checkbox" name="showDynTasks" id="showDynTasks" <?php echo $showDynTasks ? 'checked="checked"' : ''; ?> />
309-
<label for="showDynTasks"><?php echo $AppUI->_('Dynamic Tasks'); ?></label>
310-
</span>
273+
<?php
274+
$todoFilters = array(
275+
'show_pinned' => array($showPinned, 'Pinned Only'),
276+
'show_arc_proj' => array($showArcProjs, 'Archived/Template Projects'),
277+
'show_hold_proj' => array($showHoldProjs, 'Projects on Hold'),
278+
'show_dyn_task' => array($showDynTasks, 'Dynamic Tasks'),
279+
'show_low_task' => array($showLowTasks, 'Low Priority Tasks'),
280+
);
281+
foreach ($todoFilters as $name => $filter) {
282+
?>
311283
<span class="text-nowrap">
312-
<input type="checkbox" name="showLowTasks" id="showLowTasks" <?php echo $showLowTasks ? 'checked="checked"' : ''; ?> />
313-
<label for="showLowTasks"><?php echo $AppUI->_('Low Priority Tasks'); ?></label>
284+
<input type="checkbox" name="<?php echo $name; ?>" id="gantt_<?php echo $name; ?>" value="1" <?php echo $filter[0] ? 'checked="checked"' : ''; ?> />
285+
<label for="gantt_<?php echo $name; ?>"><?php echo $AppUI->_($filter[1]); ?></label>
314286
</span>
315-
</div>
287+
<?php
288+
}
289+
?>
316290
</div>
317291
<?php } ?>
318292
<div class="text-center mt-2">

0 commit comments

Comments
 (0)