Halte Kapitel am gewaehlten Vorgang fest und raeume die Arbeitsflaeche, damit Ziel, Auswahl und Rechte nicht an der Akte haengen bleiben.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
67d48378c9
commit
cafa4e8b92
8 files changed
+523
-132
No files matched your search
@@ -17,6 +17,51 @@ export function formatStamp(value) {
|
||||
return `${formatDate(day)} ${time.replace("Z", " UTC").slice(0, 8)}`.trim();
|
||||
}
|
||||
|
||||
export function selectionOf(params) {
|
||||
return {
|
||||
scope: params.get("bereich") || "all",
|
||||
chapterId: params.get("kapitel") || "",
|
||||
};
|
||||
}
|
||||
|
||||
export function writeSelection(params, setParams, scope, chapterId) {
|
||||
const next = new URLSearchParams(params);
|
||||
if (!scope || scope === "all") next.delete("bereich");
|
||||
else next.set("bereich", scope);
|
||||
if (chapterId) next.set("kapitel", chapterId);
|
||||
else next.delete("kapitel");
|
||||
setParams(next, { replace: true });
|
||||
}
|
||||
|
||||
export function writeChapter(params, setParams, chapterId) {
|
||||
const next = new URLSearchParams(params);
|
||||
if (chapterId) next.set("kapitel", chapterId);
|
||||
else next.delete("kapitel");
|
||||
setParams(next, { replace: true });
|
||||
}
|
||||
|
||||
export function withSelection(href, params) {
|
||||
const url = new URL(href, "http://tsumugu.local");
|
||||
for (const key of ["bereich", "kapitel"]) {
|
||||
const value = params.get(key);
|
||||
if (value && !url.searchParams.has(key)) url.searchParams.set(key, value);
|
||||
}
|
||||
const search = url.searchParams.toString();
|
||||
return `${url.pathname}${search ? `?${search}` : ""}`;
|
||||
}
|
||||
|
||||
export function TargetLine({ label, chapters = [], chapterId = "", chapterTitle = "" }) {
|
||||
if (!label) return null;
|
||||
const chapter = chapters.find((item) => item.id === chapterId);
|
||||
const namedChapter = chapter?.title || chapterTitle;
|
||||
return (
|
||||
<p className="target-line">
|
||||
Ziel: <strong>{label}</strong>
|
||||
{namedChapter ? <> · Kapitel <strong>{namedChapter}</strong></> : null}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
export function kindLabel(kind) {
|
||||
if (kind === "note") return "Notiz";
|
||||
if (kind === "file") return "Datei";
|
||||
@@ -417,20 +462,16 @@ export function ContentBoard({
|
||||
return (
|
||||
<div className="contents" ref={rootRef}>
|
||||
{canSort ? (
|
||||
<div className="order-bar" role="group" aria-label="Ordnung der Inhalte">
|
||||
<button type="button" className={record.content_order !== "position" && direction === "asc" ? "" : "quiet"} disabled={pending} onClick={() => saveMode("date", "asc")}>
|
||||
Fachliches Datum, aufsteigend
|
||||
</button>
|
||||
<button type="button" className={record.content_order !== "position" && direction === "desc" ? "" : "quiet"} disabled={pending} onClick={() => saveMode("date", "desc")}>
|
||||
Fachliches Datum, absteigend
|
||||
</button>
|
||||
<button type="button" className={custom ? "" : "quiet"} disabled={pending} onClick={() => saveMode("position", direction)}>
|
||||
Eigene Reihenfolge
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<p className="muted">{sortable ? (custom ? "Eigene Reihenfolge" : `Fachliches Datum, ${direction === "desc" ? "absteigend" : "aufsteigend"}`) : "Lesesicht nach fachlichem Datum. Zum Ordnen einen einzelnen Bereich wählen."}</p>
|
||||
)}
|
||||
<OrderChoice
|
||||
mode={custom ? "position" : "date"}
|
||||
direction={direction}
|
||||
disabled={pending}
|
||||
allowPosition
|
||||
onChange={saveMode}
|
||||
/>
|
||||
) : sortable ? (
|
||||
<p className="muted">{custom ? "Eigene Reihenfolge" : `Fachliches Datum, ${direction === "desc" ? "absteigend" : "aufsteigend"}`}</p>
|
||||
) : null}
|
||||
{pending ? <p className="muted">Ordnung wird gespeichert …</p> : null}
|
||||
<ErrorNote error={error} />
|
||||
{source.length || chapters.length ? (
|
||||
@@ -473,25 +514,28 @@ export function ContentBoard({
|
||||
{text ? <span className="preview-row__text">{text}</span> : null}
|
||||
{binding.origin ? <span className="preview-row__origin">{binding.origin}{binding.shared ? " · weitere Einbindung" : ""}</span> : null}
|
||||
</Link>
|
||||
{canSort && (custom || chapters.length) ? (
|
||||
<details className="row-menu">
|
||||
<summary>{custom ? "Ordnen" : "Einordnen"}</summary>
|
||||
{custom ? (
|
||||
<>
|
||||
{(canSort && custom) || (canSort && chapters.length) ? (
|
||||
<div className="preview-row__actions">
|
||||
{canSort && custom ? (
|
||||
<details className="row-menu">
|
||||
<summary>Reihenfolge</summary>
|
||||
<button type="button" aria-label={`${element.title} nach oben`} disabled={pending || index === 0} onClick={() => move(binding.id, -1)}>Nach oben</button>
|
||||
<button type="button" aria-label={`${element.title} nach unten`} disabled={pending || index === section.items.length - 1} onClick={() => move(binding.id, 1)}>Nach unten</button>
|
||||
</>
|
||||
</details>
|
||||
) : null}
|
||||
{chapters.length ? (
|
||||
<label>
|
||||
In Kapitel einordnen
|
||||
<select value={binding.chapter_id || ""} disabled={pending} onChange={(event) => placeChapter(binding.id, event.target.value)}>
|
||||
<option value="">Ohne Kapitel</option>
|
||||
{chapters.map((chapter) => <option key={chapter.id} value={chapter.id}>{chapter.title}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
{canSort && chapters.length ? (
|
||||
<details className="row-menu">
|
||||
<summary>In Kapitel einordnen</summary>
|
||||
<label>
|
||||
Kapitel
|
||||
<select value={binding.chapter_id || ""} disabled={pending} onChange={(event) => placeChapter(binding.id, event.target.value)}>
|
||||
<option value="">Ohne Kapitel</option>
|
||||
{chapters.map((chapter) => <option key={chapter.id} value={chapter.id}>{chapter.title}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
</details>
|
||||
) : null}
|
||||
</details>
|
||||
</div>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
@@ -507,6 +551,29 @@ export function ContentBoard({
|
||||
);
|
||||
}
|
||||
|
||||
export function OrderChoice({ mode, direction, disabled, allowPosition = false, onChange }) {
|
||||
const value = mode === "position" ? "position" : direction === "desc" ? "date-desc" : "date-asc";
|
||||
return (
|
||||
<label className="order-choice">
|
||||
<span>Ordnung</span>
|
||||
<select
|
||||
aria-label="Ordnung der Inhalte"
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onChange={(event) => {
|
||||
const next = event.target.value;
|
||||
if (next === "position") onChange("position", direction === "desc" ? "desc" : "asc");
|
||||
else onChange("date", next === "date-desc" ? "desc" : "asc");
|
||||
}}
|
||||
>
|
||||
<option value="date-asc">Fachliches Datum, aufsteigend</option>
|
||||
<option value="date-desc">Fachliches Datum, absteigend</option>
|
||||
{allowPosition ? <option value="position">Eigene Reihenfolge</option> : null}
|
||||
</select>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
export function CourseList({ items }) {
|
||||
if (!items) return <p className="muted">Verlauf wird geladen …</p>;
|
||||
if (!items.length) return <p className="muted">Noch kein fachlicher Verlauf.</p>;
|
||||
|
||||
Reference in new issue
Block a user