This commit is contained in:
Simon Martens
2026-01-08 18:23:48 +01:00
parent 93ea651c79
commit aff194f400
3 changed files with 144 additions and 125 deletions

View File

@@ -1,10 +1,10 @@
var $t = Object.defineProperty; var $t = Object.defineProperty;
var j = (l) => { var j = (a) => {
throw TypeError(l); throw TypeError(a);
}; };
var Nt = (l, i, t) => i in l ? $t(l, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[i] = t; var Nt = (a, i, t) => i in a ? $t(a, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[i] = t;
var E = (l, i, t) => Nt(l, typeof i != "symbol" ? i + "" : i, t), B = (l, i, t) => i.has(l) || j("Cannot " + t); var E = (a, i, t) => Nt(a, typeof i != "symbol" ? i + "" : i, t), B = (a, i, t) => i.has(a) || j("Cannot " + t);
var $ = (l, i, t) => (B(l, i, "read from private field"), t ? t.call(l) : i.get(l)), S = (l, i, t) => i.has(l) ? j("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(l) : i.set(l, t), I = (l, i, t, e) => (B(l, i, "write to private field"), e ? e.call(l, t) : i.set(l, t), t), T = (l, i, t) => (B(l, i, "access private method"), t); var $ = (a, i, t) => (B(a, i, "read from private field"), t ? t.call(a) : i.get(a)), S = (a, i, t) => i.has(a) ? j("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(a) : i.set(a, t), I = (a, i, t, e) => (B(a, i, "write to private field"), e ? e.call(a, t) : i.set(a, t), t), T = (a, i, t) => (B(a, i, "access private method"), t);
class Pt extends HTMLElement { class Pt extends HTMLElement {
constructor() { constructor() {
super(), this._value = "", this.render(); super(), this._value = "", this.render();
@@ -526,11 +526,11 @@ class Kt extends HTMLElement {
this._showall = !0, this.shown = -1, this.disable(), this._contents.forEach((i, t) => { this._showall = !0, this.shown = -1, this.disable(), this._contents.forEach((i, t) => {
i.classList.remove("hidden"); i.classList.remove("hidden");
let e = this._headings[t], s = e.querySelectorAll(".show-opened"); let e = this._headings[t], s = e.querySelectorAll(".show-opened");
for (let a of s) for (let l of s)
a.classList.add("hidden"); l.classList.add("hidden");
let n = e.querySelectorAll(".show-closed"); let n = e.querySelectorAll(".show-closed");
for (let a of n) for (let l of n)
a.classList.add("hidden"); l.classList.add("hidden");
}); });
} }
default() { default() {
@@ -678,17 +678,17 @@ class L extends HTMLElement {
} }
const n = this.findLongestAbbrevAt(i, s, t); const n = this.findLongestAbbrevAt(i, s, t);
if (n) { if (n) {
const { match: a, meaning: r } = n; const { match: l, meaning: r } = n;
e += ` e += `
<tool-tip position="top" class="!inline" timeout="300"> <tool-tip position="top" class="!inline" timeout="300">
<div class="data-tip p-2 text-sm text-white bg-gray-700 rounded shadow"> <div class="data-tip p-2 text-sm text-white bg-gray-700 rounded shadow">
${r} ${r}
</div> </div>
<span class="cursor-help text-blue-900 hover:text-slate-800"> <span class="cursor-help text-blue-900 hover:text-slate-800">
${a} ${l}
</span> </span>
</tool-tip> </tool-tip>
`, s += a.length; `, s += l.length;
} else } else
e += i[s], s++; e += i[s], s++;
} }
@@ -696,8 +696,8 @@ class L extends HTMLElement {
} }
findLongestAbbrevAt(i, t, e) { findLongestAbbrevAt(i, t, e) {
let s = null, n = 0; let s = null, n = 0;
for (const a of Object.keys(e)) for (const l of Object.keys(e))
i.startsWith(a, t) && a.length > n && (s = a, n = a.length); i.startsWith(l, t) && l.length > n && (s = l, n = l.length);
return s ? { match: s, meaning: e[s] } : null; return s ? { match: s, meaning: e[s] } : null;
} }
isSpaceOrPunct(i) { isSpaceOrPunct(i) {
@@ -879,9 +879,9 @@ class xt extends HTMLElement {
} }
set value(t) { set value(t) {
if (Array.isArray(t)) { if (Array.isArray(t)) {
const e = t.map((a) => { const e = t.map((l) => {
if (typeof a == "string") { if (typeof l == "string") {
const r = a.split(","); const r = l.split(",");
if (r.length === 2) { if (r.length === 2) {
const o = r[0].trim(), d = r[1].trim(); const o = r[0].trim(), d = r[1].trim();
if (this._getItemById(o) && this._roles.includes(d)) if (this._getItemById(o) && this._roles.includes(d))
@@ -889,10 +889,10 @@ class xt extends HTMLElement {
} }
} }
return null; return null;
}).filter((a) => a !== null), s = [], n = /* @__PURE__ */ new Set(); }).filter((l) => l !== null), s = [], n = /* @__PURE__ */ new Set();
for (const a of e) { for (const l of e) {
const r = `${a.itemId},${a.role}`; const r = `${l.itemId},${l.role}`;
n.has(r) || (s.push(a), n.add(r)); n.has(r) || (s.push(l), n.add(r));
} }
this._value = s; this._value = s;
} else } else
@@ -999,10 +999,10 @@ class xt extends HTMLElement {
} }
_createStagedRoleSelectElement(t, e) { _createStagedRoleSelectElement(t, e) {
const n = this.stagedRoleSelectTemplate.content.cloneNode(!0).firstElementChild; const n = this.stagedRoleSelectTemplate.content.cloneNode(!0).firstElementChild;
let a = `<option value="" disabled ${e ? "" : "selected"}>${this.placeholderRoleSelect}</option>`; let l = `<option value="" disabled ${e ? "" : "selected"}>${this.placeholderRoleSelect}</option>`;
return t.length === 0 && !this._roles.includes(e) ? (a += "<option disabled>Keine Rollen verfügbar</option>", n.disabled = !0) : (t.forEach((r) => { return t.length === 0 && !this._roles.includes(e) ? (l += "<option disabled>Keine Rollen verfügbar</option>", n.disabled = !0) : (t.forEach((r) => {
a += `<option value="${r}" ${r === e ? "selected" : ""}>${r}</option>`; l += `<option value="${r}" ${r === e ? "selected" : ""}>${r}</option>`;
}), n.disabled = t.length === 0 && e === ""), n.innerHTML = a, n.addEventListener("change", this._handleStagedRoleChange), n; }), n.disabled = t.length === 0 && e === ""), n.innerHTML = l, n.addEventListener("change", this._handleStagedRoleChange), n;
} }
_createStagedCancelButtonElement(t) { _createStagedCancelButtonElement(t) {
const s = this.stagedCancelBtnTemplate.content.cloneNode(!0).firstElementChild; const s = this.stagedCancelBtnTemplate.content.cloneNode(!0).firstElementChild;
@@ -1040,9 +1040,9 @@ class xt extends HTMLElement {
_createSelectedItemElement(t) { _createSelectedItemElement(t) {
const e = this._getItemById(t.itemId); const e = this._getItemById(t.itemId);
if (!e) return null; if (!e) return null;
const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, a = n.querySelector('[data-ref="textEl"]'); const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, l = n.querySelector('[data-ref="textEl"]');
let r = `<span class="${Qt}">${e.name}</span>`, o = e.additional_data ? ` <span class="${Xt}">(${e.additional_data})</span>` : "", d = ` <span class="${Yt}">${t.role}</span>`; let r = `<span class="${Qt}">${e.name}</span>`, o = e.additional_data ? ` <span class="${Xt}">(${e.additional_data})</span>` : "", d = ` <span class="${Yt}">${t.role}</span>`;
a.innerHTML = `${r}${o}${d}`; l.innerHTML = `${r}${o}${d}`;
const c = n.querySelector('[data-ref="deleteBtn"]'); const c = n.querySelector('[data-ref="deleteBtn"]');
return c.setAttribute("aria-label", `Entferne ${e.name} als ${t.role}`), c.dataset.instanceId = t.instanceId, c.disabled = this.hasAttribute("disabled"), c.addEventListener("click", (h) => { return c.setAttribute("aria-label", `Entferne ${e.name} als ${t.role}`), c.dataset.instanceId = t.instanceId, c.disabled = this.hasAttribute("disabled"), c.addEventListener("click", (h) => {
h.stopPropagation(), this._handleDeleteSelectedItem(t.instanceId); h.stopPropagation(), this._handleDeleteSelectedItem(t.instanceId);
@@ -1182,7 +1182,7 @@ class xt extends HTMLElement {
if (this.hasAttribute("disabled")) return; if (this.hasAttribute("disabled")) return;
const e = t.target.closest(`li[data-id].${lt}`); const e = t.target.closest(`li[data-id].${lt}`);
if (e) { if (e) {
const s = e.dataset.id, n = this._filteredOptions.find((a) => a.id === s); const s = e.dataset.id, n = this._filteredOptions.find((l) => l.id === s);
n && this._stageItem(n); n && this._stageItem(n);
} }
} }
@@ -1434,7 +1434,7 @@ class kt extends HTMLElement {
this._value = [...new Set(t.filter((n) => typeof n == "string" && this._getItemById(n)))]; this._value = [...new Set(t.filter((n) => typeof n == "string" && this._getItemById(n)))];
else if (typeof t == "string" && t.trim() !== "") { else if (typeof t == "string" && t.trim() !== "") {
const n = t.trim(); const n = t.trim();
this._getItemById(n) && !this._value.includes(n) ? this._value = [n] : this._getItemById(n) || (this._value = this._value.filter((a) => a !== n)); this._getItemById(n) && !this._value.includes(n) ? this._value = [n] : this._getItemById(n) || (this._value = this._value.filter((l) => l !== n));
} else this._value = []; } else this._value = [];
const s = JSON.stringify(this._value.sort()); const s = JSON.stringify(this._value.sort());
!this._initialCaptured && this._allowInitialCapture && this._value.length > 0 && (this._initialValue = [...this._value], this._initialOrder = [...this._value], this._initialCaptured = !0), this._value.forEach((n) => { !this._initialCaptured && this._allowInitialCapture && this._value.length > 0 && (this._initialValue = [...this._value], this._initialOrder = [...this._value], this._initialCaptured = !0), this._value.forEach((n) => {
@@ -1484,7 +1484,7 @@ class kt extends HTMLElement {
try { try {
this.value = JSON.parse(s); this.value = JSON.parse(s);
} catch { } catch {
this.value = s.split(",").map((a) => a.trim()).filter(Boolean); this.value = s.split(",").map((l) => l.trim()).filter(Boolean);
} }
else t === "placeholder" ? this.placeholder = s : t === "show-create-button" ? this.showCreateButton = s : t === "data-endpoint" ? this._remoteEndpoint = s || null : t === "data-result-key" ? this._remoteResultKey = s || "items" : t === "data-minchars" ? this._remoteMinChars = this._parsePositiveInt(s, F) : t === "data-limit" ? this._remoteLimit = this._parsePositiveInt(s, V) : t === "data-toggle-label" && (this._toggleLabel = s || "", this._toggleInput = this._toggleLabel !== ""); else t === "placeholder" ? this.placeholder = s : t === "show-create-button" ? this.showCreateButton = s : t === "data-endpoint" ? this._remoteEndpoint = s || null : t === "data-result-key" ? this._remoteResultKey = s || "items" : t === "data-minchars" ? this._remoteMinChars = this._parsePositiveInt(s, F) : t === "data-limit" ? this._remoteLimit = this._parsePositiveInt(s, V) : t === "data-toggle-label" && (this._toggleLabel = s || "", this._toggleInput = this._toggleLabel !== "");
} }
@@ -1552,16 +1552,16 @@ class kt extends HTMLElement {
_createSelectedItemElement(t) { _createSelectedItemElement(t) {
const e = this._getItemById(t); const e = this._getItemById(t);
if (!e) return null; if (!e) return null;
const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, a = n.querySelector('[data-ref="textEl"]'), r = n.querySelector('[data-ref="detailEl"]'), o = n.querySelector('[data-ref="deleteBtn"]'); const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, l = n.querySelector('[data-ref="textEl"]'), r = n.querySelector('[data-ref="detailEl"]'), o = n.querySelector('[data-ref="deleteBtn"]');
a.textContent = this._normalizeText(e.name); l.textContent = this._normalizeText(e.name);
const d = this._normalizeText(e.additional_data); const d = this._normalizeText(e.additional_data);
d ? (r.textContent = `(${d})`, r.classList.remove("hidden")) : (r.textContent = "", r.classList.add("hidden")); d ? (r.textContent = `(${d})`, r.classList.remove("hidden")) : (r.textContent = "", r.classList.add("hidden"));
const c = this._removedIds.has(t); const c = this._removedIds.has(t);
if (!this._initialValue.includes(t)) { if (!this._initialValue.includes(t)) {
const u = document.createElement("span"); const u = document.createElement("span");
u.className = "ml-1 text-xs text-gray-600", u.textContent = "(Neu)", a.appendChild(u); u.className = "ml-1 text-xs text-gray-600", u.textContent = "(Neu)", l.appendChild(u);
} }
return c && (a.classList.add("line-through", "decoration-2", "decoration-red-600", "text-gray-500"), r.classList.add("line-through", "decoration-2", "decoration-red-600", "text-gray-500")), o.setAttribute("aria-label", c ? `Undo remove ${e.name}` : `Remove ${e.name}`), o.dataset.id = t, o.disabled = this.hasAttribute("disabled"), o.innerHTML = c ? '<span class="text-xs inline-flex items-center"><i class="ri-arrow-go-back-line"></i></span>' : "&times;", o.addEventListener("click", (u) => { return c && (l.classList.add("line-through", "decoration-2", "decoration-red-600", "text-gray-500"), r.classList.add("line-through", "decoration-2", "decoration-red-600", "text-gray-500")), o.setAttribute("aria-label", c ? `Undo remove ${e.name}` : `Remove ${e.name}`), o.dataset.id = t, o.disabled = this.hasAttribute("disabled"), o.innerHTML = c ? '<span class="text-xs inline-flex items-center"><i class="ri-arrow-go-back-line"></i></span>' : "&times;", o.addEventListener("click", (u) => {
u.stopPropagation(), this._handleDeleteSelectedItem(t); u.stopPropagation(), this._handleDeleteSelectedItem(t);
}), n; }), n;
} }
@@ -1580,8 +1580,8 @@ class kt extends HTMLElement {
this._updateRootElementStateClasses(); this._updateRootElementStateClasses();
} }
_createOptionElement(t, e) { _createOptionElement(t, e) {
const n = this.optionTemplate.content.cloneNode(!0).firstElementChild, a = n.querySelector('[data-ref="nameEl"]'), r = n.querySelector('[data-ref="detailEl"]'); const n = this.optionTemplate.content.cloneNode(!0).firstElementChild, l = n.querySelector('[data-ref="nameEl"]'), r = n.querySelector('[data-ref="detailEl"]');
a.textContent = this._normalizeText(t.name); l.textContent = this._normalizeText(t.name);
const o = this._normalizeText(t.additional_data); const o = this._normalizeText(t.additional_data);
r.textContent = o ? `(${o})` : "", n.dataset.id = t.id, n.setAttribute("aria-selected", String(e === this._highlightedIndex)); r.textContent = o ? `(${o})` : "", n.dataset.id = t.id, n.setAttribute("aria-selected", String(e === this._highlightedIndex));
const d = `option-${this.id || "mss"}-${t.id}`; const d = `option-${this.id || "mss"}-${t.id}`;
@@ -1744,10 +1744,10 @@ class kt extends HTMLElement {
}); });
if (!n.ok) if (!n.ok)
throw new Error(`Remote fetch failed with status ${n.status}`); throw new Error(`Remote fetch failed with status ${n.status}`);
const a = await n.json(); const l = await n.json();
if (e.signal.aborted) if (e.signal.aborted)
return; return;
const r = this._extractRemoteOptions(a); const r = this._extractRemoteOptions(l);
this._applyRemoteResults(r); this._applyRemoteResults(r);
} catch (s) { } catch (s) {
if (e.signal.aborted) if (e.signal.aborted)
@@ -1762,7 +1762,7 @@ class kt extends HTMLElement {
let e = []; let e = [];
return Array.isArray(t) ? e = t : this._remoteResultKey && Array.isArray(t[this._remoteResultKey]) ? e = t[this._remoteResultKey] : Array.isArray(t.items) && (e = t.items), e.map((s) => { return Array.isArray(t) ? e = t : this._remoteResultKey && Array.isArray(t[this._remoteResultKey]) ? e = t[this._remoteResultKey] : Array.isArray(t.items) && (e = t.items), e.map((s) => {
if (!s) return null; if (!s) return null;
const n = s.id ?? s.ID ?? s.value ?? "", a = s.name ?? s.title ?? s.label ?? "", r = s.detail ?? s.additional_data ?? s.annotation ?? "", o = this._normalizeText(a), d = this._normalizeText(r); const n = s.id ?? s.ID ?? s.value ?? "", l = s.name ?? s.title ?? s.label ?? "", r = s.detail ?? s.additional_data ?? s.annotation ?? "", o = this._normalizeText(l), d = this._normalizeText(r);
return !n || !o ? null : { return !n || !o ? null : {
id: String(n), id: String(n),
name: o, name: o,
@@ -2038,7 +2038,7 @@ ${t[0].nameText()} hinzufügen`, this._menu = null, this.hideMenu();
console.error("DivManagerMenu: Invalid node provided."); console.error("DivManagerMenu: Invalid node provided.");
return; return;
} }
const s = this._cildren.find((a) => a.node === e); const s = this._cildren.find((l) => l.node === e);
if (!s) { if (!s) {
console.error("DivManagerMenu: Child not found."); console.error("DivManagerMenu: Child not found.");
return; return;
@@ -2076,7 +2076,7 @@ ${t[0].nameText()} hinzufügen`, this._menu = null, this.hideMenu();
}), this.updateTargetVisibility(); }), this.updateTargetVisibility();
} }
insertChildInOrder(t) { insertChildInOrder(t) {
const e = t.target(), s = this._cildren.indexOf(t), n = this._cildren.slice(s + 1).filter((a) => a.target() === e).map((a) => a.node).find((a) => e && e.contains(a)); const e = t.target(), s = this._cildren.indexOf(t), n = this._cildren.slice(s + 1).filter((l) => l.target() === e).map((l) => l.node).find((l) => e && e.contains(l));
e && (n ? e.insertBefore(t.node, n) : e.appendChild(t.node)); e && (n ? e.insertBefore(t.node, n) : e.appendChild(t.node));
} }
updateTargetVisibility() { updateTargetVisibility() {
@@ -2184,8 +2184,8 @@ class $e extends HTMLElement {
i.setAttribute(v, t ? "true" : "false"), i.classList.toggle("bg-red-50", t), i.querySelectorAll("[data-items-strike]").forEach((n) => { i.setAttribute(v, t ? "true" : "false"), i.classList.toggle("bg-red-50", t), i.querySelectorAll("[data-items-strike]").forEach((n) => {
n.classList.toggle("line-through", t), n.classList.toggle("decoration-2", t), n.classList.toggle("decoration-red-600", t), n.classList.toggle("text-gray-500", t); n.classList.toggle("line-through", t), n.classList.toggle("decoration-2", t), n.classList.toggle("decoration-red-600", t), n.classList.toggle("text-gray-500", t);
}), i.querySelectorAll("[data-delete-label]").forEach((n) => { }), i.querySelectorAll("[data-delete-label]").forEach((n) => {
const a = t ? n.getAttribute("data-delete-active") || "Wird entfernt" : n.getAttribute("data-delete-default") || "Entfernen"; const l = t ? n.getAttribute("data-delete-active") || "Wird entfernt" : n.getAttribute("data-delete-default") || "Entfernen";
n.textContent = a; n.textContent = l;
}), i.querySelectorAll(`.${yt} i`).forEach((n) => { }), i.querySelectorAll(`.${yt} i`).forEach((n) => {
t ? (n.classList.add("hidden"), n.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (n.classList.remove("hidden"), n.classList.add("ri-delete-bin-line"), n.classList.remove("ri-arrow-go-back-line")); t ? (n.classList.add("hidden"), n.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (n.classList.remove("hidden"), n.classList.add("ri-delete-bin-line"), n.classList.remove("ri-arrow-go-back-line"));
}); });
@@ -2229,8 +2229,8 @@ class $e extends HTMLElement {
const n = i.querySelector(`[data-field="${s}"]`); const n = i.querySelector(`[data-field="${s}"]`);
if (!n) if (!n)
return; return;
const a = `${this._idPrefix}-${t}-${s}`; const l = `${this._idPrefix}-${t}-${s}`;
n.id = a, e.setAttribute("for", a); n.id = l, e.setAttribute("for", l);
}); });
} }
_syncAllSummaries() { _syncAllSummaries() {
@@ -2251,8 +2251,8 @@ class $e extends HTMLElement {
const s = i.querySelector(`[data-field="${e}"]`); const s = i.querySelector(`[data-field="${e}"]`);
if (!s) if (!s)
return; return;
const n = this._readFieldValue(s), a = t.getAttribute("data-summary-hide-empty") === "true" ? t.closest("[data-summary-container]") : null; const n = this._readFieldValue(s), l = t.getAttribute("data-summary-hide-empty") === "true" ? t.closest("[data-summary-container]") : null;
n ? (this._setSummaryContent(t, n), t.classList.remove("text-gray-400"), a && a.classList.remove("hidden")) : (this._setSummaryContent(t, "—"), t.classList.add("text-gray-400"), a && a.classList.add("hidden")); n ? (this._setSummaryContent(t, n), t.classList.remove("text-gray-400"), l && l.classList.remove("hidden")) : (this._setSummaryContent(t, "—"), t.classList.add("text-gray-400"), l && l.classList.add("hidden"));
}), this._syncNewBadge(i); }), this._syncNewBadge(i);
} }
_syncNewBadge(i) { _syncNewBadge(i) {
@@ -2367,7 +2367,7 @@ class Ve extends HTMLElement {
if (!e.ok) if (!e.ok)
return; return;
const s = await e.json(), n = Array.isArray(s == null ? void 0 : s[this._resultKey]) ? s[this._resultKey] : []; const s = await e.json(), n = Array.isArray(s == null ? void 0 : s[this._resultKey]) ? s[this._resultKey] : [];
this._options = n.filter((a) => a && a.id && a.name), this._highlightedIndex = this._options.length > 0 ? 0 : -1, this._renderOptions(), this._options.length > 0 ? this._showList() : this._hideList(); this._options = n.filter((l) => l && l.id && l.name), this._highlightedIndex = this._options.length > 0 ? 0 : -1, this._renderOptions(), this._options.length > 0 ? this._showList() : this._hideList();
} catch (e) { } catch (e) {
if ((e == null ? void 0 : e.name) === "AbortError") if ((e == null ? void 0 : e.name) === "AbortError")
return; return;
@@ -2384,12 +2384,12 @@ class Ve extends HTMLElement {
t.classList.toggle("bg-slate-100", s), t.classList.toggle("text-gray-900", s), t.setAttribute("aria-selected", s ? "true" : "false"); t.classList.toggle("bg-slate-100", s), t.classList.toggle("text-gray-900", s), t.setAttribute("aria-selected", s ? "true" : "false");
const n = document.createElement("div"); const n = document.createElement("div");
if (n.className = [qe, "text-sm font-semibold text-gray-800"].join(" "), n.textContent = i.name, t.appendChild(n), i.detail) { if (n.className = [qe, "text-sm font-semibold text-gray-800"].join(" "), n.textContent = i.name, t.appendChild(n), i.detail) {
const a = document.createElement("div"); const l = document.createElement("div");
a.className = [De, "text-xs text-gray-600"].join(" "), a.textContent = i.detail, t.appendChild(a); l.className = [De, "text-xs text-gray-600"].join(" "), l.textContent = i.detail, t.appendChild(l);
} }
if (i.bio) { if (i.bio) {
const a = document.createElement("div"); const l = document.createElement("div");
a.className = [He, "text-xs text-gray-500"].join(" "), a.textContent = i.bio, t.appendChild(a); l.className = [He, "text-xs text-gray-500"].join(" "), l.textContent = i.bio, t.appendChild(l);
} }
t.addEventListener("click", () => { t.addEventListener("click", () => {
this._selectOption(i); this._selectOption(i);
@@ -2581,7 +2581,7 @@ class Ke extends HTMLElement {
if (Number.isNaN(s)) if (Number.isNaN(s))
throw new Error("Jahr ist ungültig."); throw new Error("Jahr ist ungültig.");
t.year = s; t.year = s;
const n = i.getAll("languages[]").map((g) => g.trim()).filter(Boolean), a = i.getAll("places[]").map((g) => g.trim()).filter(Boolean), { items: r, removedIds: o } = this._collectItems(i), { const n = i.getAll("languages[]").map((g) => g.trim()).filter(Boolean), l = i.getAll("places[]").map((g) => g.trim()).filter(Boolean), { items: r, removedIds: o } = this._collectItems(i), {
relations: d, relations: d,
deleted: c deleted: c
} = this._collectRelations(i, { } = this._collectRelations(i, {
@@ -2604,7 +2604,7 @@ class Ke extends HTMLElement {
last_edited: this._readValue(i, "last_edited"), last_edited: this._readValue(i, "last_edited"),
entry: t, entry: t,
languages: n, languages: n,
places: a, places: l,
items: r, items: r,
deleted_item_ids: o, deleted_item_ids: o,
series_relations: d, series_relations: d,
@@ -2616,14 +2616,14 @@ class Ke extends HTMLElement {
}; };
} }
_collectItems(i) { _collectItems(i) {
const t = i.getAll("items_id[]").map((h) => h.trim()), e = i.getAll("items_owner[]"), s = i.getAll("items_identifier[]"), n = i.getAll("items_location[]"), a = i.getAll("items_media[]"), r = i.getAll("items_annotation[]"), o = i.getAll("items_uri[]"), d = new Set( const t = i.getAll("items_id[]").map((h) => h.trim()), e = i.getAll("items_owner[]"), s = i.getAll("items_identifier[]"), n = i.getAll("items_location[]"), l = i.getAll("items_media[]"), r = i.getAll("items_annotation[]"), o = i.getAll("items_uri[]"), d = new Set(
i.getAll("items_removed[]").map((h) => h.trim()).filter(Boolean) i.getAll("items_removed[]").map((h) => h.trim()).filter(Boolean)
), c = []; ), c = [];
for (let h = 0; h < t.length; h += 1) { for (let h = 0; h < t.length; h += 1) {
const u = t[h] || ""; const u = t[h] || "";
if (u && d.has(u)) if (u && d.has(u))
continue; continue;
const f = (e[h] || "").trim(), m = (s[h] || "").trim(), A = (n[h] || "").trim(), g = (r[h] || "").trim(), G = (o[h] || "").trim(), M = (a[h] || "").trim(); const f = (e[h] || "").trim(), m = (s[h] || "").trim(), A = (n[h] || "").trim(), g = (r[h] || "").trim(), G = (o[h] || "").trim(), M = (l[h] || "").trim();
(u || f || m || A || g || G || M) && c.push({ (u || f || m || A || g || G || M) && c.push({
id: u, id: u,
owner: f, owner: f,
@@ -2641,10 +2641,10 @@ class Ke extends HTMLElement {
} }
_collectRelations(i, { prefix: t, targetField: e }) { _collectRelations(i, { prefix: t, targetField: e }) {
const s = [], n = []; const s = [], n = [];
for (const [a, r] of i.entries()) { for (const [l, r] of i.entries()) {
if (!a.startsWith(`${t}_type[`)) if (!l.startsWith(`${t}_type[`))
continue; continue;
const o = a.slice(a.indexOf("[") + 1, -1), d = `${t}_${e}[${o}]`, c = `${t}_id[${o}]`, h = `${t}_delete[${o}]`, u = `${t}_uncertain[${o}]`, f = (i.get(d) || "").trim(); const o = l.slice(l.indexOf("[") + 1, -1), d = `${t}_${e}[${o}]`, c = `${t}_id[${o}]`, h = `${t}_delete[${o}]`, u = `${t}_uncertain[${o}]`, f = (i.get(d) || "").trim();
if (!f) if (!f)
continue; continue;
const m = (i.get(c) || o).trim(); const m = (i.get(c) || o).trim();
@@ -2667,10 +2667,10 @@ class Ke extends HTMLElement {
return []; return [];
const e = t.querySelectorAll("[data-role='relation-add-row'] [data-rel-row]"), s = []; const e = t.querySelectorAll("[data-role='relation-add-row'] [data-rel-row]"), s = [];
return e.forEach((n) => { return e.forEach((n) => {
const a = n.querySelector(`input[name='${i}_new_id']`), r = n.querySelector(`select[name='${i}_new_type']`), o = n.querySelector(`input[name='${i}_new_uncertain']`); const l = n.querySelector(`input[name='${i}_new_id']`), r = n.querySelector(`select[name='${i}_new_type']`), o = n.querySelector(`input[name='${i}_new_uncertain']`);
if (!a) if (!l)
return; return;
const d = a.value.trim(); const d = l.value.trim();
d && s.push({ d && s.push({
target_id: d, target_id: d,
type: ((r == null ? void 0 : r.value) || "").trim(), type: ((r == null ? void 0 : r.value) || "").trim(),
@@ -2706,13 +2706,13 @@ class Ke extends HTMLElement {
}); });
if (!e.ok) if (!e.ok)
throw new Error("Formular konnte nicht aktualisiert werden."); throw new Error("Formular konnte nicht aktualisiert werden.");
const s = await e.text(), a = new DOMParser().parseFromString(s, "text/html"), r = a.querySelector("#changealmanachform"), o = this.querySelector("#changealmanachform"); const s = await e.text(), l = new DOMParser().parseFromString(s, "text/html"), r = l.querySelector("#changealmanachform"), o = this.querySelector("#changealmanachform");
if (!r || !o) if (!r || !o)
throw new Error("Formular konnte nicht geladen werden."); throw new Error("Formular konnte nicht geladen werden.");
o.replaceWith(r), this._form = r; o.replaceWith(r), this._form = r;
const d = a.querySelector("#user-message"), c = this.querySelector("#user-message"); const d = l.querySelector("#user-message"), c = this.querySelector("#user-message");
d && c && c.replaceWith(d); d && c && c.replaceWith(d);
const h = a.querySelector("#almanach-header-data"), u = this.querySelector("#almanach-header-data"); const h = l.querySelector("#almanach-header-data"), u = this.querySelector("#almanach-header-data");
h && u && u.replaceWith(h), this._initForm(), this._initPlaces(), this._initSaveHandling(); h && u && u.replaceWith(h), this._initForm(), this._initPlaces(), this._initSaveHandling();
} }
} }
@@ -2763,8 +2763,8 @@ class si extends HTMLElement {
e && e.setAttribute("href", `${this._linkBase}${this._pendingItem.id}`); e && e.setAttribute("href", `${this._linkBase}${this._pendingItem.id}`);
const s = i.querySelector("[data-rel-name]"); const s = i.querySelector("[data-rel-name]");
s && (s.textContent = this._pendingItem.name || ""); s && (s.textContent = this._pendingItem.name || "");
const n = i.querySelector("[data-rel-detail]"), a = i.querySelector("[data-rel-detail-container]"), r = this._pendingItem.detail || this._pendingItem.bio || ""; const n = i.querySelector("[data-rel-detail]"), l = i.querySelector("[data-rel-detail-container]"), r = this._pendingItem.detail || this._pendingItem.bio || "";
n && r ? n.textContent = r : a && a.remove(); n && r ? n.textContent = r : l && l.remove();
const o = i.querySelector("[data-rel-new]"); const o = i.querySelector("[data-rel-new]");
o && (o.textContent = this._newLabel); o && (o.textContent = this._newLabel);
const d = i.querySelector("[data-rel-input='type']"); const d = i.querySelector("[data-rel-input='type']");
@@ -2797,8 +2797,8 @@ class si extends HTMLElement {
})); }));
const n = i.querySelector("[data-delete-label]"); const n = i.querySelector("[data-delete-label]");
n && (n.textContent = e.checked ? n.getAttribute("data-delete-active") || "Wird entfernt" : n.getAttribute("data-delete-default") || "Entfernen"); n && (n.textContent = e.checked ? n.getAttribute("data-delete-active") || "Wird entfernt" : n.getAttribute("data-delete-default") || "Entfernen");
const a = i.querySelector("i"); const l = i.querySelector("i");
a && (e.checked ? (a.classList.add("hidden"), a.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (a.classList.remove("hidden"), a.classList.add("ri-delete-bin-line"), a.classList.remove("ri-arrow-go-back-line"))); l && (e.checked ? (l.classList.add("hidden"), l.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (l.classList.remove("hidden"), l.classList.add("ri-delete-bin-line"), l.classList.remove("ri-arrow-go-back-line")));
}), i.addEventListener("mouseenter", () => { }), i.addEventListener("mouseenter", () => {
const t = i.getAttribute("data-delete-toggle"), e = this.querySelector(`#${CSS.escape(t)}`); const t = i.getAttribute("data-delete-toggle"), e = this.querySelector(`#${CSS.escape(t)}`);
if (!e || !e.checked) if (!e || !e.checked)
@@ -2837,21 +2837,21 @@ customElements.define(gi, $e);
customElements.define(bi, Ke); customElements.define(bi, Ke);
customElements.define(Ei, si); customElements.define(Ei, si);
function Si() { function Si() {
const l = window.location.pathname, i = window.location.search, t = l + i; const a = window.location.pathname, i = window.location.search, t = a + i;
return encodeURIComponent(t); return encodeURIComponent(t);
} }
function vi(l = 5e3, i = 100) { function vi(a = 5e3, i = 100) {
return new Promise((t, e) => { return new Promise((t, e) => {
let s = 0; let s = 0;
const n = setInterval(() => { const n = setInterval(() => {
typeof window.QRCode == "function" ? (clearInterval(n), t(window.QRCode)) : (s += i, s >= l && (clearInterval(n), console.error("Timed out waiting for QRCode to become available."), e(new Error("QRCode not available after " + l + "ms. Check if qrcode.min.js is loaded correctly and sets window.QRCode.")))); typeof window.QRCode == "function" ? (clearInterval(n), t(window.QRCode)) : (s += i, s >= a && (clearInterval(n), console.error("Timed out waiting for QRCode to become available."), e(new Error("QRCode not available after " + a + "ms. Check if qrcode.min.js is loaded correctly and sets window.QRCode."))));
}, i); }, i);
}); });
} }
async function Li(l) { async function Li(a) {
const i = await vi(), t = document.getElementById("qr"); const i = await vi(), t = document.getElementById("qr");
t && (t.innerHTML = "", t.classList.add("hidden"), new i(t, { t && (t.innerHTML = "", t.classList.add("hidden"), new i(t, {
text: l, text: a,
width: 1280, width: 1280,
height: 1280, height: 1280,
colorDark: "#000000", colorDark: "#000000",
@@ -2861,31 +2861,31 @@ async function Li(l) {
t.classList.remove("hidden"); t.classList.remove("hidden");
}, 20)); }, 20));
} }
function yi(l) { function yi(a) {
l && (l.addEventListener("focus", (i) => { a && (a.addEventListener("focus", (i) => {
i.preventDefault(), l.select(); i.preventDefault(), a.select();
}), l.addEventListener("mousedown", (i) => { }), a.addEventListener("mousedown", (i) => {
i.preventDefault(), l.select(); i.preventDefault(), a.select();
}), l.addEventListener("mouseup", (i) => { }), a.addEventListener("mouseup", (i) => {
i.preventDefault(), l.select(); i.preventDefault(), a.select();
})), l && (l.addEventListener("focus", () => { })), a && (a.addEventListener("focus", () => {
l.select(); a.select();
}), l.addEventListener("click", () => { }), a.addEventListener("click", () => {
l.select(); a.select();
})); }));
} }
function Ai() { function Ai() {
document.body.addEventListener("htmx:responseError", function(l) { document.body.addEventListener("htmx:responseError", function(a) {
const i = l.detail.requestConfig; const i = a.detail.requestConfig;
if (i.boosted) { if (i.boosted) {
document.body.innerHTML = l.detail.xhr.responseText; document.body.innerHTML = a.detail.xhr.responseText;
const t = l.detail.xhr.responseURL || i.url; const t = a.detail.xhr.responseURL || i.url;
window.history.pushState(null, "", t); window.history.pushState(null, "", t);
} }
}); });
} }
function Ii(l, i) { function Ii(a, i) {
if (!(l instanceof HTMLElement)) { if (!(a instanceof HTMLElement)) {
console.warn("Target must be an HTMLElement."); console.warn("Target must be an HTMLElement.");
return; return;
} }
@@ -2893,8 +2893,8 @@ function Ii(l, i) {
console.warn("Action must be a function."); console.warn("Action must be a function.");
return; return;
} }
const t = l.querySelectorAll(Rt); const t = a.querySelectorAll(Rt);
l.addEventListener("rbichange", (e) => { a.addEventListener("rbichange", (e) => {
for (const s of t) for (const s of t)
if (s.isCurrentlyModified()) { if (s.isCurrentlyModified()) {
i(e.details, !0); i(e.details, !0);
@@ -2903,42 +2903,42 @@ function Ii(l, i) {
i(e.details, !1); i(e.details, !1);
}); });
} }
function R(l) { function R(a) {
if (!(l instanceof HTMLTextAreaElement)) { if (!(a instanceof HTMLTextAreaElement)) {
console.warn("TextareaAutoResize: Provided element is not a textarea."); console.warn("TextareaAutoResize: Provided element is not a textarea.");
return; return;
} }
l.style.height = "auto", l.style.height = `${l.scrollHeight}px`; a.style.height = "auto", a.style.height = `${a.scrollHeight}px`;
} }
function Mt(l) { function Mt(a) {
l.key === "Enter" && l.preventDefault(); a.key === "Enter" && a.preventDefault();
} }
function Bt(l) { function Bt(a) {
if (!(l instanceof HTMLTextAreaElement)) { if (!(a instanceof HTMLTextAreaElement)) {
console.warn("HookupTextareaAutoResize: Provided element is not a textarea."); console.warn("HookupTextareaAutoResize: Provided element is not a textarea.");
return; return;
} }
l.addEventListener("input", () => { a.addEventListener("input", () => {
R(l); R(a);
}); });
} }
function Ti(l) { function Ti(a) {
if (!(l instanceof HTMLTextAreaElement)) { if (!(a instanceof HTMLTextAreaElement)) {
console.warn("DisconnectTextareaAutoResize: Provided element is not a textarea."); console.warn("DisconnectTextareaAutoResize: Provided element is not a textarea.");
return; return;
} }
l.removeEventListener("input", () => { a.removeEventListener("input", () => {
R(l); R(a);
}); });
} }
function Ci(l) { function Ci(a) {
!(l instanceof HTMLTextAreaElement) && l.classList.contains("no-enter") || l.addEventListener("keydown", Mt); !(a instanceof HTMLTextAreaElement) && a.classList.contains("no-enter") || a.addEventListener("keydown", Mt);
} }
function wi(l) { function wi(a) {
!(l instanceof HTMLTextAreaElement) && l.classList.contains("no-enter") || l.removeEventListener("keydown", Mt); !(a instanceof HTMLTextAreaElement) && a.classList.contains("no-enter") || a.removeEventListener("keydown", Mt);
} }
function xi(l, i) { function xi(a, i) {
for (const t of l) for (const t of a)
if (t.type === "childList") { if (t.type === "childList") {
for (const e of t.addedNodes) for (const e of t.addedNodes)
e.nodeType === Node.ELEMENT_NODE && e.matches("textarea") && (Bt(e), R(e)); e.nodeType === Node.ELEMENT_NODE && e.matches("textarea") && (Bt(e), R(e));
@@ -2946,8 +2946,8 @@ function xi(l, i) {
e.nodeType === Node.ELEMENT_NODE && e.matches("textarea") && (wi(e), Ti(e)); e.nodeType === Node.ELEMENT_NODE && e.matches("textarea") && (wi(e), Ti(e));
} }
} }
function ki(l) { function ki(a) {
if (!(l instanceof HTMLFormElement)) { if (!(a instanceof HTMLFormElement)) {
console.warn("FormLoad: Provided element is not a form."); console.warn("FormLoad: Provided element is not a form.");
return; return;
} }
@@ -2957,11 +2957,17 @@ function ki(l) {
const t = document.querySelectorAll("textarea.no-enter"); const t = document.querySelectorAll("textarea.no-enter");
for (const s of t) for (const s of t)
Ci(s); Ci(s);
new MutationObserver(xi).observe(l, { new MutationObserver(xi).observe(a, {
childList: !0, childList: !0,
subtree: !0 subtree: !0
}); });
} }
document.addEventListener("keydown", (a) => {
if (a.key !== "Enter")
return;
const i = a.target;
i instanceof HTMLElement && i.matches("textarea.no-enter") && a.preventDefault();
});
window.ShowBoostedErrors = Ai; window.ShowBoostedErrors = Ai;
window.GenQRCode = Li; window.GenQRCode = Li;
window.SelectableInput = yi; window.SelectableInput = yi;

View File

@@ -142,7 +142,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="title" id="title" class="inputinput" placeholder="" autocomplete="off"> <textarea name="title" id="title" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">
{{- $model.result.Entry.TitleStmt -}} {{- $model.result.Entry.TitleStmt -}}
</textarea> </textarea>
</div> </div>
@@ -173,7 +173,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="subtitle" id="subtitle" class="inputinput" placeholder="" autocomplete="off"> <textarea name="subtitle" id="subtitle" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">
{{- $model.result.Entry.SubtitleStmt -}} {{- $model.result.Entry.SubtitleStmt -}}
</textarea> </textarea>
</div> </div>
@@ -203,7 +203,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="incipit" id="incipit" class="inputinput" placeholder="" autocomplete="off"> <textarea name="incipit" id="incipit" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">
{{- $model.result.Entry.IncipitStmt -}} {{- $model.result.Entry.IncipitStmt -}}
</textarea> </textarea>
</div> </div>
@@ -218,7 +218,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="responsibility_statement" id="responsibility_statement" class="inputinput" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.ResponsibilityStmt -}}</textarea> <textarea name="responsibility_statement" id="responsibility_statement" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.ResponsibilityStmt -}}</textarea>
</div> </div>
<div class="mt-3 inputwrapper {{ if eq $model.result.Entry.PublicationStmt "" }}hidden{{ end }}" data-dm-target="publication"> <div class="mt-3 inputwrapper {{ if eq $model.result.Entry.PublicationStmt "" }}hidden{{ end }}" data-dm-target="publication">
@@ -231,7 +231,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="publication_statement" id="publication_statement" class="inputinput" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.PublicationStmt -}}</textarea> <textarea name="publication_statement" id="publication_statement" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.PublicationStmt -}}</textarea>
</div> </div>
<div class="mt-3 inputwrapper {{ if eq $model.result.Entry.PlaceStmt "" }}hidden{{ end }}" data-dm-target="publication"> <div class="mt-3 inputwrapper {{ if eq $model.result.Entry.PlaceStmt "" }}hidden{{ end }}" data-dm-target="publication">
@@ -244,7 +244,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="place_statement" id="place_statement" class="inputinput" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.PlaceStmt -}}</textarea> <textarea name="place_statement" id="place_statement" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.PlaceStmt -}}</textarea>
</div> </div>
</div-manager> </div-manager>
</div> </div>
@@ -262,7 +262,7 @@ type AlmanachResult struct {
<div class="flex-1 inputwrapper"> <div class="flex-1 inputwrapper">
<label for="edition" class="inputlabel">Ausgabe</label> <label for="edition" class="inputlabel">Ausgabe</label>
<textarea name="edition" id="edition" class="inputinput" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.Edition -}}</textarea> <textarea name="edition" id="edition" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.Edition -}}</textarea>
</div> </div>
</div> </div>
@@ -638,7 +638,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="extent" id="extent" class="inputinput" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.Extent -}}</textarea> <textarea name="extent" id="extent" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.Extent -}}</textarea>
</div> </div>
<div class="mt-3 inputwrapper {{ if eq $model.result.Entry.Dimensions "" }}hidden{{ end }}"> <div class="mt-3 inputwrapper {{ if eq $model.result.Entry.Dimensions "" }}hidden{{ end }}">
@@ -651,7 +651,7 @@ type AlmanachResult struct {
</div> </div>
</div> </div>
<textarea name="dimensions" id="dimensions" class="inputinput" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.Dimensions -}}</textarea> <textarea name="dimensions" id="dimensions" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.Dimensions -}}</textarea>
</div> </div>
</div-manager> </div-manager>
</div> </div>
@@ -673,7 +673,7 @@ type AlmanachResult struct {
<!-- Nachweise - Always visible --> <!-- Nachweise - Always visible -->
<div class="inputwrapper"> <div class="inputwrapper">
<label for="refs" class="inputlabel">Nachweise</label> <label for="refs" class="inputlabel">Nachweise</label>
<textarea name="refs" id="refs" class="inputinput" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.References -}}</textarea> <textarea name="refs" id="refs" class="inputinput no-enter" placeholder="" autocomplete="off" rows="1">{{- $model.result.Entry.References -}}</textarea>
</div> </div>
<!-- Physical Description --> <!-- Physical Description -->

View File

@@ -282,6 +282,19 @@ function FormLoad(form) {
}); });
} }
document.addEventListener("keydown", (event) => {
if (event.key !== "Enter") {
return;
}
const target = event.target;
if (!(target instanceof HTMLElement)) {
return;
}
if (target.matches("textarea.no-enter")) {
event.preventDefault();
}
});
window.ShowBoostedErrors = ShowBoostedErrors; window.ShowBoostedErrors = ShowBoostedErrors;
window.GenQRCode = GenQRCode; window.GenQRCode = GenQRCode;
window.SelectableInput = SelectableInput; window.SelectableInput = SelectableInput;