Skip to content

Commit 4e8035a

Browse files
Fix coordinate reset (#1551)
2 parents 4081a28 + 4c579d3 commit 4e8035a

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/client/cypress/e2e/editor/coordinates.cy.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { setSelect } from "../helpers/formHelpers";
2-
import { delayedType, newEditableBorehole } from "../helpers/testHelpers";
2+
import { delayedType, newEditableBorehole, returnToOverview } from "../helpers/testHelpers";
33

44
function checkDecimalPlaces(inputAlias, expectedDecimalPlaces) {
55
cy.get(inputAlias)
@@ -136,6 +136,14 @@ describe("Tests for editing coordinates of a borehole.", () => {
136136
checkDecimalPlaces("@LV95Y-input", 2);
137137
checkDecimalPlaces("@LV03X-input", 2);
138138
checkDecimalPlaces("@LV03Y-input", 2);
139+
140+
returnToOverview();
141+
newEditableBorehole();
142+
// verify input are cleared for new borehole
143+
cy.get("@LV95X-input").should("have.value", "");
144+
cy.get("@LV95Y-input").should("have.value", "");
145+
cy.get("@LV03X-input").should("have.value", "");
146+
cy.get("@LV03Y-input").should("have.value", "");
139147
});
140148

141149
it("displays correct decimal precision", () => {

src/client/src/api-lib/ReduxStateInterfaces.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ReferenceSystemCode } from "../pages/detail/form/location/coordinateSegmentInterfaces.ts";
2+
13
export interface ReduxRootState {
24
filters: Filters;
35
editor: EditorStore;
@@ -58,7 +60,7 @@ interface BoreholeAttributes {
5860
workgroup: Workgroup;
5961
workflow: Workflow;
6062
id: number;
61-
spatial_reference_system: number;
63+
spatial_reference_system: ReferenceSystemCode;
6264
role: Role;
6365
lock: {
6466
id: number;

src/client/src/pages/detail/form/location/coordinatesSegment.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ const CoordinatesSegment: React.FC<CoordinatesSegmentProps> = ({
118118
// --- Utility functions ---
119119
const updateFormValues = useCallback(
120120
(refSystem: string, locationX: number, locationY: number, precisionX: number, precisionY: number) => {
121-
if (locationX && locationY) {
122-
setValuesForReferenceSystem(refSystem, locationX.toFixed(precisionX), locationY.toFixed(precisionY));
123-
}
121+
const locationXString = (locationX && locationX?.toFixed(precisionX)) || "";
122+
const locationYString = (locationY && locationY?.toFixed(precisionY)) || "";
123+
setValuesForReferenceSystem(refSystem, locationXString, locationYString);
124124
},
125125
[setValuesForReferenceSystem],
126126
);

0 commit comments

Comments
 (0)