further frontend annoyances

This commit is contained in:
Simon Martens
2026-01-16 19:08:30 +01:00
parent 136cb5f757
commit 7db1e4390e
9 changed files with 1060 additions and 460 deletions

View File

@@ -28,6 +28,7 @@ export class RelationsEditor extends HTMLElement {
this._emptyText = this.querySelector(".rel-empty-text");
this._setupAddPanel();
this._setupDeleteToggles();
this._setupNewRowDeletes();
this._setupPreferredOptionHandling();
}
@@ -248,6 +249,7 @@ export class RelationsEditor extends HTMLElement {
if (uncertain && this._uncertain) {
uncertain.checked = this._uncertain.checked;
uncertain.name = `${this._prefix}_new_uncertain`;
uncertain.value = this._pendingItem.id;
const uncertainId = `${this._prefix}_new_uncertain_row`;
uncertain.id = uncertainId;
const uncertainLabel = fragment.querySelector("[data-rel-uncertain-label]");
@@ -389,6 +391,31 @@ export class RelationsEditor extends HTMLElement {
});
}
_setupNewRowDeletes() {
if (!this._addRow) {
return;
}
this._addRow.querySelectorAll(ROLE_NEW_DELETE).forEach((button) => {
if (button.dataset.relationNewBound === "true") {
return;
}
button.dataset.relationNewBound = "true";
button.addEventListener("click", () => {
const row = button.closest(ROLE_REL_ROW);
if (row) {
row.remove();
}
this._pendingItem = null;
this._clearAddPanel();
if (this._addPanel) {
this._addPanel.classList.add("hidden");
}
this._updateEmptyTextVisibility();
this._updatePreferredOptions();
});
});
}
_setupPreferredOptionHandling() {
if (this._prefix !== "entries_series" || !this._preferredLabel) {
return;