From ab411de5b6ee68abcdca0218c9def8a3654ec121 Mon Sep 17 00:00:00 2001 From: Jeffrey Lau Date: Mon, 30 Dec 2024 19:37:35 +0800 Subject: [PATCH] fix(gr-sheet): Add support for NONE for UoM references --- packages/gr-sheet/src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/gr-sheet/src/index.ts b/packages/gr-sheet/src/index.ts index 2c6f690..9795c39 100644 --- a/packages/gr-sheet/src/index.ts +++ b/packages/gr-sheet/src/index.ts @@ -247,6 +247,13 @@ async function * generateGRItems(parsedSheetItems, opts) { throw new Error(`Unable to resolve reference, ${itemID}`); } + const resolveNullableReference = function (cellContents: string, mode: Predicate["mode"]): ReturnType | null { + if (/none/i.test(cellContents)) { + return null; + } + return resolveReference(cellContents, mode); + } + const resolveRelated = function resolveRelated(cellContents: string) { //const itemID = sheetItemID.split(' ')[0]; @@ -655,7 +662,7 @@ const SupportedSheets = { remarks: item.remarks, orientation: item.orientation, abbreviation: item.abbreviation, - unitOfMeasurement: resolveReference(item.unitOfMeasurement, 'id'), + unitOfMeasurement: resolveNullableReference(item.unitOfMeasurement, 'id'), }; }, }), @@ -747,7 +754,7 @@ const SupportedSheets = { ? ParameterType.FILE : ParameterType.MEASURE, unitOfMeasurement: type !== "Reference File" - ? resolveReference(unitOfMeasurement, 'id') as string | Predicate + ? resolveNullableReference(unitOfMeasurement, 'id') as string | Predicate | null : null, value: type === "Reference File" ? fileRef