directus-extension-super-table 0.4.2 → 0.5.1
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 +113 -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 — built straight from the native field picker or by hand. Use `{{item:<collection>.<field>}}` for a target's fields (nested chains like `{{item:partners_catalog.catalog_id.title}}` work), `{{collection}}` for the discriminator, and bare tokens like `{{code}}` for parent-row fields. 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,38 @@ 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 junction row points at one of several target
|
|
168
|
+
collections. Build the template straight from the **native field picker** (it now
|
|
169
|
+
resolves correctly), or write tokens by hand. Tokens resolve per junction row; on a
|
|
170
|
+
name clash the most specific (deepest) match wins:
|
|
171
|
+
|
|
172
|
+
- `{{item:<collection>.<field>}}` — a field on a specific target collection;
|
|
173
|
+
nested paths work, e.g. `{{item:partners_catalog.catalog_id.title}}` (M2A → M2O → value)
|
|
174
|
+
- `{{collection}}` — the name of the row's target collection (the discriminator)
|
|
175
|
+
- The field-key-prefixed forms the picker emits also work, e.g.
|
|
176
|
+
`{{treatment.collection}}`, `{{treatment.item:service.name}}`, or a junction
|
|
177
|
+
column like `{{treatment.sort}}`
|
|
178
|
+
- `{{<parentField>}}` — a bare token reads a field on the parent row, e.g.
|
|
179
|
+
`{{code}}` shows the order's own code next to each item
|
|
180
|
+
|
|
181
|
+
Each junction row only resolves the item token whose `<collection>` matches its own
|
|
182
|
+
target, so a template can cover every allowed collection at once:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
{{collection}}: {{item:partners_catalog.name}} {{item:service.name}}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The editor shows the allowed collections and an example for the selected field.
|
|
189
|
+
|
|
154
190
|
### Bookmarks
|
|
155
191
|
Save table configurations for quick access:
|
|
156
192
|
|
|
@@ -163,35 +199,38 @@ Save table configurations for quick access:
|
|
|
163
199
|
|
|
164
200
|
```
|
|
165
201
|
super-layout-table/
|
|
202
|
+
├── index.ts # Extension entry point (defineLayout)
|
|
166
203
|
├── 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
|
-
|
|
204
|
+
│ ├── super-table.vue # Main layout component
|
|
205
|
+
│ ├── options.vue # Sidebar layout options
|
|
206
|
+
│ ├── actions.vue # Row/bulk actions component
|
|
207
|
+
│ ├── components/
|
|
208
|
+
│ │ ├── InlineEditPopover.vue # Inline editor popover
|
|
209
|
+
│ │ ├── QuickFilters.vue # Quick filter management
|
|
210
|
+
│ │ ├── ColumnDisplaysSection.vue # Column-display list + editor
|
|
211
|
+
│ │ ├── ColumnDisplayEditor.vue # Single column-display form
|
|
212
|
+
│ │ ├── EditableCellRelational.vue# Relational/M2A cell rendering
|
|
213
|
+
│ │ └── CellRenderers/ # Custom cell renderers (image, select, …)
|
|
214
|
+
│ ├── composables/
|
|
215
|
+
│ │ ├── api.ts # API operations (useTableApi)
|
|
216
|
+
│ │ ├── useAliasFields.ts # Field aliasing logic
|
|
217
|
+
│ │ ├── useColumnDisplays.ts # Column-display override CRUD
|
|
218
|
+
│ │ └── … # pagination, sort, permissions, translations
|
|
219
|
+
│ └── utils/
|
|
220
|
+
│ ├── adjustFieldsForDisplays.ts# Display field expansion (incl. M2A)
|
|
221
|
+
│ ├── displayHeuristics.ts # Template tokenising + relation helpers
|
|
222
|
+
│ ├── resolveM2ARelation.ts # M2A junction-shape resolver
|
|
223
|
+
│ └── getDefaultDisplayForType.ts# Default display mapping
|
|
224
|
+
├── tests/ # Vitest unit tests
|
|
225
|
+
├── package.json # Package configuration
|
|
226
|
+
├── tsconfig.json # TypeScript configuration
|
|
227
|
+
└── README.md # This file
|
|
189
228
|
```
|
|
190
229
|
|
|
191
230
|
## Development
|
|
192
231
|
|
|
193
232
|
### Prerequisites
|
|
194
|
-
- Node.js
|
|
233
|
+
- Node.js 20+ (CI runs on 20.x and 22.x)
|
|
195
234
|
- pnpm package manager
|
|
196
235
|
- Directus 11.0.0+
|
|
197
236
|
|
|
@@ -238,10 +277,12 @@ Every push and pull request triggers automated quality validation:
|
|
|
238
277
|
|
|
239
278
|
```
|
|
240
279
|
.github/workflows/
|
|
241
|
-
├──
|
|
242
|
-
├──
|
|
243
|
-
├──
|
|
244
|
-
|
|
280
|
+
├── ci.yml # CI/CD pipeline (build, test, quality on Node 20.x & 22.x)
|
|
281
|
+
├── quality-checks.yml # Type-check, lint, format, build (push/PR)
|
|
282
|
+
├── test.yml # Vitest unit tests
|
|
283
|
+
├── pr-checks.yml # PR-specific checks with auto-comments
|
|
284
|
+
├── release.yml # Automated release creation on version tags
|
|
285
|
+
└── badges.yml # Status badge updates
|
|
245
286
|
```
|
|
246
287
|
|
|
247
288
|
### Running Locally
|
|
@@ -266,56 +307,45 @@ pnpm run build # Build test
|
|
|
266
307
|
5. GitHub Actions will automatically validate your code
|
|
267
308
|
6. PR will receive an automated quality report comment
|
|
268
309
|
|
|
269
|
-
###
|
|
270
|
-
The
|
|
310
|
+
### Layout Options
|
|
311
|
+
The layout persists these options (those marked *(sidebar)* have a control in the
|
|
312
|
+
**Layout Options** panel; the rest are set through table interactions):
|
|
271
313
|
|
|
272
314
|
```typescript
|
|
273
315
|
{
|
|
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
|
|
316
|
+
showToolbar?: boolean; // (sidebar) show the toolbar with actions
|
|
317
|
+
editMode?: boolean; // (sidebar) enable inline editing
|
|
318
|
+
directBooleanToggle?: boolean; // (sidebar, requires editMode) single-click boolean toggle
|
|
319
|
+
languageCodeField?: string; // (sidebar) language-code field for translations (default 'languages_code')
|
|
320
|
+
customFieldNames?: Record<string, string>; // per-column header label overrides
|
|
321
|
+
columnDisplays?: Record<string, { template: string; display?: string }>; // per-column display templates
|
|
322
|
+
showSelect?: boolean; // show row-selection checkboxes
|
|
323
|
+
spacing?: 'compact' | 'cozy' | 'comfortable'; // row height
|
|
324
|
+
align?: Record<string, 'left' | 'center' | 'right'>; // per-column text alignment
|
|
325
|
+
widths?: Record<string, number>; // per-column widths
|
|
326
|
+
quickFilters?: QuickFilter[]; // saved quick filters
|
|
297
327
|
}
|
|
298
328
|
```
|
|
299
329
|
|
|
300
330
|
## API Reference
|
|
301
331
|
|
|
302
332
|
### Events
|
|
303
|
-
|
|
333
|
+
As a Directus layout, the component emits the standard layout sync events:
|
|
304
334
|
|
|
305
335
|
- `update:selection` - When item selection changes
|
|
306
|
-
- `update:
|
|
307
|
-
- `update:
|
|
308
|
-
- `update:
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
336
|
+
- `update:layoutOptions` - When a layout option changes (column displays, edit mode, alignment, widths, …)
|
|
337
|
+
- `update:layoutQuery` - When the query changes (fields, sort, page, limit)
|
|
338
|
+
- `update:search` - When the search query changes
|
|
339
|
+
|
|
340
|
+
The `filter` prop is consumed read-only (filtering is driven by Directus), so no
|
|
341
|
+
`update:filter` event is emitted.
|
|
312
342
|
|
|
313
343
|
### Composables
|
|
314
344
|
Available composables for extension development:
|
|
315
345
|
|
|
316
|
-
- `
|
|
346
|
+
- `useTableApi()` - API operations wrapper (fetch, count, update, delete, export)
|
|
317
347
|
- `useAliasFields()` - Field aliasing for complex queries
|
|
318
|
-
- `
|
|
348
|
+
- `useColumnDisplays()` - Per-column display-template overrides
|
|
319
349
|
|
|
320
350
|
## Browser Support
|
|
321
351
|
|
|
@@ -349,14 +379,14 @@ Contributions are welcome! Please follow these guidelines:
|
|
|
349
379
|
- Try clearing browser cache
|
|
350
380
|
|
|
351
381
|
### Inline editing not working
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
-
|
|
382
|
+
- Make sure "Edit Mode" is enabled in the Layout Options sidebar
|
|
383
|
+
- Check field permissions in Directus (no update permission = read-only)
|
|
384
|
+
- Ensure fields are not configured as read-only
|
|
385
|
+
- Note: relational fields (M2O, O2M, M2M, M2A) are display-only by design
|
|
355
386
|
|
|
356
387
|
### Performance issues
|
|
357
|
-
-
|
|
358
|
-
-
|
|
359
|
-
- Check browser console for errors
|
|
388
|
+
- Choose a smaller page size (the per-page selector defaults to 25)
|
|
389
|
+
- Check the browser console for errors
|
|
360
390
|
|
|
361
391
|
## Changelog
|
|
362
392
|
|