Revert "Et2LinkList: Fire change event when link is removed" committed to wrong branch

This reverts commit a35d3d8778.
This commit is contained in:
nathan 2023-03-03 15:10:16 -07:00
parent b2c4b09b4a
commit 7d75c902d5
2 changed files with 11 additions and 45 deletions

View File

@ -113,7 +113,6 @@ export class Et2LinkList extends Et2LinkString
this._handleRowContext = this._handleRowContext.bind(this);
this._handleChange = this._handleChange.bind(this);
this._handleLinkToChange = this._handleLinkToChange.bind(this);
}
connectedCallback()
@ -122,29 +121,20 @@ export class Et2LinkList extends Et2LinkString
this._createContextMenu();
// Look for LinkTo and listen for change so we can update
if(this.getInstanceManager())
{
this.getInstanceManager().DOMContainer.querySelectorAll("et2-link-to").forEach(link =>
{
link.addEventListener("et2-change", this._handleLinkToChange);
link.addEventListener("et2-change", this._handleChange);
})
}
this.addEventListener("change", this._handleChange);
}
disconnectedCallback()
{
super.disconnectedCallback();
if(this.getInstanceManager())
{
this.getInstanceManager().DOMContainer.querySelectorAll("et2-link-to").forEach(link =>
{
link.removeEventListener("et2-change", this._handleLinkToChange);
link.removeEventListener("et2-change", this._handleChange);
})
}
this.removeEventListener("change", this._handleChange);
}
protected _listTemplate()
{
@ -257,27 +247,13 @@ export class Et2LinkList extends Et2LinkString
}
}
/**
* Handle & pass on an internal change
* @param {ChangeEvent} _event
* @protected
*/
protected _handleChange(_event : Event)
{
if(!this.onchange)
{
return;
}
this.onchange(this, _event.data, _event)
}
/**
* We listen to LinkTo widgets so we can update
*
* @param _ev
* @protected
*/
protected _handleLinkToChange(_ev)
protected _handleChange(_ev)
{
if(_ev && typeof _ev.currentTarget)
{
@ -325,9 +301,7 @@ export class Et2LinkList extends Et2LinkString
return html``;
}
return html`
<et2-image class="delete_button" slot="${this._get_row_id(link)}" src="delete"
part="delete-button"
._parent=${this}
<et2-image class="delete_button" slot="${this._get_row_id(link)}" src="delete" ._parent=${this}
.onclick=${() =>
{
this._delete_link(link);
@ -367,9 +341,6 @@ export class Et2LinkList extends Et2LinkString
this._link_list.splice(this._link_list.indexOf(link), 1);
}
this.dispatchEvent(new CustomEvent("et2-delete", {bubbles: true, detail: link}));
let change = new Event("change", {bubbles: true});
change['data'] = link;
this.dispatchEvent(change);
};
// Unsaved entry, had no ID yet
@ -420,12 +391,7 @@ export class Et2LinkList extends Et2LinkString
for(let id in list)
{
let link = list[id];
if(!link.app && typeof list.splice !== "undefined")
{
list.splice(parseInt(id), 1);
continue;
}
else if(link.app)
if(link.app)
{
// Temp IDs can cause problems since the ID includes the file name or :
if(link.link_id && typeof link.link_id != 'number')
@ -449,9 +415,9 @@ export class Et2LinkList extends Et2LinkString
{
link.title = link.id.name || '';
}
(<LinkInfo[]>this._link_list).push(<LinkInfo>link);
}
}
this._addLinks(list);
}
else
{

View File

@ -248,7 +248,7 @@ export class Et2LinkString extends Et2Widget(LitElement) implements et2_IDetache
);
*/
this.dispatchEvent(new Event("change", {bubbles: true}));
}
/**