Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lat and long format patterns #316

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/AttributeDetails/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
};
Expand Down
4 changes: 3 additions & 1 deletion src/ViewSchema/useExportLogicV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '\\"')}"`;
}
});

Expand Down
6 changes: 4 additions & 2 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down