diff --git a/lute/templates/term/_form.html b/lute/templates/term/_form.html index 9f1b5b5d..232e7a35 100644 --- a/lute/templates/term/_form.html +++ b/lute/templates/term/_form.html @@ -81,6 +81,13 @@ Sentences + {% if term.id %} + + + + + + {% endif %} @@ -398,4 +405,25 @@ top.frames.dictframe.location.href = url; } + function deleteTerm() { + // Ask for confirmation + var isConfirmed = confirm('Are you sure you want to delete this term?\n\nThis action cannot be undone, and if this term has children, they will be orphaned.'); + + // Check if the user confirmed + if (isConfirmed) { + // Delete term + fetch("/term/delete/{{ term.id }}") + + if ("{{ embedded_in_reading_frame }}" == "True") { + // If on reading page, reload page + parent.location.reload(); + } + else { + // If on term page, go to term listing + window.location.href = '/term/index'; + } + } + } + + diff --git a/lute/templates/term/formframes.html b/lute/templates/term/formframes.html index 1def3a18..5df5e392 100644 --- a/lute/templates/term/formframes.html +++ b/lute/templates/term/formframes.html @@ -7,16 +7,7 @@ {% block body %}
{% include('term/_form.html') %} - back to list - - {% if term.id %} -
- -
- {% endif %} + Back to all terms
diff --git a/lute/term/routes.py b/lute/term/routes.py index c73391d6..439ae06c 100644 --- a/lute/term/routes.py +++ b/lute/term/routes.py @@ -200,7 +200,7 @@ def bulk_set_parent(): return jsonify("ok") -@bp.route("/delete/", methods=["POST"]) +@bp.route("/delete/", methods=["GET"]) def delete(termid): """ Delete a term.