From 269a3cb0cc9b3649c46b521fabff653793248948 Mon Sep 17 00:00:00 2001 From: dleadbetter Date: Wed, 11 Sep 2024 09:18:37 -0400 Subject: [PATCH 1/4] UDF #35 - Adding "FuzzyDate" data type to user-defined fields --- .../.storybook/routes/UserDefinedFields.js | 12 +++++++++++ .../UserDefinedFieldsForm.stories.js | 7 ++----- .../src/components/UserDefinedFieldsForm.js | 21 +++++++++++++++++-- .../src/constants/DataTypes.js | 1 + .../src/hooks/UserDefinedFields.js | 7 ++++++- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/packages/storybook/.storybook/routes/UserDefinedFields.js b/packages/storybook/.storybook/routes/UserDefinedFields.js index 28505b8b..21a1cc4d 100644 --- a/packages/storybook/.storybook/routes/UserDefinedFields.js +++ b/packages/storybook/.storybook/routes/UserDefinedFields.js @@ -32,38 +32,50 @@ const addRoutes = (router) => { router.get('/user_defined_fields/user_defined_fields', (request, response) => { const fields = [{ + uuid: '1a82328e-3642-4fc6-9045-f42f48e3a415', table_name: 'People', column_name: 'First name', data_type: 'String', required: true, order: 10 }, { + uuid: 'b1956bf4-625f-4ce9-aa44-6c7ef621d7e6', table_name: 'People', column_name: 'Last name', data_type: 'String', required: true, order: 20 }, { + uuid: 'e399563e-46cb-4c28-a717-6d98823abfc5', table_name: 'People', column_name: 'Date of birth', data_type: 'Date', order: 30 }, { + uuid: '3aefc504-737d-4771-806c-e55ce84ef4fe', table_name: 'People', column_name: 'Biography', data_type: 'RichText', order: 40 }, { + uuid: '378091ba-f053-48a4-905c-cc8337992db7', table_name: 'People', column_name: 'Favorite color', data_type: 'Select', order: 50, options: ['Red', 'Blue', 'Green', 'Orange', 'Yellow'] }, { + uuid: 'dd83405b-0b5b-4a11-9f51-5fd744fc316d', table_name: 'People', column_name: 'Year of service', data_type: 'Number', order: 60 + }, { + uuid: '4c1557ae-1321-4a58-9096-7cfd2accf394', + table_name: 'People', + column_name: 'Fuzzy Date', + data_type: 'FuzzyDate', + order: 70 }]; response.send({ diff --git a/packages/storybook/src/user-defined-fields/UserDefinedFieldsForm.stories.js b/packages/storybook/src/user-defined-fields/UserDefinedFieldsForm.stories.js index 4f89d444..a7dbdb9b 100644 --- a/packages/storybook/src/user-defined-fields/UserDefinedFieldsForm.stories.js +++ b/packages/storybook/src/user-defined-fields/UserDefinedFieldsForm.stories.js @@ -11,17 +11,14 @@ export default { }; export const Default = () => { - const [data, setData] = useState({ - 'First name': 'Bob', - 'Last name': 'Smith' - }); + const [data, setData] = useState({}); return (
false} - onChange={(value) => setData(value)} + onChange={setData} /> ); diff --git a/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js b/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js index 6a45f512..46eddd0e 100644 --- a/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js +++ b/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js @@ -1,7 +1,7 @@ // @flow -import { DatePicker } from '@performant-software/semantic-components'; -import { RichTextArea } from '@performant-software/shared-components'; +import { DatePicker, FuzzyDate } from '@performant-software/semantic-components'; +import { FuzzyDateTransform, RichTextArea } from '@performant-software/shared-components'; import React, { useCallback, useEffect, @@ -135,6 +135,23 @@ const UserDefinedFieldsForm: ComponentType = (props: Props) => { ); } + if (field.data_type === DataTypes.fuzzyDate) { + rendered = ( + + onChange(field, date)} + title={field.column_name} + /> + + ); + } + if (field.data_type === DataTypes.boolean) { rendered = ( { ...column, resolve: (item) => DateUtils.formatDate(resolveValue(item, field)) }); + } else if (field.data_type === DataTypes.fuzzyDate) { + columns.push({ + ...column, + resolve: (item) => FuzzyDateUtils.getDateView(resolveValue(item, field)) + }); } else if (field.data_type !== DataTypes.richText) { columns.push({ ...column, From f1d0936fc3369fbccd07f87b97798f6332b21e77 Mon Sep 17 00:00:00 2001 From: dleadbetter Date: Wed, 11 Sep 2024 10:19:14 -0400 Subject: [PATCH 2/4] UDF #35 - Updating UserDefinedFieldsForm to not transform field value before passing to FuzzyDate component --- .../user-defined-fields/src/components/UserDefinedFieldsForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js b/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js index 46eddd0e..d06700a0 100644 --- a/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js +++ b/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js @@ -144,7 +144,7 @@ const UserDefinedFieldsForm: ComponentType = (props: Props) => { > onChange(field, date)} title={field.column_name} /> From 288a67a535b3d6c8c749be4dfc20037d65d83fd5 Mon Sep 17 00:00:00 2001 From: dleadbetter Date: Wed, 11 Sep 2024 12:27:23 -0400 Subject: [PATCH 3/4] UDF #35 - Updating UserDefinedFieldsForm to convert fuzzy date values --- packages/shared/src/transforms/FuzzyDate.js | 29 +++++++++++++------ .../src/components/UserDefinedFieldsForm.js | 4 +-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/shared/src/transforms/FuzzyDate.js b/packages/shared/src/transforms/FuzzyDate.js index 0cde35d9..6f5dd8d3 100644 --- a/packages/shared/src/transforms/FuzzyDate.js +++ b/packages/shared/src/transforms/FuzzyDate.js @@ -1,6 +1,25 @@ // @flow class FuzzyDate { + /** + * Returns the passed fuzzy date as a data object. + * + * @param date + * + * @returns {{end_date, _destroy, accuracy, description, range, id, start_date}} + */ + toData(date) { + return { + id: date.id, + accuracy: date.accuracy, + description: date.description, + end_date: date.endDate, + range: date.range, + start_date: date.startDate, + _destroy: date._destroy + }; + } + /** * Returns the passed date as a FuzzyDate input date. * @@ -40,15 +59,7 @@ class FuzzyDate { } return { - [attribute]: { - id: date.id, - accuracy: date.accuracy, - description: date.description, - end_date: date.endDate, - range: date.range, - start_date: date.startDate, - _destroy: date._destroy - } + [attribute]: this.toData(date) }; } } diff --git a/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js b/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js index d06700a0..ba1d1150 100644 --- a/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js +++ b/packages/user-defined-fields/src/components/UserDefinedFieldsForm.js @@ -144,8 +144,8 @@ const UserDefinedFieldsForm: ComponentType = (props: Props) => { > onChange(field, date)} + date={FuzzyDateTransform.toFuzzyDate(fieldValue)} + onChange={(date) => onChange(field, FuzzyDateTransform.toData(date))} title={field.column_name} /> From 61afe39ce669825b2e4b9ce71e3d1113ff9a21dd Mon Sep 17 00:00:00 2001 From: dleadbetter Date: Wed, 11 Sep 2024 14:30:23 -0400 Subject: [PATCH 4/4] UDF #35 - Publishing v2.2.11 --- packages/controlled-vocabulary/package.json | 6 +++--- packages/core-data/package.json | 6 +++--- packages/geospatial/package.json | 2 +- packages/semantic-ui/package.json | 4 ++-- packages/shared/package.json | 2 +- packages/user-defined-fields/package.json | 6 +++--- packages/visualize/package.json | 2 +- react-components.json | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/controlled-vocabulary/package.json b/packages/controlled-vocabulary/package.json index e44c4637..f7573596 100644 --- a/packages/controlled-vocabulary/package.json +++ b/packages/controlled-vocabulary/package.json @@ -1,6 +1,6 @@ { "name": "@performant-software/controlled-vocabulary", - "version": "2.2.10", + "version": "2.2.11", "description": "A package of components to allow user to configure dropdown elements. Use with the \"controlled_vocabulary\" gem.", "license": "MIT", "main": "./dist/index.cjs.js", @@ -23,8 +23,8 @@ "underscore": "^1.13.2" }, "peerDependencies": { - "@performant-software/semantic-components": "^2.2.10", - "@performant-software/shared-components": "^2.2.10", + "@performant-software/semantic-components": "^2.2.11", + "@performant-software/shared-components": "^2.2.11", "react": ">= 16.13.1 < 19.0.0", "react-dom": ">= 16.13.1 < 19.0.0" }, diff --git a/packages/core-data/package.json b/packages/core-data/package.json index 99a88135..0633eb84 100644 --- a/packages/core-data/package.json +++ b/packages/core-data/package.json @@ -1,6 +1,6 @@ { "name": "@performant-software/core-data", - "version": "2.2.10", + "version": "2.2.11", "description": "A package of components used with the Core Data platform.", "license": "MIT", "main": "./dist/index.cjs.js", @@ -40,8 +40,8 @@ "underscore": "^1.13.2" }, "peerDependencies": { - "@performant-software/geospatial": "^2.2.10", - "@performant-software/shared-components": "^2.2.10", + "@performant-software/geospatial": "^2.2.11", + "@performant-software/shared-components": "^2.2.11", "@peripleo/maplibre": "^0.5.2", "@peripleo/peripleo": "^0.5.2", "react": ">= 16.13.1 < 19.0.0", diff --git a/packages/geospatial/package.json b/packages/geospatial/package.json index bcbfcfaa..e6474d3e 100644 --- a/packages/geospatial/package.json +++ b/packages/geospatial/package.json @@ -1,6 +1,6 @@ { "name": "@performant-software/geospatial", - "version": "2.2.10", + "version": "2.2.11", "description": "A package of components for all things map-related.", "license": "MIT", "main": "./dist/index.cjs.js", diff --git a/packages/semantic-ui/package.json b/packages/semantic-ui/package.json index 6216e1d1..a10fdfca 100644 --- a/packages/semantic-ui/package.json +++ b/packages/semantic-ui/package.json @@ -1,6 +1,6 @@ { "name": "@performant-software/semantic-components", - "version": "2.2.10", + "version": "2.2.11", "description": "A package of shared components based on the Semantic UI Framework.", "license": "MIT", "main": "./dist/index.cjs.js", @@ -35,7 +35,7 @@ "zotero-translation-client": "^5.0.1" }, "peerDependencies": { - "@performant-software/shared-components": "^2.2.10", + "@performant-software/shared-components": "^2.2.11", "@samvera/clover-iiif": "^2.3.2", "react": ">= 16.13.1 < 19.0.0", "react-dnd": "^11.1.3", diff --git a/packages/shared/package.json b/packages/shared/package.json index bd2ca3a6..46c14bdb 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@performant-software/shared-components", - "version": "2.2.10", + "version": "2.2.11", "description": "A package of shared, framework agnostic, components.", "license": "MIT", "main": "./dist/index.cjs.js", diff --git a/packages/user-defined-fields/package.json b/packages/user-defined-fields/package.json index 39c00024..bf2a9778 100644 --- a/packages/user-defined-fields/package.json +++ b/packages/user-defined-fields/package.json @@ -1,6 +1,6 @@ { "name": "@performant-software/user-defined-fields", - "version": "2.2.10", + "version": "2.2.11", "description": "A package of components used for allowing end users to define fields on models. Use with the \"user_defined_fields\" gem.", "license": "MIT", "main": "./dist/index.cjs.js", @@ -23,8 +23,8 @@ "underscore": "^1.13.2" }, "peerDependencies": { - "@performant-software/semantic-components": "^2.2.10", - "@performant-software/shared-components": "^2.2.10", + "@performant-software/semantic-components": "^2.2.11", + "@performant-software/shared-components": "^2.2.11", "react": ">= 16.13.1 < 19.0.0", "react-dom": ">= 16.13.1 < 19.0.0" }, diff --git a/packages/visualize/package.json b/packages/visualize/package.json index cc580074..87e6df53 100644 --- a/packages/visualize/package.json +++ b/packages/visualize/package.json @@ -1,6 +1,6 @@ { "name": "@performant-software/visualize", - "version": "2.2.10", + "version": "2.2.11", "description": "A package of components used for data visualization", "license": "MIT", "main": "./dist/index.cjs.js", diff --git a/react-components.json b/react-components.json index 88473932..9d4ff475 100644 --- a/react-components.json +++ b/react-components.json @@ -8,5 +8,5 @@ "packages/user-defined-fields", "packages/visualize" ], - "version": "2.2.10" + "version": "2.2.11" }