Ensure show all tasks checkbox stays in better sync with the server
This commit is contained in:
parent
a9a4667231
commit
6b16ddfc31
16
js/main.js
16
js/main.js
|
|
@ -113,11 +113,8 @@ function setTaskComplete(incomplete = false) {
|
||||||
if ( data.error ) {
|
if ( data.error ) {
|
||||||
toastr.error(data.message, "Submission Error");
|
toastr.error(data.message, "Submission Error");
|
||||||
return;
|
return;
|
||||||
if ( data.task.completed ) {
|
|
||||||
toastr.success(data.message, "Task Complete");
|
|
||||||
} else {
|
|
||||||
toastr.success(data.message, "Task Incomplete");
|
|
||||||
}
|
}
|
||||||
|
toastr.success(data.message, (data.task.completed) ? "Task Complete" : "Task Incomplete");
|
||||||
getTasks();
|
getTasks();
|
||||||
updateImage();
|
updateImage();
|
||||||
resetForm(true);
|
resetForm(true);
|
||||||
|
|
@ -129,6 +126,7 @@ function setTaskComplete(incomplete = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleShowAll() {
|
function toggleShowAll() {
|
||||||
|
const previousValue = ! $("#form_showall").prop('checked');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'ajax/toggleshowall.php',
|
url: 'ajax/toggleshowall.php',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
@ -139,14 +137,16 @@ function toggleShowAll() {
|
||||||
success: function(data, stat, jqo) {
|
success: function(data, stat, jqo) {
|
||||||
if ( data.error ) {
|
if ( data.error ) {
|
||||||
toastr.error(data.message, "Form Data Error");
|
toastr.error(data.message, "Form Data Error");
|
||||||
} else {
|
$("#form_showall").prop('checked', previousValue);
|
||||||
toastr.success(data.message, "Task List");
|
return;
|
||||||
getTasks();
|
|
||||||
}
|
}
|
||||||
$("#form_showall").prop('checked', data.showall);
|
$("#form_showall").prop('checked', data.showall);
|
||||||
|
toastr.success(data.message, "Task List");
|
||||||
|
getTasks();
|
||||||
},
|
},
|
||||||
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");
|
||||||
|
$("#form_showall").prop('checked', previousValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +177,7 @@ function submitTask() {
|
||||||
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() {
|
complete: function() {
|
||||||
$("#form_submit").prop("disabled", false);
|
$("#form_submit").prop("disabled", false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user