-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,31 @@ export interface AdominBaseFieldConfig { | |
* If this field is a \@computed() field in your model you must set this to true | ||
*/ | ||
computed?: boolean | ||
/** Sql filter override, usefull for computed fields */ | ||
/** | ||
* Sql filter override, usefull for computed fields | ||
* | ||
* e.g. | ||
* ```ts | ||
* const isBeautifullFilter = (input: string | null) => { | ||
* if (input === null) return 'false' | ||
* | ||
* if (+input === 0) return `email != '[email protected]'` | ||
* | ||
* return `email = '[email protected]'` | ||
* } | ||
* ``` | ||
*/ | ||
sqlFilter?: (input: string | null) => string | RawQuery | ||
/** Sql order by override, usefull for computed fields */ | ||
/** | ||
* Sql orderBy override, usefull for computed fields | ||
* | ||
* e.g. | ||
* ```ts | ||
* const isBeautifullSort = (ascDesc: 'asc' | 'desc') => { | ||
* return `email = '[email protected]' ${ascDesc}` | ||
* } | ||
* ``` | ||
*/ | ||
sqlSort?: (ascDesc: 'asc' | 'desc') => string | RawQuery | ||
/** | ||
* Export data transformation callback to use for this field | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,17 @@ You can pass the following options inside the config object: | |
|
||
### columns | ||
|
||
An object listing all the model properties you want to see on the frontend | ||
An object listing all the model properties you want to see on the frontend. | ||
|
||
All fields share some basic config properties `AdominBaseFieldConfig` + specific properties for the field type | ||
This will look like this: | ||
```ts | ||
columns: { | ||
email: { type: 'string', isEmail: true, label: 'Super email' }, | ||
password: { type: 'string', isPassword: true, label: 'Mot de passe' }, | ||
} | ||
``` | ||
|
||
All fields defined in the `columns` object share some basic config properties from `AdominBaseFieldConfig` + specific properties for the field type | ||
|
||
```ts | ||
export interface AdominBaseFieldConfig { | ||
|
@@ -65,13 +73,43 @@ export interface AdominBaseFieldConfig { | |
* If false, user cannot create this field | ||
*/ | ||
creatable?: boolean | ||
/** If false, user cannot sort by this field */ | ||
sortable?: boolean | ||
/** If false, user cannot filter by this field */ | ||
filterable?: boolean | ||
/** | ||
* Sql filter override, usefull for computed fields | ||
* | ||
* e.g. | ||
* ```ts | ||
* const isBeautifullFilter = (input: string | null) => { | ||
* if (input === null) return 'false' | ||
* | ||
* if (+input === 0) return `email != '[email protected]'` | ||
* | ||
* return `email = '[email protected]'` | ||
* } | ||
* ``` | ||
*/ | ||
sqlFilter?: (input: string | null) => string | RawQuery | ||
/** | ||
* Sql orderBy override, usefull for computed fields | ||
* | ||
* e.g. | ||
* ```ts | ||
* const isBeautifullSort = (ascDesc: 'asc' | 'desc') => { | ||
* return `email = '[email protected]' ${ascDesc}` | ||
* } | ||
* ``` | ||
*/ | ||
sqlSort?: (ascDesc: 'asc' | 'desc') => string | RawQuery | ||
/** | ||
* Size of the field on the frontend | ||
* @default 120 | ||
*/ | ||
size?: number | ||
/** | ||
* If this field is a \@computed() field in your model you must set this to true | ||
* If this field is a @computed() field in your model you must set this to true | ||
*/ | ||
computed?: boolean | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters