@linzjs/step-ag-grid 14.5.0 → 14.6.0

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "14.5.0",
5
+ "version": "14.6.0",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -97,8 +97,8 @@ export const Grid = ({
97
97
  setOnCellEditingComplete,
98
98
  getColDef,
99
99
  } = useContext(GridContext);
100
- const { updatedDep, updatingCols } = useContext(GridUpdatingContext);
101
- const gridContext = useContext(GridContext);
100
+ const { checkUpdating, updatedDep, updatingCols } = useContext(GridUpdatingContext);
101
+ const { prePopupOps } = useContext(GridContext);
102
102
 
103
103
  const gridDivRef = useRef<HTMLDivElement>(null);
104
104
 
@@ -387,13 +387,23 @@ export const Grid = ({
387
387
  */
388
388
  const startCellEditing = useCallback(
389
389
  (event: CellEvent) => {
390
- event.data.id &&
391
- gridContext.startCellEditing({
392
- rowId: event.data.id,
393
- colId: event.column.getColId(),
390
+ prePopupOps();
391
+ if (!event.node.isSelected()) {
392
+ event.node.setSelected(true, true);
393
+ }
394
+ // Cell already being edited, so don't re-edit until finished
395
+ if (checkUpdating([event.colDef.field ?? ""], event.data.id)) {
396
+ return;
397
+ }
398
+
399
+ if (event.rowIndex !== null) {
400
+ event.api.startEditingCell({
401
+ rowIndex: event.rowIndex,
402
+ colKey: event.column.getColId(),
394
403
  });
404
+ }
395
405
  },
396
- [gridContext],
406
+ [checkUpdating, prePopupOps],
397
407
  );
398
408
 
399
409
  /**
@@ -54,7 +54,7 @@ GridFormEditBearingCorrectionInteractions_.play = async ({ canvasElement }) => {
54
54
  // Test formatting a bearing
55
55
  expect(inputField).toBeInTheDocument();
56
56
  userEvent.type(inputField, "1.2345");
57
- expect(await canvas.findByText("+1° 23' 45.0\"")).toBeInTheDocument();
57
+ expect(await canvas.findByText("+1° 23' 45\"")).toBeInTheDocument();
58
58
 
59
59
  // Test enter to save
60
60
  updateValue.mockClear();
@@ -7,30 +7,35 @@ import {
7
7
 
8
8
  describe("bearing", () => {
9
9
  test("convertDDToDMS converts decimal-ish degrees to DMS", () => {
10
- expect(convertDDToDMS(-0.001, false, false)).toBe("-0° 00' 10\"");
11
- expect(convertDDToDMS(-10.001, false, false)).toBe("-10° 00' 10\"");
12
- expect(convertDDToDMS(-370.001, false, false)).toBe("-10° 00' 10\"");
13
- expect(convertDDToDMS(359.595999, false, false)).toBe("0° 00'");
14
- expect(convertDDToDMS(369.696999, false, false)).toBe("10° 1010\"");
15
- expect(convertDDToDMS(221.555999, false, false)).toBe("221° 56'");
16
- expect(convertDDToDMS(221.555999, false, true)).toBe("221° 5600.0\"");
17
- expect(convertDDToDMS(5)).toBe("+5° 0000.0\"");
18
- expect(convertDDToDMS(5.0)).toBe("+5° 00' 00.0\"");
19
- expect(convertDDToDMS(5.00001)).toBe("+5° 00' 00.1\"");
20
- expect(convertDDToDMS(5.1)).toBe("+5° 10' 00.0\"");
10
+ expect(convertDDToDMS(-0.001, false)).toBe("-0° 00' 10\"");
11
+ expect(convertDDToDMS(-10.001, false)).toBe("-10° 00' 10\"");
12
+ expect(convertDDToDMS(-370.001, false)).toBe("-10° 00' 10\"");
13
+ expect(convertDDToDMS(359.595999, false, 2)).toBe("0° 00'");
14
+ expect(convertDDToDMS(359.595999, false, 4)).toBe("0° 0000\"");
15
+ expect(convertDDToDMS(359.595999, false, 5)).toBe("0° 00' 00.0\"");
16
+ expect(convertDDToDMS(369.696999, false)).toBe("10° 1010\"");
17
+ expect(convertDDToDMS(369.696999, false, 4)).toBe("10° 1010\"");
18
+ expect(convertDDToDMS(221.555999, false, 2)).toBe("221° 56'");
19
+ expect(convertDDToDMS(221.555999, false, 5)).toBe("221° 56' 00.0\"");
20
+ expect(convertDDToDMS(5, true, 5)).toBe("+5° 00' 00.0\"");
21
+ expect(convertDDToDMS(5.0, true, 5)).toBe("+5° 00' 00.0\"");
22
+ expect(convertDDToDMS(5.00001, true, 5)).toBe("+5° 00' 00.1\"");
23
+ expect(convertDDToDMS(5.1, true, 5)).toBe("+5° 10' 00.0\"");
21
24
  expect(convertDDToDMS(5.12345)).toBe("+5° 12' 34.5\"");
22
25
  expect(convertDDToDMS(5.12345, false)).toBe("5° 12' 34.5\"");
23
-
24
- expect(convertDDToDMS(300)).toBe("+300° 00' 00.0\"");
25
- expect(convertDDToDMS(300.0)).toBe("+300° 00' 00.0\"");
26
+ expect(convertDDToDMS(5.12345, false, 2)).toBe("5° 12' 34.5\"");
27
+ expect(convertDDToDMS(300, true, 5)).toBe("+300° 00' 00.0\"");
28
+ expect(convertDDToDMS(300.0, true, 5)).toBe("+300° 00' 00.0\"");
26
29
  expect(convertDDToDMS(300.00001)).toBe("+300° 00' 00.1\"");
27
- expect(convertDDToDMS(300.1)).toBe("+300° 10' 00.0\"");
30
+ expect(convertDDToDMS(300.1, true, 5)).toBe("+300° 10' 00.0\"");
28
31
  expect(convertDDToDMS(300.12345)).toBe("+300° 12' 34.5\"");
29
32
  expect(convertDDToDMS(300.12345, false)).toBe("300° 12' 34.5\"");
30
-
31
- expect(convertDDToDMS(300, false, false)).toBe("300° 00'");
32
- expect(convertDDToDMS(300.1, false, false)).toBe("300° 10'");
33
- expect(convertDDToDMS(0, false)).toBe("0° 00'");
33
+ expect(convertDDToDMS(300, false, 2)).toBe("300° 00'");
34
+ expect(convertDDToDMS(300.1, false, 2)).toBe("300° 10'");
35
+ expect(convertDDToDMS(0, false, 2)).toBe("0° 00'");
36
+ expect(convertDDToDMS(0.0, false)).toBe("0° 00'");
37
+ expect(convertDDToDMS(0.0, false, 4)).toBe("0° 00' 00\"");
38
+ expect(convertDDToDMS(0.0, false, 5)).toBe("0° 00' 00.0\"");
34
39
  });
35
40
 
36
41
  test("bearingStringValidator", () => {
@@ -3,7 +3,7 @@ export const bearingValueFormatter = (value: any): string => {
3
3
  if (safeValue == null) {
4
4
  return "–";
5
5
  }
6
- return convertDDToDMS(safeValue, false, false);
6
+ return convertDDToDMS(safeValue, false);
7
7
  };
8
8
 
9
9
  export const bearingCorrectionValueFormatter = (value: any): string => {
@@ -12,9 +12,9 @@ export const bearingCorrectionValueFormatter = (value: any): string => {
12
12
  return "–";
13
13
  }
14
14
  if (typeof safeValue === "string") {
15
- return convertDDToDMS(bearingNumberParser(safeValue), true, true);
15
+ return convertDDToDMS(bearingNumberParser(safeValue), true, 4);
16
16
  }
17
- return convertDDToDMS(safeValue, true, true);
17
+ return convertDDToDMS(safeValue, true, 4);
18
18
  };
19
19
 
20
20
  export const bearingNumberParser = (value: string): number | null => {
@@ -40,12 +40,21 @@ export const bearingStringValidator = (
40
40
  return customInvalid ? customInvalid(bearing) : null;
41
41
  };
42
42
 
43
- // Decimal-ish degrees to Degrees Minutes Seconds converter
44
- export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, addTrailingZeros = true): string => {
43
+ /**
44
+ *Decimal-ish degrees to Degrees Minutes Seconds converter
45
+ *
46
+ * @param dd Decimal-ish degrees
47
+ * @param showPositiveSymbol whether the + sign appears before the number
48
+ * @param trailingZeroDp 2 | 4 | 5
49
+ * Example:
50
+ * 2 = 300° 00'
51
+ * 4 = 300° 00' 00"
52
+ * 5 = 300° 00' 00.0"
53
+ * @returns Degrees Minutes Seconds
54
+ */
55
+ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, trailingZeroDp: 2 | 4 | 5 = 2): string => {
45
56
  if (dd == null) return "–";
46
57
 
47
- if (dd === 0) addTrailingZeros = false;
48
-
49
58
  // toFixed rounds parts up greater than 60, which has to be corrected below
50
59
  const [bearingWholeString, bearingDecimalString] = dd.toFixed(5).split(".");
51
60
 
@@ -71,14 +80,13 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, add
71
80
  const deciSecString = bearingDecimalString?.substring(4, 5);
72
81
 
73
82
  let dmsString = `${showPositiveSymbol && dd > 0 ? "+" : ""}${dd < 0 ? "-" : ""}${bearingWhole}°`;
74
- if (addTrailingZeros || deciSecString != "0") {
83
+ if (trailingZeroDp === 5 || deciSecString != "0") {
75
84
  dmsString += `\xa0${minString}'\xa0${secString}.${deciSecString}"`; // "\xa0" is here for non-breaking space
76
- } else if (secNumeric != 0) {
85
+ } else if (trailingZeroDp === 4 || secNumeric != 0) {
77
86
  dmsString += `\xa0${minString}'\xa0${secString}"`;
78
87
  } else {
79
88
  dmsString += `\xa0${minString}'`;
80
89
  }
81
-
82
90
  return dmsString;
83
91
  };
84
92