feat(documents): replace documentLocation with archiveBox/archiveFolder in edit form
This commit is contained in:
@@ -11,7 +11,8 @@ let {
|
||||
archiveBox = $bindable(''),
|
||||
archiveFolder = $bindable(''),
|
||||
initialTitle = '',
|
||||
initialDocumentLocation = '',
|
||||
initialArchiveBox = '',
|
||||
initialArchiveFolder = '',
|
||||
initialSummary = '',
|
||||
titleRequired = false,
|
||||
suggestedTitle = '',
|
||||
@@ -24,7 +25,8 @@ let {
|
||||
archiveBox?: string;
|
||||
archiveFolder?: string;
|
||||
initialTitle?: string;
|
||||
initialDocumentLocation?: string;
|
||||
initialArchiveBox?: string;
|
||||
initialArchiveFolder?: string;
|
||||
initialSummary?: string;
|
||||
titleRequired?: boolean;
|
||||
suggestedTitle?: string;
|
||||
@@ -41,7 +43,8 @@ let {
|
||||
let titleDirty = $state(false);
|
||||
onMount(() => {
|
||||
if (!currentTitle && initialTitle) currentTitle = initialTitle;
|
||||
if (!documentLocation && initialDocumentLocation) documentLocation = initialDocumentLocation;
|
||||
if (!archiveBox && initialArchiveBox) archiveBox = initialArchiveBox;
|
||||
if (!archiveFolder && initialArchiveFolder) archiveFolder = initialArchiveFolder;
|
||||
});
|
||||
const titleValue = $derived(titleDirty ? currentTitle : suggestedTitle || currentTitle);
|
||||
</script>
|
||||
@@ -110,55 +113,36 @@ const titleValue = $derived(titleDirty ? currentTitle : suggestedTitle || curren
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Aufbewahrungsort (optional) -->
|
||||
<div data-testid="description-document-location">
|
||||
<label for="documentLocation" class="mb-1 block text-sm font-medium text-ink-2"
|
||||
>{m.form_label_archive_location()}
|
||||
<!-- Karton -->
|
||||
<div data-testid="description-archive-box">
|
||||
<label for="archiveBox" class="mb-1 block text-sm font-medium text-ink-2">
|
||||
{m.form_label_archive_box()}
|
||||
{#if editMode}<FieldLabelBadge variant="replace" />{/if}
|
||||
</label>
|
||||
<input
|
||||
id="documentLocation"
|
||||
id="archiveBox"
|
||||
type="text"
|
||||
name="documentLocation"
|
||||
bind:value={documentLocation}
|
||||
placeholder={m.form_placeholder_archive_location()}
|
||||
name="archiveBox"
|
||||
bind:value={archiveBox}
|
||||
class="block w-full rounded border border-line p-2 text-sm shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-ink-3">{m.form_helper_archive_location()}</p>
|
||||
<p class="mt-1 text-xs text-ink-3">{m.form_helper_archive_box()}</p>
|
||||
</div>
|
||||
|
||||
{#if editMode}
|
||||
<!-- Karton (only in editMode — bulk-editable replace) -->
|
||||
<div data-testid="description-archive-box">
|
||||
<label for="archiveBox" class="mb-1 block text-sm font-medium text-ink-2">
|
||||
{m.form_label_archive_box()}
|
||||
<FieldLabelBadge variant="replace" />
|
||||
</label>
|
||||
<input
|
||||
id="archiveBox"
|
||||
type="text"
|
||||
name="archiveBox"
|
||||
bind:value={archiveBox}
|
||||
class="block w-full rounded border border-line p-2 text-sm shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-ink-3">{m.form_helper_archive_box()}</p>
|
||||
</div>
|
||||
|
||||
<!-- Mappe (only in editMode — bulk-editable replace) -->
|
||||
<div data-testid="description-archive-folder">
|
||||
<label for="archiveFolder" class="mb-1 block text-sm font-medium text-ink-2">
|
||||
{m.form_label_archive_folder()}
|
||||
<FieldLabelBadge variant="replace" />
|
||||
</label>
|
||||
<input
|
||||
id="archiveFolder"
|
||||
type="text"
|
||||
name="archiveFolder"
|
||||
bind:value={archiveFolder}
|
||||
class="block w-full rounded border border-line p-2 text-sm shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-ink-3">{m.form_helper_archive_folder()}</p>
|
||||
</div>
|
||||
{/if}
|
||||
<!-- Mappe -->
|
||||
<div data-testid="description-archive-folder">
|
||||
<label for="archiveFolder" class="mb-1 block text-sm font-medium text-ink-2">
|
||||
{m.form_label_archive_folder()}
|
||||
{#if editMode}<FieldLabelBadge variant="replace" />{/if}
|
||||
</label>
|
||||
<input
|
||||
id="archiveFolder"
|
||||
type="text"
|
||||
name="archiveFolder"
|
||||
bind:value={archiveFolder}
|
||||
class="block w-full rounded border border-line p-2 text-sm shadow-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-ink-3">{m.form_helper_archive_folder()}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -21,19 +21,10 @@ describe('DescriptionSection — onMount seeding (Felix B1/B2 fix regression fen
|
||||
expect(titleInput.value).toBe('Parent Title');
|
||||
});
|
||||
|
||||
it('pre-fills the documentLocation input from initialDocumentLocation', async () => {
|
||||
render(DescriptionSection, { initialDocumentLocation: 'Schrank 3, Mappe B' });
|
||||
const locationInput = document.querySelector('input#documentLocation') as HTMLInputElement;
|
||||
expect(locationInput.value).toBe('Schrank 3, Mappe B');
|
||||
});
|
||||
|
||||
it('does not stomp a parent-bound documentLocation that is already non-empty', async () => {
|
||||
render(DescriptionSection, {
|
||||
documentLocation: 'Bound Value',
|
||||
initialDocumentLocation: 'Should Not Win'
|
||||
});
|
||||
const locationInput = document.querySelector('input#documentLocation') as HTMLInputElement;
|
||||
expect(locationInput.value).toBe('Bound Value');
|
||||
it('always renders archiveBox + archiveFolder fields regardless of editMode', async () => {
|
||||
render(DescriptionSection, { editMode: false });
|
||||
expect(document.querySelector('[data-testid="description-archive-box"]')).not.toBeNull();
|
||||
expect(document.querySelector('[data-testid="description-archive-folder"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders the editMode-only archiveBox + archiveFolder fields when editMode=true', async () => {
|
||||
@@ -42,9 +33,25 @@ describe('DescriptionSection — onMount seeding (Felix B1/B2 fix regression fen
|
||||
expect(document.querySelector('[data-testid="description-archive-folder"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('hides the editMode-only archive fields when editMode=false', async () => {
|
||||
render(DescriptionSection, { editMode: false });
|
||||
expect(document.querySelector('[data-testid="description-archive-box"]')).toBeNull();
|
||||
expect(document.querySelector('[data-testid="description-archive-folder"]')).toBeNull();
|
||||
it('pre-fills archiveBox from initialArchiveBox when archiveBox is empty', async () => {
|
||||
render(DescriptionSection, { initialArchiveBox: 'K-03', hideTitle: true });
|
||||
const input = document.querySelector('input#archiveBox') as HTMLInputElement;
|
||||
expect(input.value).toBe('K-03');
|
||||
});
|
||||
|
||||
it('pre-fills archiveFolder from initialArchiveFolder when archiveFolder is empty', async () => {
|
||||
render(DescriptionSection, { initialArchiveFolder: 'Mappe B', hideTitle: true });
|
||||
const input = document.querySelector('input#archiveFolder') as HTMLInputElement;
|
||||
expect(input.value).toBe('Mappe B');
|
||||
});
|
||||
|
||||
it('does not stomp a parent-bound archiveBox that is already non-empty', async () => {
|
||||
render(DescriptionSection, {
|
||||
archiveBox: 'Parent Value',
|
||||
initialArchiveBox: 'Should Not Win',
|
||||
hideTitle: true
|
||||
});
|
||||
const input = document.querySelector('input#archiveBox') as HTMLInputElement;
|
||||
expect(input.value).toBe('Parent Value');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user