Merge pull request #27921 from barredterra/redirect-after-rename

feat: redirect to new record after rename
This commit is contained in:
Akhil Narang 2024-10-01 15:53:37 +05:30 committed by GitHub
commit 22a64461aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -229,6 +229,15 @@ def rename_doc(
indicator="green",
)
# let people watching the old form know that it has been renamed
frappe.publish_realtime(
event="doc_rename",
message={"doctype": doctype, "old": old, "new": new},
doctype=doctype,
docname=old,
after_commit=True,
)
return new

View file

@ -333,6 +333,14 @@ frappe.ui.form.Form = class FrappeForm {
$(document).on("rename", (ev, dt, old_name, new_name) => {
if (dt == this.doctype) this.rename_notify(dt, old_name, new_name);
});
frappe.realtime.on("doc_rename", (data) => {
// the current form has been renamed by some backend process
if (data.doctype == this.doctype && data.old == this.docname) {
// the current form does not exist anymore, route to the new one
frappe.set_route("Form", this.doctype, data.new);
}
});
}
setup_file_drop() {