mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-22 18:12:18 -05:00
Fold mirrored extra fields into the grid above them
In the spool view the filament's custom fields sat under their own "Extra fields" heading, styled exactly like the FILAMENT and MANUFACTURER headings beside it, so it read as a third peer section rather than as more of the filament. Emit those rows straight into the preceding field grid instead. Only the read-only mirrors change; an entity's own extra-fields section keeps its heading, which is also where the "Manage fields" link lives.
This commit is contained in:
1 parent
35cc1c7d43
commit
dadc2ba760
3 files changed
+28
-16
No files matched your search
@@ -22,8 +22,16 @@
|
||||
* another entity, where an empty section is just noise.
|
||||
*/
|
||||
manage?: boolean;
|
||||
/**
|
||||
* Emit only the field rows — no section header, no grid of its own — so the
|
||||
* caller can drop them straight into its own <FieldGrid>. Used by the
|
||||
* read-only mirrors of another entity, where a second "Extra fields" heading
|
||||
* in the same panel reads as a peer section rather than as more of the
|
||||
* entity above it (#992).
|
||||
*/
|
||||
headless?: boolean;
|
||||
}
|
||||
let { entity, extra, onchange, readonly = false, manage = false }: Props = $props();
|
||||
let { entity, extra, onchange, readonly = false, manage = false, headless = false }: Props = $props();
|
||||
|
||||
$effect(() => {
|
||||
fields.ensure(entity);
|
||||
@@ -43,20 +51,21 @@
|
||||
>
|
||||
{/snippet}
|
||||
|
||||
{#if show}
|
||||
{#snippet rows()}
|
||||
{#each defs as f (f.key)}
|
||||
<Field label={f.name}>
|
||||
<ExtraFieldInput field={f} value={extra[f.key]} onchange={(json) => onchange(f.key, json)} {readonly} />
|
||||
</Field>
|
||||
{/each}
|
||||
{/snippet}
|
||||
|
||||
{#if headless}
|
||||
{@render rows()}
|
||||
{:else if show}
|
||||
<SectionLabel right={manage ? manageLink : undefined}>{m['settings.extraFields.tab']()}</SectionLabel>
|
||||
{#if defs.length}
|
||||
<FieldGrid>
|
||||
{#each defs as f (f.key)}
|
||||
<Field label={f.name}>
|
||||
<ExtraFieldInput
|
||||
field={f}
|
||||
value={extra[f.key]}
|
||||
onchange={(json) => onchange(f.key, json)}
|
||||
{readonly}
|
||||
/>
|
||||
</Field>
|
||||
{/each}
|
||||
{@render rows()}
|
||||
</FieldGrid>
|
||||
{:else}
|
||||
<div class="none">{m['inspector.noExtraFields']()}</div>
|
||||
|
||||
@@ -376,10 +376,12 @@
|
||||
{/if}
|
||||
<Field label={m['filament.fields.registered']()}>{filament.registeredLabel}</Field>
|
||||
<Field label={m['filament.fields.comment']()}><LinkedText text={filament.comment} /></Field>
|
||||
<!-- The filament's own custom fields, as further rows of this grid: a
|
||||
second "Extra fields" heading here would read as a peer of FILAMENT
|
||||
and MANUFACTURER rather than as more of the filament. -->
|
||||
<ExtraFieldsSection entity="filament" extra={filament.extra} onchange={() => {}} readonly headless />
|
||||
</FieldGrid>
|
||||
|
||||
<ExtraFieldsSection entity="filament" extra={filament.extra} onchange={() => {}} readonly />
|
||||
|
||||
<VendorSection
|
||||
{vendor}
|
||||
href={vendor ? params.selectHref(page.url.searchParams, 'vendor', vendor.id) : undefined}
|
||||
|
||||
@@ -47,9 +47,10 @@
|
||||
{/if}
|
||||
<Field label={m['vendor.fields.registered']()}>{vendor.registeredLabel}</Field>
|
||||
<Field label={m['vendor.fields.comment']()}><LinkedText text={vendor.comment} /></Field>
|
||||
<!-- Rows of this same grid rather than their own headed section — see the
|
||||
`headless` prop's note in ExtraFieldsSection. -->
|
||||
<ExtraFieldsSection entity="vendor" extra={vendor.extra} onchange={() => {}} readonly headless />
|
||||
</FieldGrid>
|
||||
|
||||
<ExtraFieldsSection entity="vendor" extra={vendor.extra} onchange={() => {}} readonly />
|
||||
{:else}
|
||||
<div class="none">{m['add.noManufacturer']()}</div>
|
||||
{/if}
|
||||
|
||||
Reference in new issue
Block a user