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