From 1450163379c58a57d60aa12de98fa04f50c16166 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 23 Dec 2024 16:04:18 +0530 Subject: [PATCH] feat: added grid (child table) control --- frontend/src/components/Controls/Grid.vue | 268 ++++++++++++++++++++++ frontend/src/types/controls.ts | 49 ++++ frontend/src/utils/index.js | 11 + 3 files changed, 328 insertions(+) create mode 100644 frontend/src/components/Controls/Grid.vue create mode 100644 frontend/src/types/controls.ts diff --git a/frontend/src/components/Controls/Grid.vue b/frontend/src/components/Controls/Grid.vue new file mode 100644 index 00000000..c697b3be --- /dev/null +++ b/frontend/src/components/Controls/Grid.vue @@ -0,0 +1,268 @@ + + + + + diff --git a/frontend/src/types/controls.ts b/frontend/src/types/controls.ts new file mode 100644 index 00000000..9d27299e --- /dev/null +++ b/frontend/src/types/controls.ts @@ -0,0 +1,49 @@ +export type FieldTypes = + | 'Data' + | 'Int' + | 'Float' + | 'Currency' + | 'Check' + | 'Text' + | 'Small Text' + | 'Long Text' + | 'Code' + | 'Text Editor' + | 'Date' + | 'Datetime' + | 'Time' + | 'HTML' + | 'Image' + | 'Attach' + | 'Select' + | 'Read Only' + | 'Section Break' + | 'Column Break' + | 'Table' + | 'Button' + | 'Link' + | 'Dynamic Link' + | 'Password' + | 'Signature' + | 'Color' + | 'Barcode' + | 'Geolocation' + | 'Duration' + | 'Percent' + | 'Rating' + | 'Icon' + +// Grid / Child Table +export interface GridColumn { + label: string + fieldname: string + fieldtype: FieldTypes + options?: string | string[] + width?: number + onChange?: (value: string, index: number) => void +} + +export interface GridRow { + name: string + [fieldname: string]: string | number | boolean +} diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 557e8588..c0306e4b 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -305,3 +305,14 @@ export function isImage(extention) { extention.toLowerCase(), ) } + +export function getRandom(len) { + let text = '' + const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + + Array.from({ length: len }).forEach(() => { + text += possible.charAt(Math.floor(Math.random() * possible.length)) + }) + + return text +}