fix(data-store-form): add change detection, fix button class, restore textarea height

- Add original_obj prop + has_changes bindable output to element_data_store_form
- Derive has_changes by comparing each draft field to original_obj; null = always dirty (new record)
- Wire bind:has_changes + original_obj={is_new ? null : editing_obj} in management page
- Fix Save button: preset-filled-primary → preset-filled-primary-500 (matches element_data_store)
- Disable Save when !has_changes; block modal outsideclose when changes are pending
- Restore textarea rows 10 → 15 to match element_data_store.svelte

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-06-17 15:30:42 -04:00
parent ae3bc7e085
commit e321a2c4c5
2 changed files with 45 additions and 5 deletions

View File

@@ -71,6 +71,7 @@ let draft_sort = $state('');
let draft_group = $state('');
let draft_notes = $state('');
let submit_status = $state<'idle' | 'processing' | 'saved' | 'error'>('idle');
let has_changes = $state(false); // bound from form component — true when any draft differs from editing_obj
// ── Bulk rename state ─────────────────────────────────────────────────────────
let show_bulk_rename = $state(false);
@@ -734,7 +735,7 @@ function content_preview(ds: ae_DataStore): string {
title={is_new ? 'New Data Store' : `Edit: ${editing_obj?.code ?? ''}`}
bind:open={show_edit}
autoclose={false}
outsideclose={submit_status !== 'processing'}
outsideclose={!has_changes}
size="xl"
class="w-full max-w-5xl">
@@ -758,7 +759,9 @@ function content_preview(ds: ae_DataStore): string {
bind:draft_sort
bind:draft_group
bind:draft_notes
{is_new} />
{is_new}
original_obj={is_new ? null : editing_obj}
bind:has_changes />
{/key}
<!-- Footer actions -->
@@ -785,8 +788,8 @@ function content_preview(ds: ae_DataStore): string {
</button>
<button
type="submit"
class="btn preset-filled-primary"
disabled={submit_status === 'processing'}
class="btn preset-filled-primary-500"
disabled={!has_changes || submit_status === 'processing'}
title={is_new ? 'Create new data store' : 'Save changes'}>
{#if submit_status === 'processing'}
<LoaderCircle size={14} class="mr-2 animate-spin" />