From c0adbde8a93f3adab8fa64e55f151d455fc0dee4 Mon Sep 17 00:00:00 2001 From: Fredrik Thorild Date: Sun, 21 Feb 2021 07:59:15 +0100 Subject: [PATCH 1/3] Fixing 1711 - Bug with default taxonomy value Added regex clean-up of the taxonomy strings in readData() --- .../src/webparts/listForm/components/ListForm.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx b/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx index a8bc5b28c..569ab0b5a 100644 --- a/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx +++ b/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx @@ -298,7 +298,15 @@ class ListForm extends React.Component { try { if ((formType === ControlMode.New) || !id) { const data = this.state.fieldsSchema - .reduce((newData, fld) => { newData[fld.InternalName] = fld.DefaultValue; return newData; }, {}); + .reduce((newData, fld) => { + if (fld.DefaultValue && fld.FieldType.indexOf("TaxonomyField") > -1) { + newData[fld.InternalName] = fld.DefaultValue.replace(new RegExp("([#]?[0-9]+;#)", "g"), "") + } else { + newData[fld.InternalName] = fld.DefaultValue; + } + return newData; + }, + {}); this.setState({ ...this.state, data: data, originalData: { ...data }, fieldErrors: {}, isLoadingData: false }); return; } From 3055df775fbf30c8cb2669a3f3c49c81d9a09f06 Mon Sep 17 00:00:00 2001 From: Fredrik Thorild Date: Mon, 22 Feb 2021 09:51:23 +0100 Subject: [PATCH 2/3] Updated regex in default tax values The regex was not capturing > 2 values correctly --- .../src/webparts/listForm/components/ListForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx b/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx index 569ab0b5a..2a3e02e16 100644 --- a/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx +++ b/samples/react-list-form/src/webparts/listForm/components/ListForm.tsx @@ -300,7 +300,7 @@ class ListForm extends React.Component { const data = this.state.fieldsSchema .reduce((newData, fld) => { if (fld.DefaultValue && fld.FieldType.indexOf("TaxonomyField") > -1) { - newData[fld.InternalName] = fld.DefaultValue.replace(new RegExp("([#]?[0-9]+;#)", "g"), "") + newData[fld.InternalName] = fld.DefaultValue.replace(new RegExp("([#][0-9]+;#|^[0-9]+;#)", "g"), "") } else { newData[fld.InternalName] = fld.DefaultValue; } From 834626266e14b8cfc79205cd264c22f10b36bdf7 Mon Sep 17 00:00:00 2001 From: Hugo Bernier Date: Tue, 23 Feb 2021 00:04:54 -0500 Subject: [PATCH 3/3] Added version history and solution version --- samples/react-list-form/README.md | 4 +++- samples/react-list-form/config/package-solution.json | 2 +- samples/react-list-form/npm-shrinkwrap.json | 2 +- samples/react-list-form/package.json | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/samples/react-list-form/README.md b/samples/react-list-form/README.md index c6e142278..b6bd42513 100755 --- a/samples/react-list-form/README.md +++ b/samples/react-list-form/README.md @@ -47,7 +47,8 @@ The web part allows configuring which list to use and if a form for adding a new | react-list-form | Harsha Vardhini ([@harshagracy](https://twitter.com/harshagracy)) | | react-list-form | Ryan Schouten ([@shrpntknight](https://twitter.com/shrpntknight)) | | react-list-form | Abderahman Moujahid | -| react-list-form | [Kman1131](https://github.com/Kman1131) +| react-list-form | [Kman1131](https://github.com/Kman1131) | +| react-list-form | Fredrik Thorild [@fthorild](https://twitter.com/fthorild) | ## Version history @@ -62,6 +63,7 @@ The web part allows configuring which list to use and if a form for adding a new | 1.0.6 | October 8, 2020 | Added support for cascading lookup fields | | 1.0.7 | December 11, 2020 | Fix limit of lookup fields | | 1.0.8 | February 7, 2021 | Fixed dragging and dropping fields | +| 1.0.9 | February 19, 2021 | Fixed regular expressions for text validation | ## Disclaimer diff --git a/samples/react-list-form/config/package-solution.json b/samples/react-list-form/config/package-solution.json index cba120d2a..8d6fed486 100755 --- a/samples/react-list-form/config/package-solution.json +++ b/samples/react-list-form/config/package-solution.json @@ -3,7 +3,7 @@ "solution": { "name": "react-form-webpart-client-side-solution", "id": "373a20ef-dfc6-456a-95ec-171de3c94581", - "version": "1.0.8.0", + "version": "1.0.9.0", "title": "List form", "supportedLocales": [ "en-US", diff --git a/samples/react-list-form/npm-shrinkwrap.json b/samples/react-list-form/npm-shrinkwrap.json index af6592964..8894ee441 100644 --- a/samples/react-list-form/npm-shrinkwrap.json +++ b/samples/react-list-form/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "react-form-webpart", - "version": "1.0.6", + "version": "1.0.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/samples/react-list-form/package.json b/samples/react-list-form/package.json index 6ee66c1e2..78b7049c9 100755 --- a/samples/react-list-form/package.json +++ b/samples/react-list-form/package.json @@ -1,6 +1,6 @@ { "name": "react-form-webpart", - "version": "1.0.8", + "version": "1.0.9", "private": true, "engines": { "node": ">=0.10.0"