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