@wix/auto-patterns 1.40.0 → 1.42.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/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js +57 -0
- package/dist/cjs/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js.map +1 -0
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +0 -1
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js +42 -0
- package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js.map +1 -0
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js +3 -1
- package/dist/cjs/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js +3 -1
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/cjs/exports/testkit/enzyme.js +10 -0
- package/dist/cjs/exports/testkit/enzyme.js.map +1 -0
- package/dist/cjs/exports/testkit/jsdom.js +10 -0
- package/dist/cjs/exports/testkit/jsdom.js.map +1 -0
- package/dist/cjs/exports/testkit/playwright.js +10 -0
- package/dist/cjs/exports/testkit/playwright.js.map +1 -0
- package/dist/cjs/exports/testkit/puppeteer.js +10 -0
- package/dist/cjs/exports/testkit/puppeteer.js.map +1 -0
- package/dist/cjs/hooks/useCommonCollectionFeatures.js +12 -7
- package/dist/cjs/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/cjs/hooks/useDragAndDropBaseProps.js +7 -3
- package/dist/cjs/hooks/useDragAndDropBaseProps.js.map +1 -1
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useViews.js +107 -0
- package/dist/cjs/hooks/useViews.js.map +1 -0
- package/dist/cjs/providers/AutoPatternsOverridesContext.js +1 -1
- package/dist/cjs/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/cjs/testkit/enzyme.js +8 -0
- package/dist/cjs/testkit/enzyme.js.map +1 -0
- package/dist/cjs/testkit/jsdom.js +8 -0
- package/dist/cjs/testkit/jsdom.js.map +1 -0
- package/dist/cjs/testkit/playwright.js +8 -0
- package/dist/cjs/testkit/playwright.js.map +1 -0
- package/dist/cjs/testkit/puppeteer.js +8 -0
- package/dist/cjs/testkit/puppeteer.js.map +1 -0
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js +50 -0
- package/dist/esm/components/AutoPatternsApp/AutoPatternsApp.uni.driver.js.map +1 -0
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +0 -1
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js +37 -0
- package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.js.map +1 -0
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js +2 -0
- package/dist/esm/components/AutoPatternsGrid/AutoPatternsGrid.js.map +1 -1
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +2 -0
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/esm/exports/testkit/enzyme.js +2 -0
- package/dist/esm/exports/testkit/enzyme.js.map +1 -0
- package/dist/esm/exports/testkit/jsdom.js +2 -0
- package/dist/esm/exports/testkit/jsdom.js.map +1 -0
- package/dist/esm/exports/testkit/playwright.js +2 -0
- package/dist/esm/exports/testkit/playwright.js.map +1 -0
- package/dist/esm/exports/testkit/puppeteer.js +2 -0
- package/dist/esm/exports/testkit/puppeteer.js.map +1 -0
- package/dist/esm/hooks/useCommonCollectionFeatures.js +8 -3
- package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/esm/hooks/useDragAndDropBaseProps.js +8 -4
- package/dist/esm/hooks/useDragAndDropBaseProps.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useViews.js +106 -0
- package/dist/esm/hooks/useViews.js.map +1 -0
- package/dist/esm/providers/AutoPatternsOverridesContext.js.map +1 -1
- package/dist/esm/testkit/enzyme.js +4 -0
- package/dist/esm/testkit/enzyme.js.map +1 -0
- package/dist/esm/testkit/jsdom.js +4 -0
- package/dist/esm/testkit/jsdom.js.map +1 -0
- package/dist/esm/testkit/playwright.js +4 -0
- package/dist/esm/testkit/playwright.js.map +1 -0
- package/dist/esm/testkit/puppeteer.js +4 -0
- package/dist/esm/testkit/puppeteer.js.map +1 -0
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts +45 -0
- package/dist/types/components/AutoPatternsApp/AutoPatternsApp.uni.driver.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts +81 -0
- package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.uni.driver.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsGrid/AutoPatternsGrid.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
- package/dist/types/exports/testkit/enzyme.d.ts +2 -0
- package/dist/types/exports/testkit/enzyme.d.ts.map +1 -0
- package/dist/types/exports/testkit/jsdom.d.ts +2 -0
- package/dist/types/exports/testkit/jsdom.d.ts.map +1 -0
- package/dist/types/exports/testkit/playwright.d.ts +2 -0
- package/dist/types/exports/testkit/playwright.d.ts.map +1 -0
- package/dist/types/exports/testkit/puppeteer.d.ts +2 -0
- package/dist/types/exports/testkit/puppeteer.d.ts.map +1 -0
- package/dist/types/hooks/useCommonCollectionFeatures.d.ts +3 -2
- package/dist/types/hooks/useCommonCollectionFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useDragAndDropBaseProps.d.ts.map +1 -1
- package/dist/types/hooks/useGridFeatures.d.ts +1 -0
- package/dist/types/hooks/useGridFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableFeatures.d.ts +1 -0
- package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -0
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useViews.d.ts +4 -0
- package/dist/types/hooks/useViews.d.ts.map +1 -0
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts +1 -0
- package/dist/types/providers/AutoPatternsOverridesContext.d.ts.map +1 -1
- package/dist/types/testkit/enzyme.d.ts +16 -0
- package/dist/types/testkit/enzyme.d.ts.map +1 -0
- package/dist/types/testkit/jsdom.d.ts +16 -0
- package/dist/types/testkit/jsdom.d.ts.map +1 -0
- package/dist/types/testkit/playwright.d.ts +20 -0
- package/dist/types/testkit/playwright.d.ts.map +1 -0
- package/dist/types/testkit/puppeteer.d.ts +20 -0
- package/dist/types/testkit/puppeteer.d.ts.map +1 -0
- package/dist/types/types/CollectionPageConfig.d.ts +193 -1
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/mcp-docs/app_config_structure.md +95 -0
- package/mcp-docs/auto-patterns-guide.md +721 -15
- package/mcp-docs/custom_overrides.md +37 -0
- package/mcp-docs/error_handling.md +251 -15
- package/mcp-docs/index.md +4 -0
- package/mcp-docs/views.md +335 -0
- package/package.json +49 -15
|
@@ -315,6 +315,47 @@ export interface AppConfig {
|
|
|
315
315
|
};
|
|
316
316
|
showTotal?: boolean; // Show total items on toolbar. Default: false
|
|
317
317
|
};
|
|
318
|
+
views?: {
|
|
319
|
+
enabled?: boolean; // Whether to enable the views feature. Default: false
|
|
320
|
+
saveViewModalProps?: {
|
|
321
|
+
placeholderName?: string; // Placeholder text for the "new view" input when saving a new view
|
|
322
|
+
learnMore?: {
|
|
323
|
+
url?: string; // URL for the help/learn-more link in the Save View modal
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
viewsDropdownProps?: {
|
|
327
|
+
showTotal?: boolean; // Show total items count next to the current view name. Default: false
|
|
328
|
+
hideAllItemsView?: boolean; // Hide the built-in "All Items" view from the dropdown. Only works when custom presets exist. Default: false
|
|
329
|
+
customAllItemsViewLabel?: string; // Custom label for the "All Items" view. Ignored if a preset has `isDefaultView: true`. Default: "All items"
|
|
330
|
+
};
|
|
331
|
+
presets?:
|
|
332
|
+
| {
|
|
333
|
+
type: 'categories';
|
|
334
|
+
categories: {
|
|
335
|
+
id: string; // Unique category identifier. ⚠️ Don't use `predefined-views` and `saved-views` as these are reserved
|
|
336
|
+
label: string; // Category display name shown in the views control
|
|
337
|
+
views: {}[]; // Views included in this category (same structure as presets.views)
|
|
338
|
+
icon?: {
|
|
339
|
+
tooltipContent: string; // Tooltip text shown on hover over the help icon
|
|
340
|
+
size?: 'small' | 'medium'; // Size of the help icon. Default: 'small'
|
|
341
|
+
};
|
|
342
|
+
}[];
|
|
343
|
+
}
|
|
344
|
+
| {
|
|
345
|
+
type: 'views';
|
|
346
|
+
views: {
|
|
347
|
+
id: string; // Unique view identifier. ⚠️ Don't use `all-items-view` as this is reserved
|
|
348
|
+
label: string; // Display name for the view shown in the dropdown
|
|
349
|
+
filters?: Record<string, AutoFilterValue | null>; // Filters to apply when the view is selected. Keys must match filter IDs declared in the filters configuration
|
|
350
|
+
columnPreferences?: { // Column preferences controlling column visibility, sort, and order for this view
|
|
351
|
+
id: string; // Column unique identifier
|
|
352
|
+
direction?: 'asc' | 'desc'; // Sorting direction of the column in the view
|
|
353
|
+
show?: boolean; // Pass false to hide the column from the view
|
|
354
|
+
}[];
|
|
355
|
+
isDefaultView?: boolean; // Makes this view the default selection instead of the "All Items" view. Default: false
|
|
356
|
+
}[];
|
|
357
|
+
};
|
|
358
|
+
};
|
|
318
359
|
search?: {
|
|
319
360
|
shown?: boolean; // Show/hide the search
|
|
320
361
|
};
|
|
@@ -340,6 +381,9 @@ export interface AppConfig {
|
|
|
340
381
|
* Whether drag and drop is enabled. When enabled, the [schema](./schema_config.md) must support a "move" action.
|
|
341
382
|
*/
|
|
342
383
|
enabled: boolean;
|
|
384
|
+
dragAndDropCancel?: {
|
|
385
|
+
id?: string; // Optional ID that maps to a dynamic drag-and-drop cancel override function
|
|
386
|
+
};
|
|
343
387
|
};
|
|
344
388
|
layout: [ // Array of layout items that define what components to render
|
|
345
389
|
{
|
|
@@ -552,6 +596,57 @@ type LayoutContent =
|
|
|
552
596
|
};
|
|
553
597
|
};
|
|
554
598
|
|
|
599
|
+
type AutoFilterValue =
|
|
600
|
+
| {
|
|
601
|
+
filterType: 'date';
|
|
602
|
+
value:
|
|
603
|
+
| {
|
|
604
|
+
preset: DateRangeOptions | DateRangePredefinedPresetOptions;
|
|
605
|
+
}
|
|
606
|
+
| {
|
|
607
|
+
// Start date. format: MM-DD-YYYY
|
|
608
|
+
from?: string;
|
|
609
|
+
// End date. format: MM-DD-YYYY
|
|
610
|
+
to?: string;
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
| {
|
|
614
|
+
filterType: 'number';
|
|
615
|
+
value: {
|
|
616
|
+
// Minimum allowed value. default is negative infinity
|
|
617
|
+
from?: number;
|
|
618
|
+
// Maximum allowed value. default is infinity
|
|
619
|
+
to?: number;
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
| {
|
|
623
|
+
filterType: 'boolean';
|
|
624
|
+
value: {
|
|
625
|
+
// checked for true, unchecked for false, all for all
|
|
626
|
+
id: 'checked' | 'unchecked' | 'all';
|
|
627
|
+
// A string that will appear on the filter tag, after the field name, when the filter is active (appears as <field-name>: <name>)
|
|
628
|
+
name: string;
|
|
629
|
+
}[];
|
|
630
|
+
}
|
|
631
|
+
| {
|
|
632
|
+
filterType: 'enum';
|
|
633
|
+
value: {
|
|
634
|
+
// The option value (from the filter config)
|
|
635
|
+
id: string;
|
|
636
|
+
// A string that will appear on the filter tag, after the field name, when the filter is active (appears as <field-name>: <name>)
|
|
637
|
+
name: string;
|
|
638
|
+
}[];
|
|
639
|
+
}
|
|
640
|
+
| {
|
|
641
|
+
filterType: 'reference';
|
|
642
|
+
value: {
|
|
643
|
+
// The option value (from the filter config)
|
|
644
|
+
id: string;
|
|
645
|
+
// A string that will appear on the filter tag, after the field name, when the filter is active (appears as <field-name>: <name>)
|
|
646
|
+
name: string;
|
|
647
|
+
}[];
|
|
648
|
+
};
|
|
649
|
+
|
|
555
650
|
---
|
|
556
651
|
|
|
557
652
|
## Filters Configuration Notes
|
|
@@ -3661,6 +3756,40 @@ function columnOverride(props: IColumnValue<string>) {
|
|
|
3661
3756
|
}
|
|
3662
3757
|
```
|
|
3663
3758
|
|
|
3759
|
+
### Important Guidelines for Column Functions
|
|
3760
|
+
|
|
3761
|
+
**Column ID Naming**: Column IDs are always in camelCase, and your function names should match exactly:
|
|
3762
|
+
- Column ID: `petName` → Function name: `petName`
|
|
3763
|
+
- Column ID: `isVaccinated` → Function name: `isVaccinated`
|
|
3764
|
+
- Column ID: `lastActivity` → Function name: `lastActivity`
|
|
3765
|
+
|
|
3766
|
+
**React Limitations**: Column override functions are **NOT React function components**, which means:
|
|
3767
|
+
- ❌ **No React hooks allowed** (useState, useEffect, useContext, etc.)
|
|
3768
|
+
- ❌ **No custom hook calls** inside the function
|
|
3769
|
+
- ✅ **Only pure rendering logic** with JSX return
|
|
3770
|
+
|
|
3771
|
+
**Using Hooks in Column Overrides**: If you need React hooks, create a separate React component and return it from your column function:
|
|
3772
|
+
|
|
3773
|
+
```typescript
|
|
3774
|
+
// ❌ WRONG - Hooks directly in column function
|
|
3775
|
+
export function myColumn({ value, row }: IColumnValue<string>) {
|
|
3776
|
+
const [state, setState] = useState(value); // ERROR: Hooks not allowed!
|
|
3777
|
+
return <span>{state}</span>;
|
|
3778
|
+
}
|
|
3779
|
+
|
|
3780
|
+
// ✅ CORRECT - Hooks in separate component
|
|
3781
|
+
function MyColumnComponent({ value, row }: IColumnValue<string>) {
|
|
3782
|
+
const [state, setState] = useState(value); // ✅ Hooks allowed in React components
|
|
3783
|
+
const contextValue = useContext(MyContext); // ✅ Context hooks work here
|
|
3784
|
+
|
|
3785
|
+
return <span>{state} - {contextValue}</span>;
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
export function myColumn(props: IColumnValue<string>) {
|
|
3789
|
+
return <MyColumnComponent {...props} />; // ✅ Return React component
|
|
3790
|
+
}
|
|
3791
|
+
```
|
|
3792
|
+
|
|
3664
3793
|
### Type-Specific Examples
|
|
3665
3794
|
|
|
3666
3795
|
The generic type `T` in `IColumnValue<T>` should match your field's data type:
|
|
@@ -3922,6 +4051,9 @@ AutoPatternsOverridesProvider
|
|
|
3922
4051
|
|
|
3923
4052
|
### Important Guidelines
|
|
3924
4053
|
|
|
4054
|
+
- **Function Naming**: Column function names must be in camelCase and match the column ID exactly
|
|
4055
|
+
- **No React Hooks**: Column functions are NOT React components - no useState, useEffect, useContext, etc.
|
|
4056
|
+
- **Hook Workaround**: If you need hooks, create a separate React component and return it from your column function
|
|
3925
4057
|
- **TypeScript Usage**: Always use `IColumnValue<T>` and import it from `@wix/auto-patterns/types`
|
|
3926
4058
|
- **Type Matching**: Ensure the generic type `T` matches your field's actual data type (string, number, boolean, etc.)
|
|
3927
4059
|
- **Performance**: Remember that column functions are called for every row, so keep calculations lightweight
|
|
@@ -4735,12 +4867,53 @@ Slots provide a powerful way to enhance collection pages with custom functionali
|
|
|
4735
4867
|
|
|
4736
4868
|
**⚠️ CRITICAL**: When implementing custom data sources that make HTTP requests, you **MUST** wrap specific HTTP calls with proper error handling. This ensures consistent error management, prevents unhandled promise rejections, and provides better user experience.
|
|
4737
4869
|
|
|
4870
|
+
## 🚨 GOLDEN RULE: If it's a Wix Library, Wrap it with errorHandler!
|
|
4871
|
+
|
|
4872
|
+
**Simple Rule for AI Agents:**
|
|
4873
|
+
- **ANY Wix SDK call** from libraries with `@wix/` prefix → **ALWAYS wrap with `errorHandler.withErrorHandler`**
|
|
4874
|
+
- This includes: `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `@wix/crm`, and ALL other `@wix/*` packages
|
|
4875
|
+
- **NO exceptions** - all Wix SDK calls must use error handling
|
|
4876
|
+
|
|
4877
|
+
### ❌ DON'T DO THIS (Common Mistake)
|
|
4878
|
+
|
|
4879
|
+
```typescript
|
|
4880
|
+
import { items } from '@wix/data';
|
|
4881
|
+
|
|
4882
|
+
// ❌ WRONG - No errorHandler wrapping
|
|
4883
|
+
async function getAllPets() {
|
|
4884
|
+
try {
|
|
4885
|
+
const result = await items.query('WixPets').find();
|
|
4886
|
+
return result.items;
|
|
4887
|
+
} catch (error) {
|
|
4888
|
+
console.error(error);
|
|
4889
|
+
throw error;
|
|
4890
|
+
}
|
|
4891
|
+
}
|
|
4892
|
+
```
|
|
4893
|
+
|
|
4894
|
+
### ✅ DO THIS (Correct Pattern)
|
|
4895
|
+
|
|
4896
|
+
```typescript
|
|
4897
|
+
import { items } from '@wix/data';
|
|
4898
|
+
import { errorHandler } from '@wix/essentials';
|
|
4899
|
+
|
|
4900
|
+
// ✅ CORRECT - Wix SDK call wrapped with errorHandler
|
|
4901
|
+
async function getAllPets() {
|
|
4902
|
+
return errorHandler.withErrorHandler(
|
|
4903
|
+
async () => {
|
|
4904
|
+
const result = await items.query('WixPets').find();
|
|
4905
|
+
return result.items;
|
|
4906
|
+
},
|
|
4907
|
+
{}
|
|
4908
|
+
);
|
|
4909
|
+
}
|
|
4910
|
+
```
|
|
4738
4911
|
## What Requires Error Handling
|
|
4739
4912
|
|
|
4740
4913
|
**ONLY the following HTTP requests** in your custom data source actions must be wrapped with `errorHandler.withErrorHandler`:
|
|
4741
4914
|
|
|
4742
4915
|
- **httpClient from @wix/essentials** (e.g., `httpClient.request(getDummyEntity(...))`)
|
|
4743
|
-
- **Wix
|
|
4916
|
+
- **Wix API calls from libraries with `wix/` prefix** (e.g., `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `collections.getDataCollection()`, etc.)
|
|
4744
4917
|
- **httpClient.fetchWithAuth()** calls
|
|
4745
4918
|
|
|
4746
4919
|
**DO NOT use errorHandler.withErrorHandler with:**
|
|
@@ -4878,12 +5051,68 @@ return errorHandler.withErrorHandler(async () => {
|
|
|
4878
5051
|
}, {});
|
|
4879
5052
|
```
|
|
4880
5053
|
|
|
4881
|
-
**Wix APIs (wix/data, wix/stores):**
|
|
5054
|
+
**Wix APIs (@wix/data, @wix/stores, @wix/crm, etc.):**
|
|
4882
5055
|
|
|
4883
5056
|
```typescript
|
|
5057
|
+
import { items } from '@wix/data';
|
|
5058
|
+
import { errorHandler } from '@wix/essentials';
|
|
5059
|
+
|
|
5060
|
+
// ✅ CORRECT: Wix Data API calls wrapped with errorHandler
|
|
4884
5061
|
return errorHandler.withErrorHandler(async () => {
|
|
4885
5062
|
return await items.get(collectionId, entityId);
|
|
4886
5063
|
}, {});
|
|
5064
|
+
|
|
5065
|
+
// ✅ CORRECT: Query operations wrapped with errorHandler
|
|
5066
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5067
|
+
return await items.query('WixPets').find();
|
|
5068
|
+
}, {});
|
|
5069
|
+
|
|
5070
|
+
// ✅ CORRECT: Insert operations wrapped with errorHandler
|
|
5071
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5072
|
+
return await items.insert(collectionId, dataItem);
|
|
5073
|
+
}, {});
|
|
5074
|
+
|
|
5075
|
+
// ✅ CORRECT: Update operations wrapped with errorHandler
|
|
5076
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5077
|
+
return await items.update(collectionId, dataItem);
|
|
5078
|
+
}, {});
|
|
5079
|
+
|
|
5080
|
+
// ✅ CORRECT: Delete operations wrapped with errorHandler
|
|
5081
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5082
|
+
return await items.remove(collectionId, itemId);
|
|
5083
|
+
}, {});
|
|
5084
|
+
|
|
5085
|
+
// ✅ CORRECT: Bulk delete operations wrapped with errorHandler
|
|
5086
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5087
|
+
return await items.bulkRemove(collectionId, itemIds);
|
|
5088
|
+
}, {});
|
|
5089
|
+
```
|
|
5090
|
+
|
|
5091
|
+
**All Other Wix API calls from libraries with `@wix/` prefix:**
|
|
5092
|
+
|
|
5093
|
+
```typescript
|
|
5094
|
+
import { stores } from '@wix/stores';
|
|
5095
|
+
import { events } from '@wix/events';
|
|
5096
|
+
import { bookings } from '@wix/bookings';
|
|
5097
|
+
import { contacts } from '@wix/crm';
|
|
5098
|
+
import { errorHandler } from '@wix/essentials';
|
|
5099
|
+
|
|
5100
|
+
// ✅ CORRECT: All Wix API calls from @wix/* libraries must be wrapped
|
|
5101
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5102
|
+
return await stores.queryProducts().find();
|
|
5103
|
+
}, {});
|
|
5104
|
+
|
|
5105
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5106
|
+
return await events.queryEvents().find();
|
|
5107
|
+
}, {});
|
|
5108
|
+
|
|
5109
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5110
|
+
return await bookings.queryBookings().find();
|
|
5111
|
+
}, {});
|
|
5112
|
+
|
|
5113
|
+
return errorHandler.withErrorHandler(async () => {
|
|
5114
|
+
return await contacts.queryContacts().find();
|
|
5115
|
+
}, {});
|
|
4887
5116
|
```
|
|
4888
5117
|
|
|
4889
5118
|
**httpClient.fetchWithAuth() calls:**
|
|
@@ -4931,25 +5160,120 @@ The error handling in your custom data source integrates seamlessly with AutoPat
|
|
|
4931
5160
|
**BEFORE implementing ANY custom action or data source, AI agents MUST verify:**
|
|
4932
5161
|
|
|
4933
5162
|
### ✅ Error Handling Requirements
|
|
4934
|
-
- **
|
|
4935
|
-
-
|
|
4936
|
-
- **httpClient
|
|
4937
|
-
- **
|
|
4938
|
-
- **
|
|
4939
|
-
-
|
|
5163
|
+
- ✅ **ALL Wix API calls from `@wix/*` libraries** are wrapped with `errorHandler.withErrorHandler`
|
|
5164
|
+
- Including: `@wix/data`, `@wix/stores`, `@wix/events`, `@wix/bookings`, `@wix/crm`, and ALL other `@wix/*` packages
|
|
5165
|
+
- ✅ **httpClient from @wix/essentials** is wrapped with `errorHandler.withErrorHandler`
|
|
5166
|
+
- ✅ **httpClient.fetchWithAuth()** calls are wrapped with `errorHandler.withErrorHandler`
|
|
5167
|
+
- ✅ **External API calls are NOT wrapped** with errorHandler (e.g., fetch(), axios, third-party HTTP clients)
|
|
5168
|
+
- ✅ **SDK actions are used directly** without error handling (e.g., `sdk.getOptimisticActions()`, `sdk.getSchema()`)
|
|
5169
|
+
- ✅ **@wix/essentials** is installed as a dependency
|
|
5170
|
+
|
|
5171
|
+
### ✅ Correct API Signature Verification
|
|
5172
|
+
- ✅ **Check TypeScript/linter errors FIRST** - they tell you when the API is used incorrectly
|
|
5173
|
+
- ✅ **Verify imports are correct** - `import { items } from '@wix/data'` (not default imports)
|
|
5174
|
+
- ✅ **Use correct method signatures** - refer to the API reference section
|
|
5175
|
+
- ✅ **Pass correct parameters** - verify collectionId, itemId, and data structure
|
|
5176
|
+
- ✅ **Handle return values correctly** - `.find()` returns `{ items, ... }`, not just items array
|
|
4940
5177
|
|
|
4941
5178
|
### ✅ Implementation Checklist
|
|
4942
|
-
- **Read this error handling documentation** before implementing any custom action
|
|
4943
|
-
- **Identify the type of HTTP request** being made (Wix vs External)
|
|
4944
|
-
- **Apply the correct error handling pattern** based on the request type
|
|
4945
|
-
- **Test error scenarios** to ensure proper error handling
|
|
4946
|
-
- **Verify error messages** are user-friendly and actionable
|
|
5179
|
+
- ✅ **Read this error handling documentation** before implementing any custom action
|
|
5180
|
+
- ✅ **Identify the type of HTTP request** being made (Wix vs External)
|
|
5181
|
+
- ✅ **Apply the correct error handling pattern** based on the request type
|
|
5182
|
+
- ✅ **Test error scenarios** to ensure proper error handling
|
|
5183
|
+
- ✅ **Verify error messages** are user-friendly and actionable
|
|
5184
|
+
- ✅ **Run linter after implementation** to catch any API usage errors
|
|
4947
5185
|
|
|
4948
5186
|
### ✅ Common Mistakes to Avoid
|
|
4949
5187
|
- ❌ **NEVER** wrap external API calls (fetch, axios) with errorHandler
|
|
4950
5188
|
- ❌ **NEVER** wrap SDK methods (sdk.getOptimisticActions) with errorHandler
|
|
4951
5189
|
- ❌ **NEVER** forget to wrap Wix HTTP requests with errorHandler
|
|
4952
5190
|
- ❌ **NEVER** implement custom actions without reading this documentation first
|
|
5191
|
+
- ❌ **NEVER** use incorrect API signatures (e.g., `items.queryDataItems()` instead of `items.query()`)
|
|
5192
|
+
- ❌ **NEVER** ignore TypeScript/linter errors - they indicate incorrect API usage
|
|
5193
|
+
- ❌ **NEVER** use try-catch blocks instead of errorHandler for Wix SDK calls
|
|
5194
|
+
|
|
5195
|
+
## 🎯 Common Wix SDK API Reference
|
|
5196
|
+
|
|
5197
|
+
### @wix/data - Data Items API
|
|
5198
|
+
|
|
5199
|
+
**ALWAYS use with errorHandler.withErrorHandler:**
|
|
5200
|
+
|
|
5201
|
+
```typescript
|
|
5202
|
+
import { items } from '@wix/data';
|
|
5203
|
+
import { errorHandler } from '@wix/essentials';
|
|
5204
|
+
|
|
5205
|
+
// Query all items
|
|
5206
|
+
errorHandler.withErrorHandler(async () => {
|
|
5207
|
+
const result = await items.query('WixPets').find();
|
|
5208
|
+
return result.items;
|
|
5209
|
+
}, {});
|
|
5210
|
+
|
|
5211
|
+
// Query with filters
|
|
5212
|
+
errorHandler.withErrorHandler(async () => {
|
|
5213
|
+
const result = await items.query('WixPets')
|
|
5214
|
+
.contains('name', 'fluffy')
|
|
5215
|
+
.eq('age', 5)
|
|
5216
|
+
.find();
|
|
5217
|
+
return result.items;
|
|
5218
|
+
}, {});
|
|
5219
|
+
|
|
5220
|
+
// Get single item by ID
|
|
5221
|
+
errorHandler.withErrorHandler(async () => {
|
|
5222
|
+
const item = await items.get('WixPets', itemId);
|
|
5223
|
+
return item;
|
|
5224
|
+
}, {});
|
|
5225
|
+
|
|
5226
|
+
// Insert new item
|
|
5227
|
+
errorHandler.withErrorHandler(async () => {
|
|
5228
|
+
const newItem = await items.insert('WixPets', { name: 'Fluffy', age: 5 });
|
|
5229
|
+
return newItem;
|
|
5230
|
+
}, {});
|
|
5231
|
+
|
|
5232
|
+
// Update existing item
|
|
5233
|
+
errorHandler.withErrorHandler(async () => {
|
|
5234
|
+
const updatedItem = await items.update('WixPets', { _id: itemId, name: 'Updated Name' });
|
|
5235
|
+
return updatedItem;
|
|
5236
|
+
}, {});
|
|
5237
|
+
|
|
5238
|
+
// Delete single item
|
|
5239
|
+
errorHandler.withErrorHandler(async () => {
|
|
5240
|
+
await items.remove('WixPets', itemId);
|
|
5241
|
+
}, {});
|
|
5242
|
+
|
|
5243
|
+
// Bulk delete items
|
|
5244
|
+
errorHandler.withErrorHandler(async () => {
|
|
5245
|
+
await items.bulkRemove('WixPets', [itemId1, itemId2, itemId3]);
|
|
5246
|
+
}, {});
|
|
5247
|
+
```
|
|
5248
|
+
|
|
5249
|
+
### @wix/essentials - Error Handler
|
|
5250
|
+
|
|
5251
|
+
```typescript
|
|
5252
|
+
import { errorHandler } from '@wix/essentials';
|
|
5253
|
+
|
|
5254
|
+
// Basic pattern (recommended)
|
|
5255
|
+
errorHandler.withErrorHandler(
|
|
5256
|
+
async () => {
|
|
5257
|
+
// Your Wix SDK call here
|
|
5258
|
+
return await items.query('WixPets').find();
|
|
5259
|
+
},
|
|
5260
|
+
{
|
|
5261
|
+
// Optional: Custom error handling
|
|
5262
|
+
handleError: (error) => {
|
|
5263
|
+
console.error('Custom error handling:', error);
|
|
5264
|
+
throw error; // Re-throw to show error to user
|
|
5265
|
+
},
|
|
5266
|
+
}
|
|
5267
|
+
);
|
|
5268
|
+
|
|
5269
|
+
// Simple pattern (empty options object)
|
|
5270
|
+
errorHandler.withErrorHandler(
|
|
5271
|
+
async () => {
|
|
5272
|
+
return await items.query('WixPets').find();
|
|
5273
|
+
},
|
|
5274
|
+
{}
|
|
5275
|
+
);
|
|
5276
|
+
```
|
|
4953
5277
|
|
|
4954
5278
|
## Quick Decision Tree for AI Agents
|
|
4955
5279
|
|
|
@@ -4960,7 +5284,7 @@ The error handling in your custom data source integrates seamlessly with AutoPat
|
|
|
4960
5284
|
- **YES** → Go to step 2
|
|
4961
5285
|
|
|
4962
5286
|
2. **What type of HTTP request?**
|
|
4963
|
-
- **Wix
|
|
5287
|
+
- **Wix API libraries with `@wix/` prefix** (@wix/data, @wix/stores, @wix/events, @wix/bookings, @wix/crm) → **WRAP with errorHandler.withErrorHandler**
|
|
4964
5288
|
- **External APIs** (fetch, axios, third-party) → **NO errorHandler needed**
|
|
4965
5289
|
- **SDK methods** (sdk.getOptimisticActions, sdk.getSchema) → **NO errorHandler needed**
|
|
4966
5290
|
|
|
@@ -4969,6 +5293,15 @@ The error handling in your custom data source integrates seamlessly with AutoPat
|
|
|
4969
5293
|
- **External requests** are NOT wrapped
|
|
4970
5294
|
- **SDK methods** are used directly
|
|
4971
5295
|
|
|
5296
|
+
## 🚨 TypeScript Error Detection
|
|
5297
|
+
|
|
5298
|
+
**CRITICAL**: If you see TypeScript/linter errors when using Wix SDK methods:
|
|
5299
|
+
|
|
5300
|
+
1. ✅ **Check the import** - Make sure you're importing from the correct package
|
|
5301
|
+
2. ✅ **Check the method signature** - Verify you're using the correct API signature (refer to the API reference above)
|
|
5302
|
+
3. ✅ **Check errorHandler wrapping** - Ensure the call is wrapped with `errorHandler.withErrorHandler`
|
|
5303
|
+
4. ✅ **Run linter** - Read the linter error message carefully; it tells you what's wrong
|
|
5304
|
+
|
|
4972
5305
|
## Complete Examples for All Custom Action Types
|
|
4973
5306
|
|
|
4974
5307
|
### ActionCell Custom Actions
|
|
@@ -5161,9 +5494,44 @@ export const myCustomDataSource = async (collectionId: string, context: any) =>
|
|
|
5161
5494
|
};
|
|
5162
5495
|
```
|
|
5163
5496
|
|
|
5497
|
+
### Actions Using Wix API Libraries (REQUIRES errorHandler)
|
|
5498
|
+
|
|
5499
|
+
**Example 7: Action using Wix API libraries with `wix/` prefix (REQUIRES errorHandler)**
|
|
5500
|
+
```typescript
|
|
5501
|
+
import { errorHandler } from '@wix/essentials';
|
|
5502
|
+
import { data } from '@wix/data';
|
|
5503
|
+
import { stores } from '@wix/stores';
|
|
5504
|
+
import { CustomActionCellActionResolver } from '@wix/auto-patterns';
|
|
5505
|
+
|
|
5506
|
+
export const syncWithWixData: CustomActionCellActionResolver = (params) => {
|
|
5507
|
+
const { actionParams, sdk } = params;
|
|
5508
|
+
const { item } = actionParams;
|
|
5509
|
+
|
|
5510
|
+
return {
|
|
5511
|
+
label: 'Sync with Wix Data',
|
|
5512
|
+
icon: <SyncIcon />,
|
|
5513
|
+
onClick: () => {
|
|
5514
|
+
// ✅ CORRECT: Wix API library calls wrapped with errorHandler
|
|
5515
|
+
errorHandler.withErrorHandler(
|
|
5516
|
+
async () => {
|
|
5517
|
+
// Using @wix/data library
|
|
5518
|
+
const dataResult = await data.query('MyCollection').eq('id', item.id).find();
|
|
5519
|
+
|
|
5520
|
+
// Using @wix/stores library
|
|
5521
|
+
const productResult = await stores.queryProducts().eq('sku', item.sku).find();
|
|
5522
|
+
|
|
5523
|
+
return { dataResult, productResult };
|
|
5524
|
+
},
|
|
5525
|
+
{}
|
|
5526
|
+
);
|
|
5527
|
+
},
|
|
5528
|
+
};
|
|
5529
|
+
};
|
|
5530
|
+
```
|
|
5531
|
+
|
|
5164
5532
|
### Actions Using SDK Methods (NO errorHandler needed)
|
|
5165
5533
|
|
|
5166
|
-
**Example
|
|
5534
|
+
**Example 8: Action using SDK methods (NO errorHandler needed)**
|
|
5167
5535
|
```typescript
|
|
5168
5536
|
import { CustomActionCellActionResolver } from '@wix/auto-patterns';
|
|
5169
5537
|
|
|
@@ -5192,3 +5560,341 @@ export const quickUpdate: CustomActionCellActionResolver = (params) => {
|
|
|
5192
5560
|
};
|
|
5193
5561
|
};
|
|
5194
5562
|
```
|
|
5563
|
+
|
|
5564
|
+
---
|
|
5565
|
+
|
|
5566
|
+
# Views Configuration (Collection Level)
|
|
5567
|
+
|
|
5568
|
+
Views let users quickly switch between predefined table or grid configurations (filters, column visibility/sort), and optionally save their own configurations.
|
|
5569
|
+
|
|
5570
|
+
To configure views in a `collectionPage`, add a `views` property inside the page's component configuration object.
|
|
5571
|
+
|
|
5572
|
+
### Key Guidelines
|
|
5573
|
+
|
|
5574
|
+
* **enabled**: Must be set to `true` to activate the views feature.
|
|
5575
|
+
* **Precedence over toolbarTitle**: When views are enabled, they take precedence over `toolbarTitle` configuration.
|
|
5576
|
+
* **Column preferences**: To control column visibility and order in views, you must enable custom columns in your table config (`table.customColumns.enabled: true`).
|
|
5577
|
+
* **Filter references**: Filters used in preset views must reference existing filter IDs from your `filters.items` configuration.
|
|
5578
|
+
* **Reserved identifiers**: Don't use reserved IDs like `predefined-views`, `saved-views`, or `all-items-view`.
|
|
5579
|
+
|
|
5580
|
+
### Views vs Categories
|
|
5581
|
+
|
|
5582
|
+
* **Individual views** (`type: 'views'`): Use for simple preset configurations
|
|
5583
|
+
* **Categories** (`type: 'categories'`): Use to group related views together under labeled sections
|
|
5584
|
+
|
|
5585
|
+
### Default View Behavior
|
|
5586
|
+
|
|
5587
|
+
* By default, the "All Items" view is shown as the first option
|
|
5588
|
+
* Set `isDefaultView: true` on any preset view to make it the default instead
|
|
5589
|
+
* Use `hideAllItemsView: true` to hide the "All Items" view when custom presets exist
|
|
5590
|
+
* Use `customAllItemsViewLabel` to change the "All Items" label (ignored if a preset is set as default)
|
|
5591
|
+
|
|
5592
|
+
## Configuration
|
|
5593
|
+
|
|
5594
|
+
For the complete interface definitions and detailed field documentation, see the views section in [app_config_structure.md](./app_config_structure.md#views-configuration-notes)
|
|
5595
|
+
|
|
5596
|
+
## Usage Examples - Basic
|
|
5597
|
+
|
|
5598
|
+
### Simple setup
|
|
5599
|
+
Enable the views feature and manage views (save, rename, delete, set as default).
|
|
5600
|
+
|
|
5601
|
+
```ts
|
|
5602
|
+
views: {
|
|
5603
|
+
enabled: true
|
|
5604
|
+
}
|
|
5605
|
+
```
|
|
5606
|
+
|
|
5607
|
+
### Preset view
|
|
5608
|
+
Create a preset view.
|
|
5609
|
+
|
|
5610
|
+
For example a view that displays the `name` column in ascending order.
|
|
5611
|
+
```ts
|
|
5612
|
+
views: {
|
|
5613
|
+
enabled: true,
|
|
5614
|
+
presets: {
|
|
5615
|
+
type: 'views',
|
|
5616
|
+
views: [
|
|
5617
|
+
{
|
|
5618
|
+
id: 'ascending-name',
|
|
5619
|
+
label: 'Ascending names',
|
|
5620
|
+
columnPreferences: [{ id: 'name', direction: 'asc' }],
|
|
5621
|
+
},
|
|
5622
|
+
],
|
|
5623
|
+
},
|
|
5624
|
+
}
|
|
5625
|
+
```
|
|
5626
|
+
|
|
5627
|
+
### Presets Categories
|
|
5628
|
+
Group views under labeled categories.
|
|
5629
|
+
|
|
5630
|
+
For example, two views that sort the `price` column ascending and descending, grouped under 'Price' category
|
|
5631
|
+
|
|
5632
|
+
```ts
|
|
5633
|
+
views: {
|
|
5634
|
+
enabled: true,
|
|
5635
|
+
presets: {
|
|
5636
|
+
type: 'categories',
|
|
5637
|
+
categories: [
|
|
5638
|
+
{
|
|
5639
|
+
id: 'price',
|
|
5640
|
+
label: 'Price',
|
|
5641
|
+
views: [
|
|
5642
|
+
{
|
|
5643
|
+
id: 'price-low-to-high',
|
|
5644
|
+
label: 'Low to High',
|
|
5645
|
+
columnPreferences: [{ id: 'price', direction: 'asc' }],
|
|
5646
|
+
},
|
|
5647
|
+
{
|
|
5648
|
+
id: 'price-high-to-low',
|
|
5649
|
+
label: 'High to Low',
|
|
5650
|
+
columnPreferences: [{ id: 'price', direction: 'desc' }],
|
|
5651
|
+
},
|
|
5652
|
+
],
|
|
5653
|
+
},
|
|
5654
|
+
],
|
|
5655
|
+
},
|
|
5656
|
+
}
|
|
5657
|
+
```
|
|
5658
|
+
|
|
5659
|
+
### Category help tooltip icon
|
|
5660
|
+
Add a help tooltip icon next to the category name using the `icon` property.
|
|
5661
|
+
|
|
5662
|
+
```ts
|
|
5663
|
+
views: {
|
|
5664
|
+
enabled: true,
|
|
5665
|
+
presets: {
|
|
5666
|
+
type: 'categories',
|
|
5667
|
+
categories: [
|
|
5668
|
+
{
|
|
5669
|
+
id: 'price',
|
|
5670
|
+
label: 'Price',
|
|
5671
|
+
icon: {
|
|
5672
|
+
tooltipContent: 'These views sort by the item price.',
|
|
5673
|
+
size: 'small',
|
|
5674
|
+
},
|
|
5675
|
+
views: [
|
|
5676
|
+
// some views...
|
|
5677
|
+
],
|
|
5678
|
+
},
|
|
5679
|
+
],
|
|
5680
|
+
},
|
|
5681
|
+
}
|
|
5682
|
+
```
|
|
5683
|
+
|
|
5684
|
+
## Usage Examples - Advanced presets
|
|
5685
|
+
|
|
5686
|
+
### Columns visibility and order
|
|
5687
|
+
```
|
|
5688
|
+
Note that when controlling columns visibility, you always need to specify which columns you wish to show. a column without `{show: true}` will be hidden.
|
|
5689
|
+
If you wish to hide a certain column or columns - you must pass all the other ids.
|
|
5690
|
+
```
|
|
5691
|
+
|
|
5692
|
+
The `columnPreferences` array controls both visibility and order together. The array order determines the display order, and `show: true` controls visibility.
|
|
5693
|
+
|
|
5694
|
+
Examples:
|
|
5695
|
+
|
|
5696
|
+
```ts
|
|
5697
|
+
views: {
|
|
5698
|
+
enabled: true,
|
|
5699
|
+
presets: {
|
|
5700
|
+
type: 'views',
|
|
5701
|
+
views: [
|
|
5702
|
+
{
|
|
5703
|
+
id: 'compact-view',
|
|
5704
|
+
label: 'Compact',
|
|
5705
|
+
columnPreferences: [
|
|
5706
|
+
// The columns will be displayed in this order, re-order the array to control the columns' order
|
|
5707
|
+
{ id: 'name', show: true},
|
|
5708
|
+
{ id: 'price', show: true },
|
|
5709
|
+
{ id: 'age', show: true },
|
|
5710
|
+
],
|
|
5711
|
+
}
|
|
5712
|
+
],
|
|
5713
|
+
},
|
|
5714
|
+
}
|
|
5715
|
+
```
|
|
5716
|
+
|
|
5717
|
+
### Filters
|
|
5718
|
+
|
|
5719
|
+
#### Date filter
|
|
5720
|
+
Apply a filter for date data type. A 'fixed' period can be used (last week, last month, next week...) or a custom range between actual dates.
|
|
5721
|
+
|
|
5722
|
+
Examples:
|
|
5723
|
+
```ts
|
|
5724
|
+
filters: {
|
|
5725
|
+
// some date filter definition with filterId: 'createdAt-filter', supporting presets and custom ranges
|
|
5726
|
+
},
|
|
5727
|
+
views: {
|
|
5728
|
+
enabled: true,
|
|
5729
|
+
presets: {
|
|
5730
|
+
type: 'views',
|
|
5731
|
+
views: [
|
|
5732
|
+
{
|
|
5733
|
+
// Fixed preset (last 7 days)
|
|
5734
|
+
id: 'recent-created',
|
|
5735
|
+
label: 'Created: Last 7 days',
|
|
5736
|
+
filters: {
|
|
5737
|
+
'createdAt-filter': { filterType: 'date', value: { preset: 'SEVEN_DAYS' } },
|
|
5738
|
+
},
|
|
5739
|
+
},
|
|
5740
|
+
{
|
|
5741
|
+
// Closed range (between two dates)
|
|
5742
|
+
id: 'created-in-2025',
|
|
5743
|
+
label: 'Created in 2025',
|
|
5744
|
+
filters: {
|
|
5745
|
+
'createdAt-filter': { filterType: 'date', value: { from: '01-01-2025', to: '12-31-2025' } },
|
|
5746
|
+
},
|
|
5747
|
+
},
|
|
5748
|
+
],
|
|
5749
|
+
},
|
|
5750
|
+
}
|
|
5751
|
+
```
|
|
5752
|
+
|
|
5753
|
+
#### Number filter
|
|
5754
|
+
Apply a filter for numeric data type. You can filter by minimum only, maximum only, or a closed range.
|
|
5755
|
+
|
|
5756
|
+
Examples:
|
|
5757
|
+
```ts
|
|
5758
|
+
filters: {
|
|
5759
|
+
// some number filter definition with filterId: 'price-filter' and lower boundary of 0
|
|
5760
|
+
},
|
|
5761
|
+
views: {
|
|
5762
|
+
enabled: true,
|
|
5763
|
+
presets: {
|
|
5764
|
+
type: 'views',
|
|
5765
|
+
views: [
|
|
5766
|
+
{
|
|
5767
|
+
// Closed range — 10 ≤ price ≤ 100
|
|
5768
|
+
id: 'price-10-to-100',
|
|
5769
|
+
label: 'Price: 10–100',
|
|
5770
|
+
filters: {
|
|
5771
|
+
'price-filter': { filterType: 'number', value: { from: 10, to: 100 } },
|
|
5772
|
+
},
|
|
5773
|
+
},
|
|
5774
|
+
],
|
|
5775
|
+
},
|
|
5776
|
+
}
|
|
5777
|
+
```
|
|
5778
|
+
|
|
5779
|
+
#### Boolean filter
|
|
5780
|
+
Apply a filter for boolean data type. Choose items where the value is true or false. You can use the `name` field to control what will be written in the filter label when it's applied.
|
|
5781
|
+
|
|
5782
|
+
Examples:
|
|
5783
|
+
```ts
|
|
5784
|
+
filters: {
|
|
5785
|
+
// some boolean filter definition with filterId: 'inStock-filter'
|
|
5786
|
+
},
|
|
5787
|
+
views: {
|
|
5788
|
+
enabled: true,
|
|
5789
|
+
presets: {
|
|
5790
|
+
type: 'views',
|
|
5791
|
+
views: [
|
|
5792
|
+
{
|
|
5793
|
+
// Items where value is true
|
|
5794
|
+
id: 'only-in-stock',
|
|
5795
|
+
label: 'In stock only',
|
|
5796
|
+
// we will use id: 'unchecked' for false
|
|
5797
|
+
filters: {
|
|
5798
|
+
'inStock-filter': { filterType: 'boolean', value: [{ id: 'checked', name: 'In stock' }] },
|
|
5799
|
+
},
|
|
5800
|
+
},
|
|
5801
|
+
],
|
|
5802
|
+
},
|
|
5803
|
+
}
|
|
5804
|
+
```
|
|
5805
|
+
|
|
5806
|
+
#### Enum filter
|
|
5807
|
+
Apply a filter for enum (options) data type. The value is an array of selected options. You can use the `name` field to control what will be written in the filter label when it's applied
|
|
5808
|
+
|
|
5809
|
+
Examples:
|
|
5810
|
+
```ts
|
|
5811
|
+
filters: {
|
|
5812
|
+
// some enum filter definiton with filterId: 'category-filter', and options that include the values 'pets' and 'toys'
|
|
5813
|
+
},
|
|
5814
|
+
views: {
|
|
5815
|
+
enabled: true,
|
|
5816
|
+
presets: {
|
|
5817
|
+
type: 'views',
|
|
5818
|
+
views: [
|
|
5819
|
+
{
|
|
5820
|
+
id: 'pets-and-toys',
|
|
5821
|
+
label: 'Categories: Pets & Toys',
|
|
5822
|
+
filters: {
|
|
5823
|
+
'category-filter': {
|
|
5824
|
+
filterType: 'enum',
|
|
5825
|
+
value: [
|
|
5826
|
+
{ id: 'pets', name: 'Pets' },
|
|
5827
|
+
{ id: 'toys', name: 'Toys' },
|
|
5828
|
+
],
|
|
5829
|
+
},
|
|
5830
|
+
},
|
|
5831
|
+
},
|
|
5832
|
+
],
|
|
5833
|
+
},
|
|
5834
|
+
}
|
|
5835
|
+
```
|
|
5836
|
+
|
|
5837
|
+
#### Reference filter
|
|
5838
|
+
Apply a filter for reference data type. The value is an array of selected options. You can use the `name` field to control what will be written in the filter label when it's applied
|
|
5839
|
+
|
|
5840
|
+
Examples:
|
|
5841
|
+
```ts
|
|
5842
|
+
filters: {
|
|
5843
|
+
// some reference filter definition with filterId: 'owner-filter'
|
|
5844
|
+
},
|
|
5845
|
+
views: {
|
|
5846
|
+
enabled: true,
|
|
5847
|
+
presets: {
|
|
5848
|
+
type: 'views',
|
|
5849
|
+
views: [
|
|
5850
|
+
{
|
|
5851
|
+
id: 'owners-a-b',
|
|
5852
|
+
label: 'Owners: A & B',
|
|
5853
|
+
filters: {
|
|
5854
|
+
'owner-filter': {
|
|
5855
|
+
filterType: 'reference',
|
|
5856
|
+
value: [
|
|
5857
|
+
{ id: 'owner-a-id', name: 'Owner A' },
|
|
5858
|
+
{ id: 'owner-b-id', name: 'Owner B' },
|
|
5859
|
+
],
|
|
5860
|
+
},
|
|
5861
|
+
},
|
|
5862
|
+
},
|
|
5863
|
+
],
|
|
5864
|
+
},
|
|
5865
|
+
}
|
|
5866
|
+
```
|
|
5867
|
+
|
|
5868
|
+
## About Column Preferences
|
|
5869
|
+
⚠️ **Note**: To control column visibility and order in a view, you must enable custom columns in your table config (`table.customColumns.enabled: true`). See the App Config Structure doc: [app_config_structure.md](./app_config_structure.md).
|
|
5870
|
+
|
|
5871
|
+
Column preferences allows to control:
|
|
5872
|
+
1. Column's sorting
|
|
5873
|
+
2. Column's visibility and order
|
|
5874
|
+
|
|
5875
|
+
### Sorting
|
|
5876
|
+
The `direction` field can be used to decide the sorting for a column in a preset view.
|
|
5877
|
+
|
|
5878
|
+
Note that the column must be configured with `sortable: true` in the columns config.
|
|
5879
|
+
|
|
5880
|
+
For example, to sort the column `age`:
|
|
5881
|
+
```ts
|
|
5882
|
+
columnPreferences: [
|
|
5883
|
+
{
|
|
5884
|
+
id: `age`, // the column id
|
|
5885
|
+
direction: 'asc', // we can also use 'desc'
|
|
5886
|
+
}
|
|
5887
|
+
]
|
|
5888
|
+
```
|
|
5889
|
+
|
|
5890
|
+
### Visibility & Order
|
|
5891
|
+
Columns visibility and order are controlled together via the `show` field on `columnPreferences`.
|
|
5892
|
+
If you wish to change visibility and order: list ALL the columns you want to see with `{ show: true }` and they’ll be shown in exactly that order. Columns that can’t be hidden (`hideable: false` or `hiddenFromCustomColumnsSelection: true`) are always shown even if you don’t list them. Columns marked `reorderDisabled: true` keep their original position and ignore reordering.
|
|
5893
|
+
|
|
5894
|
+
## About Filters (in a preset view)
|
|
5895
|
+
Filters used in a preset are referenced by their filter item `id` from your app config. If a referenced filter id does not exist in the app config, it is ignored. Ensure all used filters are defined under `filters.items`.
|
|
5896
|
+
|
|
5897
|
+
Example usages available here: [Filters examples](#filters)
|
|
5898
|
+
|
|
5899
|
+
**Supported filter value shapes**: See the complete `AutoFilterValue` type definition and all related filter value types (`DateFilterValue`, `NumberFilterValue`, `BooleanFilterValue`, `EnumFilterValue`, `ReferenceFilterValue`) in [app_config_structure.md](./app_config_structure.md).
|
|
5900
|
+
|