diff --git a/src/AttributeDetails/Grid.js b/src/AttributeDetails/Grid.js index 7fdb7fd..1d2e57f 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 4a47b37..7d34516 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 ce37e7b..dc75191 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -197,10 +197,12 @@ 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+)?)"?$` }; export const formatCodeText = Object.keys(descriptionToFormatCodeText);