Fix the completed boolean of tasks in the class and set the toast accordingly

This commit is contained in:
Junior 2026-11-22 12:51:51 -05:00
parent 6222ca71a4
commit 8f47e90251
2 changed files with 9 additions and 3 deletions

View File

@ -58,12 +58,13 @@ class Task implements JsonSerializable {
} }
public function getCompleted($flag = 0) { public function getCompleted($flag = 0) {
$completed = (is_null($this->getCompleteTime())) ? false : true;
switch ($flag) { switch ($flag) {
case AppDB::BOOLEANDB: case AppDB::BOOLEANDB:
return ($this->completed) ? "true" : "false"; return ($completed) ? "true" : "false";
break; break;
default: default:
return $this->completed; return $completed;
break; break;
} }
} }
@ -220,6 +221,7 @@ class Task implements JsonSerializable {
'createdate' => $this->getCreateTime(SHORTDATE), 'createdate' => $this->getCreateTime(SHORTDATE),
'duetime' => $this->getDueTime(), 'duetime' => $this->getDueTime(),
'duedate' => $this->getDueTime(SHORTDATE), 'duedate' => $this->getDueTime(SHORTDATE),
'completed' => $this->getCompleted(),
'completetime' => $this->getCompleteTime(), 'completetime' => $this->getCompleteTime(),
'completedate' => $this->getCompleteTime(SHORTDATE) 'completedate' => $this->getCompleteTime(SHORTDATE)
]; ];

View File

@ -113,7 +113,11 @@ function setTaskComplete(incomplete = false) {
if ( data.error ) { if ( data.error ) {
toastr.error(data.message, "Submission Error"); toastr.error(data.message, "Submission Error");
} else { } else {
toastr.success(data.message, "Task Complete"); if ( data.task.completed ) {
toastr.success(data.message, "Task Complete");
} else {
toastr.success(data.message, "Task Incomplete");
}
getTasks(); getTasks();
updateImage(); updateImage();
resetForm(true); resetForm(true);