mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-03-08 10:03:31 +01:00
206 lines
6.1 KiB
Markdown
206 lines
6.1 KiB
Markdown
# 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:
|
|
|
|
```javascript
|
|
{
|
|
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
|
|
|
|
- [x] IPC handlers added to BackendManager.js
|
|
- [x] DataBrowser component created
|
|
- [x] DataGrid with inline editing
|
|
- [x] CellEditor with type-aware controls
|
|
- [x] NewRecordModal for creating records
|
|
- [x] CSV export functionality
|
|
- [x] Pagination working
|
|
- [x] Search functionality
|
|
- [x] Bulk delete operations
|
|
- [x] Integration with LocalBackendCard
|
|
- [x] Theme-compliant styling
|
|
- [x] No hardcoded colors
|
|
- [x] JSDoc comments added
|
|
|
|
---
|
|
|
|
## Related Tasks
|
|
|
|
- **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)
|