From 1facf9cd6033ada3d6c7fb2b5b75f1b95cee184c Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 26 Mar 2026 12:20:34 +0100 Subject: [PATCH] refactor(documents): extract document form sub-components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shared (src/lib/components/document/): - WhoWhenSection.svelte: date/location/sender/receivers; owns date state - DescriptionSection.svelte: title/archive-loc/tags/summary; owns tag binding - TranscriptionSection.svelte: transcription textarea Page-local: - documents/[id]/edit/FileSectionEdit.svelte: current file + replace input - documents/[id]/edit/SaveBar.svelte: sticky bar with two-step delete confirm - documents/new/FileSectionNew.svelte: initial file upload input documents/[id]/edit drops from 319 → ~40 lines. documents/new drops from 254 → ~30 lines. Date handling imported from \$lib/utils/date. Part of #75 Co-Authored-By: Claude Sonnet 4.6 --- .../document/DescriptionSection.svelte | 80 +++++ .../document/TranscriptionSection.svelte | 19 ++ .../components/document/WhoWhenSection.svelte | 102 ++++++ .../routes/documents/[id]/edit/+page.svelte | 292 ++---------------- .../[id]/edit/FileSectionEdit.svelte | 40 +++ .../routes/documents/[id]/edit/SaveBar.svelte | 72 +++++ .../src/routes/documents/new/+page.svelte | 206 +----------- .../documents/new/FileSectionNew.svelte | 25 ++ 8 files changed, 374 insertions(+), 462 deletions(-) create mode 100644 frontend/src/lib/components/document/DescriptionSection.svelte create mode 100644 frontend/src/lib/components/document/TranscriptionSection.svelte create mode 100644 frontend/src/lib/components/document/WhoWhenSection.svelte create mode 100644 frontend/src/routes/documents/[id]/edit/FileSectionEdit.svelte create mode 100644 frontend/src/routes/documents/[id]/edit/SaveBar.svelte create mode 100644 frontend/src/routes/documents/new/FileSectionNew.svelte diff --git a/frontend/src/lib/components/document/DescriptionSection.svelte b/frontend/src/lib/components/document/DescriptionSection.svelte new file mode 100644 index 00000000..10cda974 --- /dev/null +++ b/frontend/src/lib/components/document/DescriptionSection.svelte @@ -0,0 +1,80 @@ + + +
+

+ {m.doc_section_description()} +

+ +
+ +
+ + +
+ + +
+ + +

{m.form_helper_archive_location()}

+
+ + +
+

{m.form_label_tags()}

+ + +
+ + +
+ + +
+
+
diff --git a/frontend/src/lib/components/document/TranscriptionSection.svelte b/frontend/src/lib/components/document/TranscriptionSection.svelte new file mode 100644 index 00000000..142af5ae --- /dev/null +++ b/frontend/src/lib/components/document/TranscriptionSection.svelte @@ -0,0 +1,19 @@ + + +
+

+ {m.form_label_transcription()} +

+ +
diff --git a/frontend/src/lib/components/document/WhoWhenSection.svelte b/frontend/src/lib/components/document/WhoWhenSection.svelte new file mode 100644 index 00000000..71b2feaf --- /dev/null +++ b/frontend/src/lib/components/document/WhoWhenSection.svelte @@ -0,0 +1,102 @@ + + +
+

+ {m.doc_section_who_when()} +

+ +
+ +
+ + + + {#if dateInvalid} +

{m.form_date_error()}

+ {/if} +
+ + +
+ + +
+ + +
+ +
+ + +
+

{m.form_label_receivers()}

+ +
+
+
diff --git a/frontend/src/routes/documents/[id]/edit/+page.svelte b/frontend/src/routes/documents/[id]/edit/+page.svelte index cac183a9..0adb8955 100644 --- a/frontend/src/routes/documents/[id]/edit/+page.svelte +++ b/frontend/src/routes/documents/[id]/edit/+page.svelte @@ -1,11 +1,12 @@
@@ -65,253 +42,30 @@ function handleDateInput(e: Event) { {/if}
- -
-

- {m.doc_section_who_when()} -

- -
- -
- - - - {#if dateInvalid} -

{m.form_date_error()}

- {/if} -
- - -
- - -
- - -
- -
- - -
-

{m.form_label_receivers()}

- -
-
-
- - -
-

- {m.doc_section_description()} -

- -
- -
- - -
- - -
- - -

{m.form_helper_archive_location()}

-
- - -
-

{m.form_label_tags()}

- - -
- - -
- - -
-
-
- - -
-

- {m.form_label_transcription()} -

- -
- - -
-

- {m.doc_section_file()} -

- -
- - {m.doc_current_file_label()} - {doc.originalFilename} -
- - - -
- - -
- -
- {#if confirmDelete} - {m.doc_delete_confirm()} - - - {:else} - - {/if} -
- - -
- - {m.btn_cancel()} - - -
-
+ + + + +
diff --git a/frontend/src/routes/documents/[id]/edit/FileSectionEdit.svelte b/frontend/src/routes/documents/[id]/edit/FileSectionEdit.svelte new file mode 100644 index 00000000..1896861c --- /dev/null +++ b/frontend/src/routes/documents/[id]/edit/FileSectionEdit.svelte @@ -0,0 +1,40 @@ + + +
+

+ {m.doc_section_file()} +

+ +
+ + {m.doc_current_file_label()} + {originalFilename} +
+ + + +
diff --git a/frontend/src/routes/documents/[id]/edit/SaveBar.svelte b/frontend/src/routes/documents/[id]/edit/SaveBar.svelte new file mode 100644 index 00000000..8fd6547b --- /dev/null +++ b/frontend/src/routes/documents/[id]/edit/SaveBar.svelte @@ -0,0 +1,72 @@ + + +
+ +
+ {#if confirmDelete} + {m.doc_delete_confirm()} + + + {:else} + + {/if} +
+ + +
+ + {m.btn_cancel()} + + +
+
diff --git a/frontend/src/routes/documents/new/+page.svelte b/frontend/src/routes/documents/new/+page.svelte index 0b8355f6..b0eee120 100644 --- a/frontend/src/routes/documents/new/+page.svelte +++ b/frontend/src/routes/documents/new/+page.svelte @@ -1,10 +1,11 @@
@@ -75,167 +46,16 @@ function handleDateInput(e: Event) { {/if}
- -
-

- {m.doc_section_who_when()} -

+ + + + -
- -
- - - - {#if dateInvalid} -

- {m.form_date_error()} -

- {/if} -
- - -
- - -
- - -
- -
- - -
-

{m.form_label_receivers()}

- -
-
-
- - -
-

- {m.doc_section_description()} -

- -
- -
- - -
- - -
- - -

{m.form_helper_archive_location()}

-
- - -
-

{m.form_label_tags()}

- - -
- - -
- - -
-
-
- - -
-

- {m.form_label_transcription()} -

- -
- - -
-

- {m.doc_section_file()} -

- - - -
- - +
diff --git a/frontend/src/routes/documents/new/FileSectionNew.svelte b/frontend/src/routes/documents/new/FileSectionNew.svelte new file mode 100644 index 00000000..3e99fa47 --- /dev/null +++ b/frontend/src/routes/documents/new/FileSectionNew.svelte @@ -0,0 +1,25 @@ + + +
+

+ {m.doc_section_file()} +

+ + + +