directus-extension-super-table 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -83
- package/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,26 +31,28 @@ Powerful search functionality across all table fields, including nested relation
|
|
|
31
31
|
Switch seamlessly between read-only view mode and interactive edit mode. Control when and how users can modify data.
|
|
32
32
|
|
|
33
33
|
### 🖼️ Advanced Image Display & Selection
|
|
34
|
-
Smart image handling with hover preview, proper aspect ratios, and built-in file browser for selecting media files directly from table cells.
|
|
34
|
+
Smart image handling with an enlarged hover preview, proper aspect ratios, and a built-in file browser for selecting media files directly from table cells.
|
|
35
35
|
|
|
36
36
|
### 🔄 Deep Duplication
|
|
37
37
|
Duplicate items with all their relationships and translations. Perfect for creating variations of complex data structures.
|
|
38
38
|
|
|
39
|
+
### 🧩 Many-to-Any (M2A) Display
|
|
40
|
+
Render polymorphic Many-to-Any relationships directly in the table. Use the `related-values` display or a per-column template with the `{{item:collection.field}}` syntax — including nested chains like `{{item:partners_catalog.catalog_id.title}}`. Each junction row resolves against its own target collection.
|
|
41
|
+
|
|
39
42
|
|
|
40
43
|
|
|
41
44
|
### Display Features
|
|
42
45
|
- **Custom Cell Rendering** - Specialized display for different field types
|
|
43
46
|
- **Relationship Support** - Handle M2O, O2M, M2M, M2A relationships with deep data access
|
|
44
|
-
- **Image Preview** - Inline image display with
|
|
47
|
+
- **Image Preview** - Inline image display with an enlarged hover preview and file browser
|
|
45
48
|
- **Tag Support** - Automatic detection and display of tag fields as visual chips with inline popover editor for adding/removing tags
|
|
46
49
|
- **Status Indicators** - Visual representation of boolean and select fields
|
|
47
50
|
- **Translation Support** - Display multiple language translations as separate columns
|
|
48
51
|
- **Column Alignment** - Configurable text alignment per column (left, center, right)
|
|
49
52
|
|
|
50
53
|
### Performance
|
|
51
|
-
- **
|
|
52
|
-
- **
|
|
53
|
-
- **Lazy Loading** - Load data as needed for large datasets
|
|
54
|
+
- **Native Pagination** - Server-side pagination with selectable page sizes (25, 50, 100, 250, 500, 1000; default 25)
|
|
55
|
+
- **Separate Count Query** - Item count is fetched independently so the table still renders when the count query is restricted by permissions
|
|
54
56
|
|
|
55
57
|
|
|
56
58
|
## Installation
|
|
@@ -87,12 +89,12 @@ npx directus start
|
|
|
87
89
|
1. Clone or download the extension to your Directus extensions folder:
|
|
88
90
|
```bash
|
|
89
91
|
cd /path/to/directus/extensions
|
|
90
|
-
git clone https://github.com/
|
|
92
|
+
git clone https://github.com/smartlabsAT/directus-super-table.git
|
|
91
93
|
```
|
|
92
94
|
|
|
93
95
|
2. Install dependencies:
|
|
94
96
|
```bash
|
|
95
|
-
cd super-
|
|
97
|
+
cd directus-super-table
|
|
96
98
|
pnpm install # or npm install
|
|
97
99
|
```
|
|
98
100
|
|
|
@@ -105,11 +107,10 @@ npx directus start
|
|
|
105
107
|
|
|
106
108
|
### Configuration
|
|
107
109
|
|
|
108
|
-
1.
|
|
109
|
-
2.
|
|
110
|
-
3. Select "Super
|
|
111
|
-
4. Configure the layout options
|
|
112
|
-
5. Save your changes
|
|
110
|
+
1. Open a collection in the Directus Content module
|
|
111
|
+
2. Open the layout dropdown in the sidebar
|
|
112
|
+
3. Select **"Super Table"** as the layout
|
|
113
|
+
4. Configure the layout options in the **Layout Options** sidebar panel
|
|
113
114
|
|
|
114
115
|
## Usage Guide
|
|
115
116
|
|
|
@@ -127,21 +128,24 @@ Quick Filters provide fast access to frequently used filter combinations:
|
|
|
127
128
|
### Inline Editing
|
|
128
129
|
Edit data directly in the table without opening a separate form:
|
|
129
130
|
|
|
130
|
-
1. **Entering Edit Mode**:
|
|
131
|
+
1. **Entering Edit Mode**: Enable "Edit Mode" in the **Layout Options** sidebar (or the edit toggle in the table header), then click an editable cell
|
|
131
132
|
2. **Editor Types**:
|
|
132
133
|
- Text fields: Simple input or WYSIWYG editor
|
|
133
134
|
- Boolean: Checkbox toggle
|
|
134
135
|
- Select: Dropdown menu
|
|
135
136
|
- Date/Time: Full date picker with calendar
|
|
136
137
|
- Color: Color picker with alignment support
|
|
137
|
-
- Image/File:
|
|
138
|
-
3. **Unified Header Actions
|
|
139
|
-
- Save/Cancel buttons
|
|
138
|
+
- Image/File: File browser with larger previews
|
|
139
|
+
3. **Unified Header Actions**:
|
|
140
|
+
- Save/Cancel buttons in the popover header for all field types
|
|
140
141
|
- Consistent UI across all editors
|
|
141
142
|
- Icon-only buttons matching native Directus style
|
|
142
143
|
4. **Saving**: Click save button (✓) or press Enter
|
|
143
144
|
5. **Canceling**: Click cancel button (✗) or press Escape
|
|
144
145
|
|
|
146
|
+
> **Note:** Relational fields (M2O, O2M, M2M, M2A) are display-only and are not
|
|
147
|
+
> editable inline — open the item detail view to edit them.
|
|
148
|
+
|
|
145
149
|
### Column Management
|
|
146
150
|
Customize which columns are displayed and how:
|
|
147
151
|
|
|
@@ -151,6 +155,34 @@ Customize which columns are displayed and how:
|
|
|
151
155
|
4. **Reorder Columns**: Drag column headers to reorder
|
|
152
156
|
5. **Resize Columns**: Drag column borders to resize
|
|
153
157
|
|
|
158
|
+
### Column Displays
|
|
159
|
+
Override how a column renders by attaching a display template, configured in the
|
|
160
|
+
sidebar under **Layout Options → Column Displays**:
|
|
161
|
+
|
|
162
|
+
1. **Add a display**: Click "Add Column Display", pick a column, and enter a template
|
|
163
|
+
2. **Edit / Remove**: Click an existing entry to edit it, or the ✗ icon to remove it
|
|
164
|
+
3. **Templates** use the `{{ field }}` mustache syntax and may reference related fields
|
|
165
|
+
|
|
166
|
+
#### Many-to-Any (M2A) templates
|
|
167
|
+
M2A fields are polymorphic — each row points at one of several target collections —
|
|
168
|
+
so their templates use a dedicated `item:` syntax. Tokens are written **relative to
|
|
169
|
+
the field** (do not prefix the field name):
|
|
170
|
+
|
|
171
|
+
- `{{collection}}` — the name of the row's target collection
|
|
172
|
+
- `{{item:<collection>.<field>}}` — a field on a specific target collection
|
|
173
|
+
- Nested paths are supported, e.g. `{{item:partners_catalog.catalog_id.title}}`
|
|
174
|
+
(M2A → M2O → value)
|
|
175
|
+
|
|
176
|
+
Each junction row only resolves the token whose `<collection>` matches its own
|
|
177
|
+
target, so a template can cover every allowed collection at once:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
{{collection}}: {{item:partners_catalog.name}} {{item:service.name}}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The editor shows the allowed collections and an example for the selected field. A
|
|
184
|
+
bare token (e.g. `{{name}}`) is intentionally dropped for M2A — use the `item:` form.
|
|
185
|
+
|
|
154
186
|
### Bookmarks
|
|
155
187
|
Save table configurations for quick access:
|
|
156
188
|
|
|
@@ -163,35 +195,38 @@ Save table configurations for quick access:
|
|
|
163
195
|
|
|
164
196
|
```
|
|
165
197
|
super-layout-table/
|
|
198
|
+
├── index.ts # Extension entry point (defineLayout)
|
|
166
199
|
├── src/
|
|
167
|
-
│ ├──
|
|
168
|
-
│ ├──
|
|
169
|
-
│ ├── actions.vue
|
|
170
|
-
│ ├──
|
|
171
|
-
│ ├──
|
|
172
|
-
│
|
|
173
|
-
│
|
|
174
|
-
│
|
|
175
|
-
│
|
|
176
|
-
│
|
|
177
|
-
│
|
|
178
|
-
│
|
|
179
|
-
├──
|
|
180
|
-
│ ├──
|
|
181
|
-
│
|
|
182
|
-
│ └──
|
|
183
|
-
├──
|
|
184
|
-
│
|
|
185
|
-
│
|
|
186
|
-
|
|
187
|
-
├──
|
|
188
|
-
|
|
200
|
+
│ ├── super-table.vue # Main layout component
|
|
201
|
+
│ ├── options.vue # Sidebar layout options
|
|
202
|
+
│ ├── actions.vue # Row/bulk actions component
|
|
203
|
+
│ ├── components/
|
|
204
|
+
│ │ ├── InlineEditPopover.vue # Inline editor popover
|
|
205
|
+
│ │ ├── QuickFilters.vue # Quick filter management
|
|
206
|
+
│ │ ├── ColumnDisplaysSection.vue # Column-display list + editor
|
|
207
|
+
│ │ ├── ColumnDisplayEditor.vue # Single column-display form
|
|
208
|
+
│ │ ├── EditableCellRelational.vue# Relational/M2A cell rendering
|
|
209
|
+
│ │ └── CellRenderers/ # Custom cell renderers (image, select, …)
|
|
210
|
+
│ ├── composables/
|
|
211
|
+
│ │ ├── api.ts # API operations (useTableApi)
|
|
212
|
+
│ │ ├── useAliasFields.ts # Field aliasing logic
|
|
213
|
+
│ │ ├── useColumnDisplays.ts # Column-display override CRUD
|
|
214
|
+
│ │ └── … # pagination, sort, permissions, translations
|
|
215
|
+
│ └── utils/
|
|
216
|
+
│ ├── adjustFieldsForDisplays.ts# Display field expansion (incl. M2A)
|
|
217
|
+
│ ├── displayHeuristics.ts # Template tokenising + relation helpers
|
|
218
|
+
│ ├── resolveM2ARelation.ts # M2A junction-shape resolver
|
|
219
|
+
│ └── getDefaultDisplayForType.ts# Default display mapping
|
|
220
|
+
├── tests/ # Vitest unit tests
|
|
221
|
+
├── package.json # Package configuration
|
|
222
|
+
├── tsconfig.json # TypeScript configuration
|
|
223
|
+
└── README.md # This file
|
|
189
224
|
```
|
|
190
225
|
|
|
191
226
|
## Development
|
|
192
227
|
|
|
193
228
|
### Prerequisites
|
|
194
|
-
- Node.js
|
|
229
|
+
- Node.js 20+ (CI runs on 20.x and 22.x)
|
|
195
230
|
- pnpm package manager
|
|
196
231
|
- Directus 11.0.0+
|
|
197
232
|
|
|
@@ -238,10 +273,12 @@ Every push and pull request triggers automated quality validation:
|
|
|
238
273
|
|
|
239
274
|
```
|
|
240
275
|
.github/workflows/
|
|
241
|
-
├──
|
|
242
|
-
├──
|
|
243
|
-
├──
|
|
244
|
-
|
|
276
|
+
├── ci.yml # CI/CD pipeline (build, test, quality on Node 20.x & 22.x)
|
|
277
|
+
├── quality-checks.yml # Type-check, lint, format, build (push/PR)
|
|
278
|
+
├── test.yml # Vitest unit tests
|
|
279
|
+
├── pr-checks.yml # PR-specific checks with auto-comments
|
|
280
|
+
├── release.yml # Automated release creation on version tags
|
|
281
|
+
└── badges.yml # Status badge updates
|
|
245
282
|
```
|
|
246
283
|
|
|
247
284
|
### Running Locally
|
|
@@ -266,56 +303,45 @@ pnpm run build # Build test
|
|
|
266
303
|
5. GitHub Actions will automatically validate your code
|
|
267
304
|
6. PR will receive an automated quality report comment
|
|
268
305
|
|
|
269
|
-
###
|
|
270
|
-
The
|
|
306
|
+
### Layout Options
|
|
307
|
+
The layout persists these options (those marked *(sidebar)* have a control in the
|
|
308
|
+
**Layout Options** panel; the rest are set through table interactions):
|
|
271
309
|
|
|
272
310
|
```typescript
|
|
273
311
|
{
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
//
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
//
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
// Allow column resizing
|
|
287
|
-
showResize: true,
|
|
288
|
-
|
|
289
|
-
// Enable inline editing
|
|
290
|
-
allowInlineEdit: true,
|
|
291
|
-
|
|
292
|
-
// Enable bookmark system
|
|
293
|
-
allowBookmarks: true,
|
|
294
|
-
|
|
295
|
-
// Enable quick filters
|
|
296
|
-
allowQuickFilters: true
|
|
312
|
+
showToolbar?: boolean; // (sidebar) show the toolbar with actions
|
|
313
|
+
editMode?: boolean; // (sidebar) enable inline editing
|
|
314
|
+
directBooleanToggle?: boolean; // (sidebar, requires editMode) single-click boolean toggle
|
|
315
|
+
languageCodeField?: string; // (sidebar) language-code field for translations (default 'languages_code')
|
|
316
|
+
customFieldNames?: Record<string, string>; // per-column header label overrides
|
|
317
|
+
columnDisplays?: Record<string, { template: string; display?: string }>; // per-column display templates
|
|
318
|
+
showSelect?: boolean; // show row-selection checkboxes
|
|
319
|
+
spacing?: 'compact' | 'cozy' | 'comfortable'; // row height
|
|
320
|
+
align?: Record<string, 'left' | 'center' | 'right'>; // per-column text alignment
|
|
321
|
+
widths?: Record<string, number>; // per-column widths
|
|
322
|
+
quickFilters?: QuickFilter[]; // saved quick filters
|
|
297
323
|
}
|
|
298
324
|
```
|
|
299
325
|
|
|
300
326
|
## API Reference
|
|
301
327
|
|
|
302
328
|
### Events
|
|
303
|
-
|
|
329
|
+
As a Directus layout, the component emits the standard layout sync events:
|
|
304
330
|
|
|
305
331
|
- `update:selection` - When item selection changes
|
|
306
|
-
- `update:
|
|
307
|
-
- `update:
|
|
308
|
-
- `update:
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
332
|
+
- `update:layoutOptions` - When a layout option changes (column displays, edit mode, alignment, widths, …)
|
|
333
|
+
- `update:layoutQuery` - When the query changes (fields, sort, page, limit)
|
|
334
|
+
- `update:search` - When the search query changes
|
|
335
|
+
|
|
336
|
+
The `filter` prop is consumed read-only (filtering is driven by Directus), so no
|
|
337
|
+
`update:filter` event is emitted.
|
|
312
338
|
|
|
313
339
|
### Composables
|
|
314
340
|
Available composables for extension development:
|
|
315
341
|
|
|
316
|
-
- `
|
|
342
|
+
- `useTableApi()` - API operations wrapper (fetch, count, update, delete, export)
|
|
317
343
|
- `useAliasFields()` - Field aliasing for complex queries
|
|
318
|
-
- `
|
|
344
|
+
- `useColumnDisplays()` - Per-column display-template overrides
|
|
319
345
|
|
|
320
346
|
## Browser Support
|
|
321
347
|
|
|
@@ -349,14 +375,14 @@ Contributions are welcome! Please follow these guidelines:
|
|
|
349
375
|
- Try clearing browser cache
|
|
350
376
|
|
|
351
377
|
### Inline editing not working
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
-
|
|
378
|
+
- Make sure "Edit Mode" is enabled in the Layout Options sidebar
|
|
379
|
+
- Check field permissions in Directus (no update permission = read-only)
|
|
380
|
+
- Ensure fields are not configured as read-only
|
|
381
|
+
- Note: relational fields (M2O, O2M, M2M, M2A) are display-only by design
|
|
355
382
|
|
|
356
383
|
### Performance issues
|
|
357
|
-
-
|
|
358
|
-
-
|
|
359
|
-
- Check browser console for errors
|
|
384
|
+
- Choose a smaller page size (the per-page selector defaults to 25)
|
|
385
|
+
- Check the browser console for errors
|
|
360
386
|
|
|
361
387
|
## Changelog
|
|
362
388
|
|