Files
OpenNoodl/dev-docs/tasks/phase-5-multi-target-deployment/01-byob-backend/TASK-007-integrated-backend/TASK-007I-COMPLETE.md
2026-01-16 12:00:31 +01:00

6.1 KiB

TASK-007I: Data Browser Panel - COMPLETE

Summary

Implemented a full-featured data browser panel for viewing and editing records in local backend SQLite tables, providing a spreadsheet-like interface with inline editing, search, pagination, and CRUD operations.

Status: Complete

Date: 2026-01-15


What Was Implemented

1. Backend IPC Handlers (BackendManager.js)

Added four new IPC handlers for data operations:

  • backend:queryRecords - Query records with pagination, sorting, search filters
  • backend:createRecord - Create a new record in a table
  • backend:saveRecord - Update an existing record (inline edit)
  • backend:deleteRecord - Delete a single record

These handlers wrap the existing LocalSQLAdapter CRUD methods (query, create, save, delete) and expose them to the renderer process.

2. DataBrowser Component (panels/databrowser/)

Created a complete data browser panel with the following components:

DataBrowser.tsx (Main Component)

  • Table selector dropdown
  • Search input with cross-field text search
  • Pagination with page navigation (50 records per page)
  • Bulk selection and delete operations
  • CSV export functionality
  • Loading states and error handling
  • New record modal trigger

DataGrid.tsx (Spreadsheet View)

  • Column headers with type badges (String, Number, Boolean, Date, Object, Array)
  • System columns (objectId, createdAt, updatedAt) displayed as read-only
  • Inline editing - click any editable cell to edit
  • Row selection with checkbox
  • Select all/none toggle
  • Delete action per row
  • Scrollable with sticky header

CellEditor.tsx (Inline Editor)

  • Type-aware input controls:
    • String: Text input
    • Number: Number input with step="any"
    • Boolean: Checkbox with immediate save
    • Date: datetime-local input
    • Object/Array: Multi-line JSON editor with Save/Cancel buttons
  • Auto-focus and select on mount
  • Enter to save, Escape to cancel (for simple types)
  • Validation for numbers and JSON parsing
  • Error display for invalid input

NewRecordModal.tsx (Create Record Form)

  • Form fields generated from column schema
  • Type-aware input controls for each field type
  • Required field validation
  • Default values based on column defaults or type defaults
  • Success callback to refresh data grid

3. Styling

All components use theme CSS variables per UI-STYLING-GUIDE.md:

  • --theme-color-bg-* for backgrounds
  • --theme-color-fg-* for text
  • --theme-color-border-* for borders
  • --theme-color-primary* for accents
  • --theme-color-success/danger/notice for status colors

4. Integration

Added "Data" button to LocalBackendCard (visible when backend is running):

  • Opens DataBrowser in a full-screen portal overlay
  • Same pattern as Schema panel

Files Created/Modified

Created Files:

packages/noodl-editor/src/editor/src/views/panels/databrowser/
├── DataBrowser.tsx           - Main data browser component
├── DataBrowser.module.scss   - Styles for DataBrowser
├── DataGrid.tsx              - Spreadsheet grid component
├── DataGrid.module.scss      - Styles for DataGrid
├── CellEditor.tsx            - Inline cell editor
├── CellEditor.module.scss    - Styles for CellEditor
├── NewRecordModal.tsx        - Create record modal
├── NewRecordModal.module.scss - Styles for modal
└── index.ts                  - Exports

Modified Files:

packages/noodl-editor/src/main/src/local-backend/BackendManager.js
  - Added queryRecords(), createRecord(), saveRecord(), deleteRecord() methods
  - Added corresponding IPC handlers

packages/noodl-editor/src/editor/src/views/panels/BackendServicesPanel/LocalBackendCard/LocalBackendCard.tsx
  - Added DataBrowser import
  - Added showDataBrowser state
  - Added "Data" button
  - Added DataBrowser portal rendering

How To Use

  1. Start a local backend from the Backend Services panel
  2. Click the "Data" button on the running backend card
  3. Select a table from the dropdown (auto-selects first table if available)
  4. Browse records with pagination
  5. Click any editable cell to edit inline
  6. Use "+ New Record" to add records
  7. Use checkboxes for bulk selection and delete
  8. Use "Export CSV" to download current view

Technical Notes

Query API

The query API supports:

{
  collection: string,    // Table name
  limit: number,         // Max records (default 50)
  skip: number,          // Pagination offset
  where: object,         // Filter conditions ($or, contains, etc.)
  sort: string[],        // Sort order (e.g., ['-createdAt'])
  count: boolean         // Return total count for pagination
}

Search Implementation

Search uses $or with contains operator across all String columns and objectId. The LocalSQLAdapter converts this to SQLite LIKE queries.

Type Handling

  • System fields (objectId, createdAt, updatedAt) are always read-only
  • Boolean cells save immediately on checkbox toggle
  • Object/Array cells require explicit Save button due to JSON editing
  • Dates are stored as ISO8601 strings

Future Improvements (Not in scope)

  • Column sorting by clicking headers
  • Filter by specific field values
  • Relation/Pointer field expansion
  • Inline record duplication
  • Undo for delete operations
  • Import CSV/JSON

Verification Checklist

  • IPC handlers added to BackendManager.js
  • DataBrowser component created
  • DataGrid with inline editing
  • CellEditor with type-aware controls
  • NewRecordModal for creating records
  • CSV export functionality
  • Pagination working
  • Search functionality
  • Bulk delete operations
  • Integration with LocalBackendCard
  • Theme-compliant styling
  • No hardcoded colors
  • JSDoc comments added

  • TASK-007A: Core SQLite adapter
  • TASK-007B: Workflow integration
  • TASK-007C: Schema management
  • TASK-007D: Backend lifecycle
  • TASK-007E: Express HTTP API
  • TASK-007F: Node integration
  • TASK-007G: UI components
  • TASK-007H: Schema Panel UI
  • TASK-007I: Data Browser (this task)