Et2LinkList: Fix deleting links on unsaved entries deleted more than expected

This commit is contained in:
nathan 2022-08-04 10:47:06 -06:00
parent 111e337db1
commit 78acaba766

View File

@ -296,15 +296,26 @@ export class Et2LinkList extends Et2LinkString
link_element.classList.add("loading"); link_element.classList.add("loading");
this.dispatchEvent(new CustomEvent("before_delete", {detail: link})); this.dispatchEvent(new CustomEvent("before_delete", {detail: link}));
let removeLink = () => {this.querySelectorAll("[slot='" + this._get_row_id(link) + "']").forEach(e => e.remove());};
// Unsaved entry, had no ID yet
if(typeof this.entryId !== "string" && this.entryId[link.link_id])
{
delete this.entryId[link.link_id];
removeLink();
}
else if(typeof this.entryId == "string" && link.link_id)
{
egw.json("EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_delete", [link.link_id]).sendRequest() egw.json("EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_delete", [link.link_id]).sendRequest()
.then((data) => .then((data) =>
{ {
if(data) if(data)
{ {
this.querySelectorAll("[slot='" + this._get_row_id(link) + "']").forEach(e => e.remove()); removeLink();
} }
}); });
}
} }
/** /**