@reekon-tools/boldr-utils 1.17.3 → 1.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,6 +15,7 @@ export type BuildJobCsvInput = {
|
|
|
15
15
|
measurementsByGroup: Map<string, Measurement[]>;
|
|
16
16
|
objectsByGroup: Map<string, ExportObjectRow[]>;
|
|
17
17
|
formatMeasurementValue: (value: number, device?: string) => string;
|
|
18
|
+
applyGroupFormula?: (group: Group, measurement: Measurement) => number | null;
|
|
18
19
|
unitPrefs: {
|
|
19
20
|
defaultUnit?: Units;
|
|
20
21
|
fractionalTolerance?: FractionalTolerance;
|
|
@@ -39,7 +39,7 @@ const userCell = (user) => (user ? [user.firstName, user.lastName].filter(Boolea
|
|
|
39
39
|
// trailing "Objects" column (list groups) or extend the form row (form
|
|
40
40
|
// groups), one skipped column after the existing cells.
|
|
41
41
|
export function buildJobCsv(input) {
|
|
42
|
-
const { scope, activeGroupId, config, groups, sections, formulas, measurementsByGroup, objectsByGroup, formatMeasurementValue, unitPrefs, } = input;
|
|
42
|
+
const { scope, activeGroupId, config, groups, sections, formulas, measurementsByGroup, objectsByGroup, formatMeasurementValue, applyGroupFormula, unitPrefs, } = input;
|
|
43
43
|
const csvRows = [];
|
|
44
44
|
let listGroups;
|
|
45
45
|
let formGroups;
|
|
@@ -82,9 +82,13 @@ export function buildJobCsv(input) {
|
|
|
82
82
|
headerCells.push(escapeCSVField(''), escapeCSVField('Objects'));
|
|
83
83
|
}
|
|
84
84
|
csvRows.push(headerCells.join(','));
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
85
|
+
// File-scratch measurements (non-null fileId: created inside a CAD/PDF
|
|
86
|
+
// canvas, never saved into the group) live in the same subcollection
|
|
87
|
+
// but are internal — the group cards hide them, so exports must too.
|
|
88
|
+
// Then export rows in the card/table display order (incomplete first,
|
|
89
|
+
// then capture time), regardless of the order the caller fetched them
|
|
90
|
+
// in.
|
|
91
|
+
const measurements = sortMeasurementsByCompleted((measurementsByGroup.get(group.id) ?? []).filter((m) => m.fileId == null)).filter(measurementPassesFilter);
|
|
88
92
|
// Objects fill a parallel column, one per row from the top; extra rows
|
|
89
93
|
// are emitted when a group has more objects than measurements.
|
|
90
94
|
const rowCount = Math.max(measurements.length, objects.length);
|
|
@@ -94,12 +98,22 @@ export function buildJobCsv(input) {
|
|
|
94
98
|
if (includeField('measurement')) {
|
|
95
99
|
// Angles and unitless numbers store their value as entered, not as
|
|
96
100
|
// micrometers — running them through the length formatter would
|
|
97
|
-
// render 45° as ~0. Emit them as-is with their own suffix.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
// render 45° as ~0. Emit them as-is with their own suffix. Group
|
|
102
|
+
// formulas apply to length measurements only, same as the tiles.
|
|
103
|
+
let cell = '';
|
|
104
|
+
if (measurement) {
|
|
105
|
+
if (isScalarMeasurement(measurement.type)) {
|
|
106
|
+
cell = `${measurement.value}${scalarValueSuffix(measurement.type)}`;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const formulaValue = applyGroupFormula?.(group, measurement) ?? null;
|
|
110
|
+
cell =
|
|
111
|
+
formulaValue !== null
|
|
112
|
+
? formatMeasurementValue(formulaValue)
|
|
113
|
+
: formatMeasurementValue(measurement.value, measurement.device);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
row.push(escapeCSVField(cell));
|
|
103
117
|
}
|
|
104
118
|
if (includeField('label')) {
|
|
105
119
|
row.push(escapeCSVField(measurement?.label || ''));
|