Skip to content

Commit

Permalink
fix(gr-sheet): Add support for NONE for UoM references
Browse files Browse the repository at this point in the history
  • Loading branch information
ribose-jeffreylau committed Dec 30, 2024
1 parent cf7166a commit ab411de
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/gr-sheet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof resolveReference> | null {
if (/none/i.test(cellContents)) {
return null;
}
return resolveReference(cellContents, mode);
}

const resolveRelated = function resolveRelated(cellContents: string) {

//const itemID = sheetItemID.split(' ')[0];
Expand Down Expand Up @@ -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'),
};
},
}),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ab411de

Please sign in to comment.