+a few improvements

This commit is contained in:
Simon Martens
2026-01-16 20:48:27 +01:00
parent c3d295f420
commit ce4f735496
2 changed files with 31 additions and 7 deletions

View File

@@ -132,11 +132,23 @@
<span data-role="contents-htmx-label">Eintrag wird geladen</span>
</div>
<input type="hidden" name="csrf_token" value="{{ $model.csrf_token }}" data-role="csrf-token" />
<div class="flex items-center justify-end px-4">
<div class="flex items-center justify-end gap-2 px-4">
<button type="button" class="resetbutton w-auto px-3 py-2 flex items-center gap-2" data-role="contents-collapse-all" data-state="expanded">
<i class="ri-arrow-up-s-line" data-role="contents-collapse-all-icon"></i>
<span data-role="contents-collapse-all-label">Alle Eintraege einklappen</span>
</button>
<button
type="button"
class="resetbutton w-auto px-3 py-2 flex items-center gap-2"
data-loading-label="Eintrag wird geladen"
hx-post="/almanach/{{ $model.result.Entry.MusenalmID }}/contents/insert"
hx-target="[data-role='contents-list']"
hx-swap="beforeend"
hx-include="[data-role='csrf-token']"
hx-vals='{"position":"after","content_id":""}'>
<i class="ri-add-line"></i>
<span>Eintrag anlegen</span>
</button>
</div>
<div class="flex flex-col gap-1"
data-role="contents-list"
@@ -367,6 +379,14 @@
}
});
};
const preserveScroll = (action) => {
const top = window.scrollY;
const left = window.scrollX;
action();
requestAnimationFrame(() => {
window.scrollTo(left, top);
});
};
enterEditMode = (item) => {
const view = item.querySelector("[data-role='content-view']");
@@ -456,9 +476,11 @@
if (item.classList.contains("data-editing") || item.dataset.contentTemp === "true") {
return;
}
preserveScroll(() => {
setCollapsed(item.dataset.collapsed !== "true");
updateCollapseAllLabel();
});
});
}
if (header) {
@@ -472,9 +494,11 @@
if (event.target.closest("button, a, select, input, textarea")) {
return;
}
preserveScroll(() => {
setCollapsed(item.dataset.collapsed !== "true");
updateCollapseAllLabel();
});
});
}
if (editButton) {

View File

@@ -37,13 +37,13 @@
{{- if $content.MusenalmType -}}
<span class="flex flex-wrap gap-1 text-gray-700 font-normal">
{{- range $i, $t := $content.MusenalmType -}}
<span class="bg-stone-100 px-1.5 py-0.5 rounded text-sm font-semibold">{{- $t -}}</span>
<span class="bg-slate-200 text-slate-900 px-1.5 py-0.5 rounded text-sm font-semibold shadow-sm" data-role="content-type-pill">{{- $t -}}</span>
{{- end -}}
</span>
{{- end -}}
<div class="hidden flex flex-wrap items-baseline gap-2 text-gray-800" data-role="content-collapsed-summary">
{{- if $content.Extent -}}
<span class="text-sm font-semibold text-gray-700">S. {{- $content.Extent -}}</span>
<span class="bg-slate-200 text-slate-900 px-1.5 py-0.5 rounded text-sm font-semibold shadow-sm">S. {{- $content.Extent -}}</span>
{{- end -}}
{{- if $content.PreferredTitle -}}
<span class="text-sm font-semibold">{{- $content.PreferredTitle -}}</span>