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.
This commit is contained in:
Scott Idem
2026-02-13 16:07:21 -05:00
parent 6bfd13f52c
commit 3e83890932
3 changed files with 542 additions and 38 deletions

View File

@@ -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.