@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
- // Export rows in the card/table display order (incomplete first, then
86
- // capture time), regardless of the order the caller fetched them in.
87
- const measurements = sortMeasurementsByCompleted(measurementsByGroup.get(group.id) ?? []).filter(measurementPassesFilter);
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
- row.push(escapeCSVField(measurement
99
- ? isScalarMeasurement(measurement.type)
100
- ? `${measurement.value}${scalarValueSuffix(measurement.type)}`
101
- : formatMeasurementValue(measurement.value, measurement.device)
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 || ''));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reekon-tools/boldr-utils",
3
- "version": "1.17.3",
3
+ "version": "1.17.4",
4
4
  "description": "Shared utilities for formulas and measurement conversion used in Reekon apps",
5
5
  "author": "REEKON Tools",
6
6
  "license": "MIT",