Skip to content

Commit

Permalink
feat: add additional config to DataGridPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
awesthouse committed Jan 10, 2024
1 parent b63a76e commit 6692dd4
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,109 @@
"attributeType": "string"
},
{
"name": "fieldName",
"name": "title",
"type": "CORE:BlueprintAttribute",
"attributeType": "string"
"attributeType": "string",
"optional": true,
"default": ""
},
{
"name": "columns",
"name": "description",
"type": "CORE:BlueprintAttribute",
"description": "Name of primitive child attributes to display in header of item",
"attributeType": "string",
"optional": true,
"default": [],
"default": ""
},
{
"name": "fieldNames",
"type": "CORE:BlueprintAttribute",
"description": "If more than one field is selected, the arrays have to be 1-dimensional.",
"attributeType": "string",
"dimensions": "*"
},
{
"name": "editable",
"type": "CORE:BlueprintAttribute",
"attributeType": "boolean",
"optional": true,
"default": true
},
{
"name": "showColumns",
"type": "CORE:BlueprintAttribute",
"attributeType": "boolean",
"optional": true,
"default": true
},
{
"name": "adjustableColumns",
"type": "CORE:BlueprintAttribute",
"attributeType": "boolean",
"optional": true,
"default": true
},
{
"name": "columnLabels",
"type": "CORE:BlueprintAttribute",
"description": "Define column labels or use predefined columns. Predefined values are ABC, ZYX, 123 and you can select those by using the spread operator ['...ABC']. You can also merge the two like this: ['custom field', 'custom field2', '...ABC']",
"attributeType": "string",
"optional": true,
"default": ["...ABC"],
"dimensions": "*"
},
{
"name": "showRows",
"type": "CORE:BlueprintAttribute",
"attributeType": "boolean",
"optional": true,
"default": true
},
{
"name": "adjustableRows",
"type": "CORE:BlueprintAttribute",
"attributeType": "boolean",
"optional": true,
"default": true
},
{
"name": "movableRows",
"type": "CORE:BlueprintAttribute",
"attributeType": "boolean",
"optional": true,
"default": true
},
{
"name": "rowLabels",
"type": "CORE:BlueprintAttribute",
"description": "Define row labels or use predefined rows. Predefined values are ABC, ZYX, 123and you can select those by using the spread operator ['...ABC']. You can also merge the two like this: ['custom field', 'custom field2', '...ABC']",
"attributeType": "string",
"optional": true,
"default": ["...123"],
"dimensions": "*"
},
{
"name": "printDirection",
"type": "CORE:BlueprintAttribute",
"description": "Which direction should rows be printed. Horizontal means printing rows top-down, vertical means left-right.",
"attributeType": "string",
"optional": true,
"default": "horizontal"
},
{
"name": "rowsPerPage",
"type": "CORE:BlueprintAttribute",
"description": "How many rows per page should be pre-selected in the pagination when datagrid loads.",
"attributeType": "number",
"optional": true,
"default": 25
},
{
"name": "hidePaginationIfLessThan",
"type": "CORE:BlueprintAttribute",
"description": "Hide the pagination if rows are less than x values.",
"attributeType": "number",
"optional": true,
"default": 0
}
]
}
46 changes: 46 additions & 0 deletions packages/dm-core-plugins/src/data-grid/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export type DataGridConfig = {
title: string
description: string
fieldNames: string[]
editable: boolean
showColumns: boolean
adjustableColumns: boolean
columnLabels: string[]
showRows: boolean
adjustableRows: boolean
rowLabels: string[]
movableRows: boolean
printDirection: 'horizontal' | 'vertical'
rowsPerPage: number
hidePaginationIfLessThan: number
}

export const defaultConfig: DataGridConfig = {
title: '',
description: '',
fieldNames: [],
editable: true,
showColumns: true,
adjustableColumns: true,
columnLabels: ['...ABC'],
showRows: true,
adjustableRows: true,
rowLabels: ['...123'],
movableRows: true,
printDirection: 'horizontal',
rowsPerPage: 25,
hidePaginationIfLessThan: 0,
}

export type DataGridProps = {
attributeType: string
config?: DataGridConfig
data: any[]
description?: string
dimensions?: string
initialRowsPerPage?: number
setData: (data: any[]) => void
title?: string
}

export type PredefinedLabels = '...ABC' | '...ZYX' | '...123'

0 comments on commit 6692dd4

Please sign in to comment.