From 50979fe24e8ca7933f069faaf79ee50d8410e66f Mon Sep 17 00:00:00 2001 From: mathew-at-guelph Date: Wed, 12 Mar 2025 16:16:10 -0400 Subject: [PATCH 1/2] Fix lat and long regex patterns --- src/AttributeDetails/Grid.js | 8 +++++--- src/ViewSchema/useExportLogicV2.js | 4 +++- src/constants/constants.js | 8 +++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/AttributeDetails/Grid.js b/src/AttributeDetails/Grid.js index 7fdb7fdd..1d2e57f5 100644 --- a/src/AttributeDetails/Grid.js +++ b/src/AttributeDetails/Grid.js @@ -477,9 +477,11 @@ export default function Grid({ const updateSavedEntryCodes = (oldAttributeValue, newAttributeValue) => { setSavedEntryCodes((prevData) => { const updatedSavedEntryCodes = { ...prevData }; - updatedSavedEntryCodes[newAttributeValue] = - updatedSavedEntryCodes[oldAttributeValue]; - delete updatedSavedEntryCodes[oldAttributeValue]; + if (updatedSavedEntryCodes[oldAttributeValue]) { + updatedSavedEntryCodes[newAttributeValue] = + updatedSavedEntryCodes[oldAttributeValue]; + delete updatedSavedEntryCodes[oldAttributeValue]; + } return updatedSavedEntryCodes; }); }; diff --git a/src/ViewSchema/useExportLogicV2.js b/src/ViewSchema/useExportLogicV2.js index 4a47b37e..7d345166 100644 --- a/src/ViewSchema/useExportLogicV2.js +++ b/src/ViewSchema/useExportLogicV2.js @@ -135,7 +135,9 @@ const useExportLogicV2 = () => { let tempText = ""; formatRuleRowData.forEach((item, index) => { if (item.FormatText) { - tempText += ` ${attributesList[index]}="${item.FormatText}"`; + // Any " in the format text needs to be escaped for OCA file + // eslint-disable-next-line quotes + tempText += ` ${attributesList[index]}="${item.FormatText.replace(/"/g, '\\"')}"`; } }); diff --git a/src/constants/constants.js b/src/constants/constants.js index ce37e7b8..58df164f 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -197,12 +197,14 @@ export const descriptionToFormatCodeText = { "Phone number": "\\+?\\(?\\d{2,4}\\)?[\\d\\s-]{3,}", // eslint-disable-next-line quotes 'Latitude in formats S30°15\'45.678" or N12°30.999"': - "^[NS]-?(?:[0-8]?\\d|90)°(?:\\d+(?:\\.\\d+)?)(?:'(\\d+(?:\\.\\d+)?)\")?$", + // eslint-disable-next-line quotes + `^[NS]\\s?(?:[0-8]?\\d)°\\s?(?:[0-5]?\\d)'?\\s?(?:[0-5]?\\d(?:\\.\\d+)?)"?$`, // eslint-disable-next-line quotes 'Longitude in formats E30°15\'45.678" or W90°00.000"': - "^[WE]-?(?:[0-8]?\\d|90)°(?:\\d+(?:\\.\\d+)?)(?:'(\\d+(?:\\.\\d+)?)\")?$" + // eslint-disable-next-line quotes + `^[EW]\\s?(?:[0-1]?[0-7]?\\d)°\\s?(?:[0-5]?\\d)'?\\s?(?:[0-5]?\\d(?:\\.\\d+)?)"?$` }; - +// ^[NS](?:(?:[0-8]\\d|90)(?:\\.\\d+)?°|(?:[0-8]\\d|90)°(?:[0-5]\\d(?:\\.\\d+)?'|[0-5]\\d'(?:[0-5]\\d(?:\\.\\d+)?")))$ export const formatCodeText = Object.keys(descriptionToFormatCodeText); export const formatCodeTextDescription = Object.entries( From da219635fdfe78865d132e06071e4a4e5c8a7b32 Mon Sep 17 00:00:00 2001 From: mathew-at-guelph Date: Wed, 12 Mar 2025 16:18:35 -0400 Subject: [PATCH 2/2] Remove comment --- src/constants/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/constants.js b/src/constants/constants.js index 58df164f..dc751918 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -204,7 +204,7 @@ export const descriptionToFormatCodeText = { // eslint-disable-next-line quotes `^[EW]\\s?(?:[0-1]?[0-7]?\\d)°\\s?(?:[0-5]?\\d)'?\\s?(?:[0-5]?\\d(?:\\.\\d+)?)"?$` }; -// ^[NS](?:(?:[0-8]\\d|90)(?:\\.\\d+)?°|(?:[0-8]\\d|90)°(?:[0-5]\\d(?:\\.\\d+)?'|[0-5]\\d'(?:[0-5]\\d(?:\\.\\d+)?")))$ + export const formatCodeText = Object.keys(descriptionToFormatCodeText); export const formatCodeTextDescription = Object.entries(