persist ppl's edit text on failure

master
Aevann 2023-07-14 20:07:58 +03:00
parent dce3dde6d7
commit a139197371
3 changed files with 10 additions and 3 deletions

View File

@ -327,6 +327,14 @@ function sendFormXHRSwitch(form) {
)
}
function sendFormXHRReload(form) {
sendFormXHR(form,
() => {
location.reload();
}
)
}
let sortAscending = {};
function sort_table(t) {

View File

@ -1089,5 +1089,4 @@ def edit_post(pid, v):
)
g.db.add(ma)
return redirect(p.permalink)
return {"message": "Post edited successfully!"}

View File

@ -157,7 +157,7 @@
{% if v and v.can_edit(p) and not v.is_suspended %}
<div id="edit-post-body-{{p.id}}" class="d-none comment-write collapsed child">
<form id="post-edit-form-{{p.id}}" action="/edit_post/{{p.id}}" method="post" enctype="multipart/form-data">
<form id="post-edit-form-{{p.id}}" action="/edit_post/{{p.id}}" method="post" enctype="multipart/form-data" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRReload(this)">
<input hidden name="formkey" value="{{v|formkey}}">
<input hidden name="current_page" value="{{request.path}}">
<textarea id="post-edit-title" autocomplete="off" max-length="500" name="title" class="comment-box form-control rounded" required placeholder="title">{{p.title}}</textarea>