Skip to content

Commit 6f622e0

Browse files
Fix checkboxes for lithology fields (#1712)
2 parents 414ffe1 + 1546a92 commit 6f622e0

File tree

13 files changed

+218
-66
lines changed

13 files changed

+218
-66
lines changed

src/client/cypress/e2e/filters/filter.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("Search filter tests", () => {
6969
cy.wait("@setting");
7070

7171
// check visibility of filters
72-
cy.contains("h3", "Done").click();
72+
returnToOverview();
7373
cy.get('[data-cy="show-filter-button"]').click();
7474
cy.contains("Registration").click();
7575
cy.contains("Created by");

src/client/cypress/e2e/filters/srsFilter.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("Tests for filtering data by reference system.", () => {
1818
cy.get("@checkbox").check({ force: true });
1919
cy.get("@checkbox").should("be.checked");
2020

21-
cy.contains("h3", "Done").click();
21+
returnToOverview();
2222
cy.get('[data-cy="show-filter-button"]').click();
2323
cy.contains("h6", "Location").click();
2424
cy.get('[data-cy="spatial-reference-filter"]').should("exist");
@@ -27,7 +27,7 @@ describe("Tests for filtering data by reference system.", () => {
2727
cy.get("@checkbox").uncheck({ force: true });
2828
cy.get("@checkbox").should("not.be.checked");
2929

30-
cy.contains("h3", "Done").click();
30+
returnToOverview();
3131
cy.get('[data-cy="show-filter-button"]').click();
3232
cy.contains("h6", "Location").click();
3333
cy.get('[data-cy="spatial-reference-filter"]').should("not.exist");

src/client/cypress/e2e/mainPage/map.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { loginAsEditor } from "../helpers/testHelpers.js";
1+
import { loginAsEditor, returnToOverview } from "../helpers/testHelpers.js";
22

33
describe("Map tests", () => {
44
it("map preserves zoom level and center", () => {
@@ -28,7 +28,7 @@ describe("Map tests", () => {
2828
cy.get('[data-cy="settings-button"]').click();
2929

3030
// return to map
31-
cy.contains("h3", "Done").click();
31+
returnToOverview();
3232

3333
// verify resolution and map center
3434
cy.window().then(win => {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { goToRouteAndAcceptTerms, loginAsAdmin, returnToOverview } from "../helpers/testHelpers";
2+
3+
it("checks that the field settings control the field visibility.", () => {
4+
loginAsAdmin("/");
5+
6+
const waitForSettings = () => {
7+
cy.wait(["@setting", "@codes", "@codelist_GET"]);
8+
};
9+
cy.get('[data-cy="settings-button"]').click();
10+
cy.contains("Lithology fields").click();
11+
cy.contains("Select all").click();
12+
cy.wait("@setting");
13+
waitForSettings();
14+
15+
goToRouteAndAcceptTerms("/1001140/stratigraphy/lithology");
16+
cy.get('[data-cy="styled-layer-9"]').click();
17+
cy.contains("From depth [m MD]").should("exist");
18+
cy.contains("To depth [m MD]").should("exist");
19+
cy.contains("End of borehole").should("exist");
20+
cy.contains("Completeness of entries").should("exist");
21+
cy.contains("Lithology").should("exist");
22+
cy.contains("Original lithology").should("exist");
23+
cy.contains("USCS original classification").should("exist");
24+
cy.contains("USCS way of determination").should("exist");
25+
cy.contains("USCS 1").should("exist");
26+
cy.contains("Grain size 1").should("exist");
27+
cy.contains("USCS 2").should("exist");
28+
cy.contains("Grain size 2").should("exist");
29+
cy.contains("USCS 3").should("exist");
30+
cy.contains("Grain shape").should("exist");
31+
cy.contains("Grain angularity").should("exist");
32+
cy.contains("Organic components").should("exist");
33+
cy.contains("Debris").should("exist");
34+
cy.contains("Debris lithology").should("exist");
35+
cy.contains("Striations").should("exist");
36+
cy.contains("Colour").should("exist");
37+
cy.contains("Consistency").should("exist");
38+
cy.contains("Plasticity").should("exist");
39+
cy.contains("Compactness").should("exist");
40+
cy.contains("Cohesion").should("exist");
41+
cy.contains("Gradation").should("exist");
42+
cy.contains("Humidity").should("exist");
43+
cy.contains("Alteration").should("exist");
44+
cy.contains("Notes").should("exist");
45+
46+
returnToOverview();
47+
cy.get('[data-cy="settings-button"]').click();
48+
cy.contains("Lithology fields").click();
49+
cy.contains("Unselect all").click();
50+
waitForSettings();
51+
52+
goToRouteAndAcceptTerms("/1001140/stratigraphy/lithology");
53+
cy.get('[data-cy="styled-layer-9"]').click();
54+
cy.contains("From depth [m MD]").should("exist");
55+
cy.contains("To depth [m MD]").should("exist");
56+
cy.contains("End of borehole").should("not.exist");
57+
cy.contains("Completeness of entries").should("not.exist");
58+
cy.contains("Original lithology").should("not.exist");
59+
cy.contains("USCS original classification").should("not.exist");
60+
cy.contains("USCS way of determination").should("not.exist");
61+
cy.contains("USCS 1").should("not.exist");
62+
cy.contains("Grain size 1").should("not.exist");
63+
cy.contains("USCS 2").should("not.exist");
64+
cy.contains("Grain size 2").should("not.exist");
65+
cy.contains("USCS 3").should("not.exist");
66+
cy.contains("Grain shape").should("not.exist");
67+
cy.contains("Grain angularity").should("not.exist");
68+
cy.contains("Organic components").should("not.exist");
69+
cy.contains("Debris").should("not.exist");
70+
cy.contains("Debris lithology").should("not.exist");
71+
cy.contains("Colour").should("not.exist");
72+
cy.contains("Consistency").should("not.exist");
73+
cy.contains("Plasticity").should("not.exist");
74+
cy.contains("Compactness").should("not.exist");
75+
cy.contains("Cohesion").should("not.exist");
76+
cy.contains("Gradation").should("not.exist");
77+
cy.contains("Humidity").should("not.exist");
78+
cy.contains("Alteration").should("not.exist");
79+
cy.contains("Notes").should("not.exist");
80+
81+
returnToOverview();
82+
cy.get('[data-cy="settings-button"]').click();
83+
cy.contains("Lithology fields").click();
84+
waitForSettings();
85+
cy.wait(500);
86+
87+
// manually check some and verify states
88+
cy.get('[data-cy="checkbox-original_lithology"]').click();
89+
cy.get('[data-cy="checkbox-plasticity"]').click();
90+
cy.get('[data-cy="checkbox-uscs_1"]').click();
91+
cy.get('[data-cy="checkbox-plasticity"] input').should("be.checked");
92+
cy.get('[data-cy="checkbox-original_lithology"] input').should("be.checked");
93+
cy.get('[data-cy="checkbox-uscs_1"] input').should("be.checked");
94+
95+
cy.get('[data-cy="checkbox-humidity"] input').should("not.be.checked");
96+
cy.get('[data-cy="checkbox-gradation"] input').should("not.be.checked");
97+
cy.get('[data-cy="checkbox-cohesion"] input').should("not.be.checked");
98+
cy.get('[data-cy="checkbox-compactness"] input').should("not.be.checked");
99+
});

src/client/cypress/e2e/settings/mapSettings.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { goToRouteAndAcceptTerms } from "../helpers/testHelpers.js";
1+
import { goToRouteAndAcceptTerms, returnToOverview } from "../helpers/testHelpers.js";
22

33
describe("map settings", () => {
44
it("Adds wms and wmts to user maps", () => {
@@ -28,7 +28,7 @@ describe("map settings", () => {
2828
cy.get('[data-cy="maps-for-user-box"]').contains(wmtsName);
2929

3030
// Verify layers are added to overview map
31-
cy.contains("h3", "Done").click();
31+
returnToOverview();
3232
cy.get('[data-cy="layers-button"]').click();
3333
cy.contains(wmsName);
3434
cy.contains(wmtsName);

src/client/src/components/buttons/buttons.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { forwardRef } from "react";
22
import { useTranslation } from "react-i18next";
33
import CloseIcon from "@mui/icons-material/Close";
4-
import { Button } from "@mui/material";
5-
import { ArrowDownToLine, Check, Pencil, Plus, Save, Trash2 } from "lucide-react";
4+
import { Button, IconButton } from "@mui/material";
5+
import { ArrowDownToLine, Check, ChevronLeft, Pencil, Plus, Save, Trash2 } from "lucide-react";
66
import CopyIcon from "../../assets/icons/copy.svg?react";
77
import { capitalizeFirstLetter } from "../../utils.ts";
88
import { ButtonProps } from "./buttonsInterface";
@@ -131,3 +131,20 @@ export const ExportButton = forwardRef<HTMLButtonElement, ButtonProps>((props, r
131131
/>
132132
);
133133
});
134+
135+
export const ReturnButton = ({ onClick }: { onClick: () => void }) => {
136+
return (
137+
<IconButton
138+
color="primary"
139+
data-cy="backButton"
140+
onClick={onClick}
141+
sx={{
142+
width: "36px",
143+
height: "36px",
144+
marginRight: "18px",
145+
borderRadius: "2px",
146+
}}>
147+
<ChevronLeft />
148+
</IconButton>
149+
);
150+
};

src/client/src/components/legacyComponents/listItem/listItem.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ const ListItem = props => {
1414
style={{
1515
padding: "1em",
1616
borderRadius: "inherit",
17-
borderLeft:
18-
location.pathname.indexOf(path) >= 0 && name !== "done" ? "0.25em solid rgb(237, 29, 36)" : null,
17+
borderLeft: location.pathname.indexOf(path) >= 0 ? "0.25em solid rgb(237, 29, 36)" : null,
1918
}}>
2019
<List.Icon name={icon} size="large" verticalAlign="middle" />
2120
<List.Content>

src/client/src/components/styledComponents.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ export const DialogFooterContainer = styled(Box)({
6363
borderTop: "1px solid " + theme.palette.border,
6464
padding: theme.spacing(3),
6565
});
66+
67+
export const DetailHeaderStack = styled(Stack)({
68+
borderBottom: "1px solid " + theme.palette.boxShadow,
69+
height: "84px",
70+
padding: "16px",
71+
});

src/client/src/pages/detail/detailHeader.tsx

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ import { useContext } from "react";
22
import { useTranslation } from "react-i18next";
33
import { useDispatch } from "react-redux";
44
import { useHistory } from "react-router-dom";
5-
import { Chip, IconButton, Stack, Typography } from "@mui/material";
6-
import { Check, ChevronLeft, Trash2, X } from "lucide-react";
5+
import { Chip, Stack, Typography } from "@mui/material";
6+
import { Check, Trash2, X } from "lucide-react";
77
import { deleteBorehole, lockBorehole, unlockBorehole } from "../../api-lib";
88
import { BoreholeV2 } from "../../api/borehole.ts";
9-
import { theme } from "../../AppTheme.ts";
109
import { useAuth } from "../../auth/useBdmsAuth.tsx";
11-
import { DeleteButton, EditButton, EndEditButton, ExportButton } from "../../components/buttons/buttons.tsx";
10+
import {
11+
DeleteButton,
12+
EditButton,
13+
EndEditButton,
14+
ExportButton,
15+
ReturnButton,
16+
} from "../../components/buttons/buttons.tsx";
1217
import DateText from "../../components/legacyComponents/dateText";
1318
import { PromptContext } from "../../components/prompt/promptContext.tsx";
19+
import { DetailHeaderStack } from "../../components/styledComponents.ts";
1420

1521
interface DetailHeaderProps {
1622
editingEnabled: boolean;
@@ -93,32 +99,16 @@ const DetailHeader = ({
9399
};
94100

95101
return (
96-
<Stack
97-
direction="row"
98-
alignItems="center"
99-
sx={{
100-
borderBottom: "1px solid " + theme.palette.boxShadow,
101-
height: "84px",
102-
padding: "16px",
103-
}}>
102+
<DetailHeaderStack direction="row" alignItems="center">
104103
<Stack direction="row" sx={{ flex: "1 1 100%" }} alignItems={"center"}>
105-
<IconButton
106-
color="primary"
107-
data-cy="backButton"
104+
<ReturnButton
108105
onClick={() => {
109106
{
110107
editingEnabled && (isFormDirty ? stopEditingWithUnsavedChanges() : stopEditing());
111108
history.push("/");
112109
}
113110
}}
114-
sx={{
115-
width: "36px",
116-
height: "36px",
117-
marginRight: "18px",
118-
borderRadius: "2px",
119-
}}>
120-
<ChevronLeft />
121-
</IconButton>
111+
/>
122112
<Stack>
123113
<Typography variant="h2"> {borehole?.alternateName}</Typography>
124114
{!auth.anonymousModeEnabled && (
@@ -165,7 +155,7 @@ const DetailHeader = ({
165155
</>
166156
))}
167157
</Stack>
168-
</Stack>
158+
</DetailHeaderStack>
169159
);
170160
};
171161

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { useHistory } from "react-router-dom";
2+
import { Stack } from "@mui/material";
3+
import { ReturnButton } from "../../components/buttons/buttons.tsx";
4+
import { DetailHeaderStack } from "../../components/styledComponents.ts";
5+
6+
export const DetailHeaderSettings = () => {
7+
const history = useHistory();
8+
9+
return (
10+
<DetailHeaderStack direction="row" alignItems="center">
11+
<Stack direction="row" sx={{ flex: "1 1 100%" }} alignItems={"center"}>
12+
<ReturnButton
13+
onClick={() => {
14+
history.push("/");
15+
}}
16+
/>
17+
</Stack>
18+
</DetailHeaderStack>
19+
);
20+
};

0 commit comments

Comments
 (0)