We are at the start of getting UPDATE support properly set up.

This commit is contained in:
Yaro Kasear 2025-09-30 14:56:47 -05:00
parent dbf0d6169a
commit 8a3eb2c2ef
3 changed files with 194 additions and 18 deletions

View file

@ -41,6 +41,7 @@
document.getElementById("{{ field['attrs']['data-model'] }}_form").addEventListener("submit", async e => {
e.preventDefault();
const json = formToJson(e.target);
json['id'] = {{ field['template_ctx']['values']['id'] }};
response = await fetch("{{ url_for('entry.update_entry', id=field['template_ctx']['values']['id'], model=field['attrs']['data-model']) }}", {
method: "POST",
@ -52,9 +53,9 @@
reply = await response.json();
if (reply['status'] === 'success') {
console.log("WELL DONE!")
toastMessage("This entry has been successfully saved!", "success");
} else {
console.log("YOU HAVE FAILED!")
toastMessage(`Unable to save entry: ${reply['error']}`, "danger");
}
});
</script>