Skip to content

Commit a1734d9

Browse files
Restriction end date (#1741)
2 parents ddcf77c + 7e05f14 commit a1734d9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/client/cypress/e2e/detailPage/location.cy.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addItem, saveWithSaveBar, stopEditing } from "../helpers/buttonHelpers";
22
import { checkRowWithText, clickOnRowWithText, showTableAndWaitForData } from "../helpers/dataGridHelpers";
3-
import { evaluateInput, evaluateSelect, setInput, setSelect } from "../helpers/formHelpers";
3+
import { evaluateInput, evaluateSelect, isDisabled, setInput, setSelect } from "../helpers/formHelpers";
44
import {
55
createBorehole,
66
goToRouteAndAcceptTerms,
@@ -124,6 +124,21 @@ describe("Tests for 'Location' edit page.", () => {
124124
});
125125
});
126126

127+
it("Saves restriction until date.", () => {
128+
newEditableBorehole().as("borehole_id");
129+
130+
setSelect("restrictionId", 3);
131+
isDisabled("restrictionUntil", false);
132+
setInput("restrictionUntil", "2012-11-14");
133+
evaluateInput("restrictionUntil", "2012-11-14");
134+
saveWithSaveBar();
135+
// navigate away and back to check if values are saved
136+
cy.get('[data-cy="borehole-menu-item"]').click();
137+
cy.get('[data-cy="location-menu-item"]').click();
138+
139+
evaluateInput("restrictionUntil", "2012-11-14");
140+
});
141+
127142
it("saves with ctrl s", () => {
128143
newEditableBorehole();
129144

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const RestrictionSegment = ({ borehole, editingEnabled, formMethods }: Restricti
2424
const { dirtyFields } = formMethods.formState;
2525
const restriction = formMethods.watch("restrictionId");
2626

27+
useEffect(() => {
28+
//TODO: Adapt data type on backend to Date instead of slicing the returned DateTime
29+
formMethods.setValue("restrictionUntil", borehole.restrictionUntil?.toString().slice(0, 10) ?? "");
30+
}, [borehole.restrictionUntil, formMethods]);
31+
2732
useEffect(() => {
2833
if (dirtyFields.restrictionId) {
2934
setRestrictionUntilEnabled(restriction === restrictionUntilCode);

0 commit comments

Comments
 (0)