* can save setting of alltasks list to show or not completed tasks

This commit is contained in:
maxpozdeev 2022-08-01 22:16:01 +03:00
parent c51a46567d
commit f7d590383f
2 changed files with 18 additions and 3 deletions

View file

@ -157,17 +157,19 @@ class ListsController extends ApiController {
//default values
$hidden = 1;
$sort = 3;
$showCompleted = 1;
$opts = Config::requestDomain('alltasks.json');
if ( isset($opts['hidden']) ) $hidden = (int)$opts['hidden'] ? 1 : 0;
if ( isset($opts['sort']) ) $sort = (int)$opts['sort'];
if ( isset($opts['showCompleted']) ) $showCompleted = (int)$opts['showCompleted'];
return array(
'id' => -1,
'name' => htmlarray(__('alltasks')),
'sort' => $sort,
'published' => 0,
'showCompl' => 1,
'showCompl' => $showCompleted,
'showNotes' => 0,
'hidden' => $hidden,
);
@ -226,6 +228,20 @@ class ListsController extends ApiController {
}
}
static function setListShowCompletedById(int $listId, bool $showCompleted)
{
$db = DBConnection::instance();
if ($listId == -1) {
$opts = Config::requestDomain('alltasks.json');
$opts['showCompleted'] = (int)$showCompleted;
Config::saveDomain('alltasks.json', $opts);
}
else {
$bitwise = $showCompleted ? 'taskview & ~1' : 'taskview | 1';
$db->dq("UPDATE {$db->prefix}lists SET taskview=$bitwise WHERE id=?", [$listId]);
}
}
private function publishList(int $listId)
{
$db = DBConnection::instance();

View file

@ -99,8 +99,7 @@ class TasksController extends ApiController {
$t['list'][] = $this->prepareTaskRow($r);
}
if (_get('setCompl') && haveWriteAccess($listId)) {
$bitwise = (_get('compl') == 0) ? 'taskview & ~1' : 'taskview | 1';
$db->dq("UPDATE {$db->prefix}lists SET taskview=$bitwise WHERE id=$listId");
ListsController::setListShowCompletedById($listId, !(_get('compl') == 0) );
}
if (_get('saveSort') == 1 && haveWriteAccess($listId)) {
ListsController::setListSortingById($listId, $sort);