Skip to content

Commit

Permalink
docs: updated kpi stat docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mle-moni committed Aug 14, 2024
1 parent 00cf008 commit e73c955
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 6 deletions.
26 changes: 24 additions & 2 deletions app/adomin/fields.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 41 additions & 3 deletions docs/src/content/docs/reference/views/models/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
17 changes: 16 additions & 1 deletion docs/src/content/docs/reference/views/stats/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ For basic charts, your `dataFetcher` can use the built in [data fetcher helpers]

### options

Chartkick options for the chart
When stat type is `pie`, `bar`, `column`, `line` or `area` you can pass the following options inside the config object:

```ts
interface ChartKickOptions {
Expand Down Expand Up @@ -270,6 +270,21 @@ interface ChartKickOptions {
}
```

When stat type is `kpi` you can pass the following options inside the config object:
```ts
export interface KpiStatOptions {
/**
* If true, the value should be a number between 0-100 and will be displayed as a percentage
* @default false
*/
isPercentage?: boolean
/**
* Color of the mui CircularProgress
*/
color?: string
}
```

## Data fetcher helpers

For basic charts, you can use these functions in your `dataFetcher` function:
Expand Down

0 comments on commit e73c955

Please sign in to comment.