Fix a few bugs and edge cases in conditional logic
This commit is contained in:
parent
c09ab3c48e
commit
6f6c605cc9
14
js/main.js
14
js/main.js
|
|
@ -78,6 +78,7 @@ function deleteTask() {
|
|||
if ( $("#form_id").val() == "0" ) return;
|
||||
const doDelete = confirm("Are you certain you wish to delete this task?\n\nIf so then click 'OK'.")
|
||||
if ( !doDelete ) return;
|
||||
$("#form_delete").prop("disabled", true);
|
||||
$.ajax({
|
||||
url: 'ajax/task-delete.php',
|
||||
type: 'POST',
|
||||
|
|
@ -97,14 +98,16 @@ function deleteTask() {
|
|||
},
|
||||
error: function(jqo, stat, error) {
|
||||
toastr.error("Could not communicate with server!", "Server Error");
|
||||
},
|
||||
complete: function() {
|
||||
$("#form_delete").prop("disabled", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setTaskCompleteState(complete = TASKCOMPLETE) {
|
||||
if ( $("#form_id").val() == "0" ) return;
|
||||
$("#form_complete").prop("disabled", true);
|
||||
$("#form_incomplete").prop("disabled", true);
|
||||
$("#form_setcomplete, #form_setincomplete").prop("disabled", true);
|
||||
$.ajax({
|
||||
url: 'ajax/task-setcomplete.php',
|
||||
type: 'POST',
|
||||
|
|
@ -118,8 +121,8 @@ function setTaskCompleteState(complete = TASKCOMPLETE) {
|
|||
toastr.error(data.message, "Submission Error");
|
||||
return;
|
||||
}
|
||||
if ( !Object.hasOwn(data, "task") ) {
|
||||
toastr.error("API Error", "No task returned");
|
||||
if ( !data.task ) {
|
||||
toastr.error("No task returned", "API Error);
|
||||
return;
|
||||
}
|
||||
toastr.success(data.message, (data.task.completed) ? "Task Complete" : "Task Incomplete");
|
||||
|
|
@ -131,8 +134,7 @@ function setTaskCompleteState(complete = TASKCOMPLETE) {
|
|||
toastr.error("Could not communicate with server!", "Server Error");
|
||||
},
|
||||
complete: function() {
|
||||
$("#form_complete").prop("disabled", false);
|
||||
$("#form_incomplete").prop("disabled", false);
|
||||
$("#form_setcomplete, #form_setincomplete").prop("disabled", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user