From 3e83890932651c3efbd2d22c628f17b8ecc9a0ad Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Fri, 13 Feb 2026 16:07:21 -0500 Subject: [PATCH] feat(framework): implement AE Obj Field Editor v3 and test playground - Created consolidated AE_Obj_Field_Editor_V3 component using Svelte 5 Runes. - Standardized on V3 CRUD API (PATCH /v3/crud/{obj_type}/{obj_id}). - Implemented local state guards to prevent reactivity loops. - Added support for multiple field types (text, textarea, select, checkbox, tiptap). - Created a dedicated testing playground with real Demo account data. - Updated the PROJECT_AE_OBJECT_FIELD_EDITOR_V3_UPGRADE.md plan. --- ...OJECT_AE_OBJECT_FIELD_EDITOR_V3_UPGRADE.md | 73 +++-- .../element_ae_obj_field_editor_v3.svelte | 285 ++++++++++++++++++ .../ae_obj_field_editor_v3/+page.svelte | 222 ++++++++++++++ 3 files changed, 542 insertions(+), 38 deletions(-) create mode 100644 src/lib/elements/element_ae_obj_field_editor_v3.svelte create mode 100644 src/routes/testing/ae_obj_field_editor_v3/+page.svelte diff --git a/documentation/PROJECT_AE_OBJECT_FIELD_EDITOR_V3_UPGRADE.md b/documentation/PROJECT_AE_OBJECT_FIELD_EDITOR_V3_UPGRADE.md index 8194c2f6..cfc19bcb 100644 --- a/documentation/PROJECT_AE_OBJECT_FIELD_EDITOR_V3_UPGRADE.md +++ b/documentation/PROJECT_AE_OBJECT_FIELD_EDITOR_V3_UPGRADE.md @@ -1,49 +1,46 @@ -# Project Plan: Aether CRUD v2 Component Refactor (V3 Alignment) +# Project Plan: Aether AE Obj Field Editor v3 (Consolidated) -> **Status:** Draft / Initial Planning -> **Date:** February 9, 2026 -> **Target Component:** `src/lib/elements/element_ae_crud_v2.svelte` +> **Status:** Active / Planning Refinement +> **Date:** February 13, 2026 +> **Target Component:** `src/lib/elements/element_ae_obj_field_editor_v3.svelte` +> **Replaces:** `element_ae_crud.svelte` and `element_ae_crud_v2.svelte` ## 1. Overview -The `Element_ae_crud_v2` component is the central property editor for the Aether platform. Following major backend (FastAPI V3) and frontend (Svelte 5) upgrades, this component requires a systematic refactor to restore full functionality, improve performance, and enhance the developer experience (DX). - -The goal is a **near drop-in replacement** that maintains the existing API while leveraging modern platform standards. +Consolidate the legacy CRUD components into a single, high-performance "Aether Object Field Editor" (v3). This component will be the standard for single-property editing across the platform, fully aligned with the FastAPI V3 CRUD patterns and Svelte 5 Runes. ## 2. Strategic Objectives -- **API Alignment:** Fully integrate with the V3 CRUD pattern (`PATCH /v3/crud/{obj_type}/{obj_id}`). -- **Svelte 5 Optimization:** Migrate fully to Runes (`$state`, `$derived`, `$effect`, `$props`) for cleaner reactivity and improved prop-binding. -- **Mobile-First UX:** Redesign the edit popover/form for better accessibility on smaller screens. -- **Robust Error Handling:** Standardize error bubbling and validation feedback. -- **Type Safety:** Ensure all props and internal state are strictly typed. +- **Consolidation:** Retire `v1` and `v2` components in favor of a single, unified codebase. +- **API Alignment:** Native support for `PATCH /v3/crud/{obj_type}/{obj_id}`. +- **Svelte 5 Runes:** Pure `$props`, `$state`, and `$derived` implementation. No legacy imports. +- **Callback Pattern:** Replace `createEventDispatcher` with callback props (`on_patch`, `on_success`, `on_error`). +- **Iconography:** Standardize on **Lucide-Svelte**. +- **Mobile-First:** Improved "Tap to Edit" targets and mobile-responsive popovers. -## 3. Current Version Audit (`v2`) -- **Strengths:** Support for multiple field types (text, textarea, tiptap, select); SWR-ready via `object_reload`. -- **Weaknesses:** Fragmented CSS; manual state synchronization logic; inconsistent button styling; limited feedback for patch failures. +## 3. Implementation Phases -## 4. Implementation Phases +### Phase 1: Foundation & Reactivity +- [ ] Create the new `v3` component shell. +- [ ] Implement strict TypeScript interface for Props. +- [ ] Use `$state` for local "draft" values to prevent reactivity loops with the global store. +- [ ] Implement the `handle_patch` logic using the central `api.patch` helper. -### Phase 1: Core Reactivity & API -- [ ] Replace `let` exports with `$props()` destructuring. -- [ ] Implement `$state` for internal values and patch status. -- [ ] Standardize the `handle_obj_field_patch` function to use the central `api.patch` helper. -- [ ] Verify Triple-ID mapping within the component. +### Phase 2: UI & UX Refinement +- [ ] Standardize Tailwind classes (using Tailwind 4 patterns). +- [ ] Implement "Edit Mode" awareness (syncing with `$ae_loc.edit_mode`). +- [ ] Add a "Save" loading state with Lucide's `LoaderCircle` spinner. +- [ ] Implement a clear "Cancel" path that restores the original value. -### Phase 2: UI/UX & Accessibility -- [ ] Standardize Tailwind classes; remove legacy scope-polluting CSS. -- [ ] Implement a "Select" mode optimized for mobile (Bottom Sheet style?). -- [ ] Improve "Double Click to Edit" discoverability or provide a single-tap alternative for mobile. -- [ ] Standardize button types (`type="button"`) and preset styles. +### Phase 3: Field Type Parity +- [ ] Support `text`, `textarea`, `select`, `tiptap`, and `checkbox`. +- [ ] Add `datetime` support using native browser pickers. +- [ ] Implement searchable dropdowns for the `select` type. -### Phase 3: Field Type Expansion -- [ ] Enhance `select` mode with searchable dropdowns. -- [ ] Formalize `tiptap` integration with full configuration support. -- [ ] Add `datetime` and `date` field types. +### Phase 4: Migration & Cleanup +- [ ] Create a playground route for V3 verification. +- [ ] Deprecate and eventually remove `v1` and `v2` files. +- [ ] Update `GUIDE__DEVELOPMENT.md` with the new usage patterns. -### Phase 4: Verification & Migration -- [ ] Create a testing playground route for CRUD v2. -- [ ] Perform a surgical swap across high-traffic modules (Leads, Events, Journals). -- [ ] Verify `npm run check` baseline. - -## 5. Maintenance & Standards -- Maintain the `object_reload={true}` pattern for automatic cache revalidation. -- Ensure `class_li` and `display_block` props remain backward compatible. +## 4. Maintenance & Standards +- Component must respect `$ae_loc.trusted_access` for visibility of edit triggers. +- Always use `type="button"` for internal actions to prevent form collisions. +- Maintain the `object_reload` pattern for SWR cache invalidation. diff --git a/src/lib/elements/element_ae_obj_field_editor_v3.svelte b/src/lib/elements/element_ae_obj_field_editor_v3.svelte new file mode 100644 index 00000000..4ac0262b --- /dev/null +++ b/src/lib/elements/element_ae_obj_field_editor_v3.svelte @@ -0,0 +1,285 @@ + + +
+ +
+
+ {#if children} + {@render children()} + {:else if field_type === 'checkbox'} + + {current_value ? 'Enabled' : 'Disabled'} + + {:else if field_type === 'tiptap'} +
+ {@html current_value || 'Empty'} +
+ {:else} + + {current_value || 'Not set'} + + {/if} +
+ + + {#if $ae_loc.edit_mode} + + {/if} +
+ + + {#if is_editing} +
+
+ {edit_label || field_name} +
+ +
+
+ +
+ {#if field_type === 'textarea'} + + {:else if field_type === 'select'} + + {:else if field_type === 'checkbox'} + + {:else if field_type === 'tiptap'} + + {:else if field_type === 'date'} + + {:else if field_type === 'datetime'} + + {:else} + e.key === 'Enter' && handle_patch()} + /> + {/if} +
+ +
+
+ {#if patch_status === 'processing'} + + Saving... + + {:else if patch_status === 'success'} + + Saved + + {:else if patch_status === 'error'} + + Error + + {/if} +
+ +
+ {#if allow_null && draft_value !== null} + + {/if} + +
+
+
+ {/if} +
+ + diff --git a/src/routes/testing/ae_obj_field_editor_v3/+page.svelte b/src/routes/testing/ae_obj_field_editor_v3/+page.svelte new file mode 100644 index 00000000..0e51145b --- /dev/null +++ b/src/routes/testing/ae_obj_field_editor_v3/+page.svelte @@ -0,0 +1,222 @@ + + +
+
+
+

AE Obj Field Editor V3 Test

+

IDs: Journal={test_journal_id} | Entry={test_journal_entry_id}

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

Journal Properties

+ + {#if $lq__test_journal} +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ {:else} +
+ +

Loading Journal {test_journal_id}...

+
+ {/if} +
+ + +
+

Journal Entry Properties

+ + {#if $lq__test_journal_entry} +
+
+ + +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ {:else} +
+ +

Loading Entry {test_journal_entry_id}...

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

Debug Context

+
+
+ Edit Mode: {$ae_loc.edit_mode} +
+
+ Account ID: {$ae_loc.account_id} +
+
+ Journal Status: {$lq__test_journal ? 'Cached' : 'Pending'} +
+
+ Entry Status: {$lq__test_journal_entry ? 'Cached' : 'Pending'} +
+
+
+