Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkboxes for lithology fields #1712

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/client/cypress/e2e/filters/filter.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
createStratigraphy,
loginAsAdmin,
returnToOverview,
startBoreholeEditing,
} from "../helpers/testHelpers.js";

describe("Search filter tests", () => {
Expand Down Expand Up @@ -69,7 +68,7 @@ describe("Search filter tests", () => {
cy.wait("@setting");

// check visibility of filters
cy.contains("h3", "Done").click();
returnToOverview();
cy.get('[data-cy="show-filter-button"]').click();
cy.contains("Registration").click();
cy.contains("Created by");
Expand Down
4 changes: 2 additions & 2 deletions src/client/cypress/e2e/filters/srsFilter.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Tests for filtering data by reference system.", () => {
cy.get("@checkbox").check({ force: true });
cy.get("@checkbox").should("be.checked");

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

cy.contains("h3", "Done").click();
returnToOverview();
cy.get('[data-cy="show-filter-button"]').click();
cy.contains("h6", "Location").click();
cy.get('[data-cy="spatial-reference-filter"]').should("not.exist");
Expand Down
4 changes: 2 additions & 2 deletions src/client/cypress/e2e/mainPage/map.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsEditor } from "../helpers/testHelpers.js";
import { loginAsEditor, returnToOverview } from "../helpers/testHelpers.js";

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

// return to map
cy.contains("h3", "Done").click();
returnToOverview();

// verify resolution and map center
cy.window().then(win => {
Expand Down
99 changes: 99 additions & 0 deletions src/client/cypress/e2e/settings/fieldSettings.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { goToRouteAndAcceptTerms, loginAsAdmin, returnToOverview } from "../helpers/testHelpers";

it("checks that the field settings control the field visibility.", () => {
loginAsAdmin("/");

const waitForSettings = () => {
cy.wait(["@setting", "@codes", "@codelist_GET"]);
};
cy.get('[data-cy="settings-button"]').click();
cy.contains("Lithology fields").click();
cy.contains("Select all").click();
cy.wait("@setting");
waitForSettings();

goToRouteAndAcceptTerms("/1001140/stratigraphy/lithology");
cy.get('[data-cy="styled-layer-9"]').click();
cy.contains("From depth [m MD]").should("exist");
cy.contains("To depth [m MD]").should("exist");
cy.contains("End of borehole").should("exist");
cy.contains("Completeness of entries").should("exist");
cy.contains("Lithology").should("exist");
cy.contains("Original lithology").should("exist");
cy.contains("USCS original classification").should("exist");
cy.contains("USCS way of determination").should("exist");
cy.contains("USCS 1").should("exist");
cy.contains("Grain size 1").should("exist");
cy.contains("USCS 2").should("exist");
cy.contains("Grain size 2").should("exist");
cy.contains("USCS 3").should("exist");
cy.contains("Grain shape").should("exist");
cy.contains("Grain angularity").should("exist");
cy.contains("Organic components").should("exist");
cy.contains("Debris").should("exist");
cy.contains("Debris lithology").should("exist");
cy.contains("Striations").should("exist");
cy.contains("Colour").should("exist");
cy.contains("Consistency").should("exist");
cy.contains("Plasticity").should("exist");
cy.contains("Compactness").should("exist");
cy.contains("Cohesion").should("exist");
cy.contains("Gradation").should("exist");
cy.contains("Humidity").should("exist");
cy.contains("Alteration").should("exist");
cy.contains("Notes").should("exist");

returnToOverview();
cy.get('[data-cy="settings-button"]').click();
cy.contains("Lithology fields").click();
cy.contains("Unselect all").click();
waitForSettings();

goToRouteAndAcceptTerms("/1001140/stratigraphy/lithology");
cy.get('[data-cy="styled-layer-9"]').click();
cy.contains("From depth [m MD]").should("exist");
cy.contains("To depth [m MD]").should("exist");
cy.contains("End of borehole").should("not.exist");
cy.contains("Completeness of entries").should("not.exist");
cy.contains("Original lithology").should("not.exist");
cy.contains("USCS original classification").should("not.exist");
cy.contains("USCS way of determination").should("not.exist");
cy.contains("USCS 1").should("not.exist");
cy.contains("Grain size 1").should("not.exist");
cy.contains("USCS 2").should("not.exist");
cy.contains("Grain size 2").should("not.exist");
cy.contains("USCS 3").should("not.exist");
cy.contains("Grain shape").should("not.exist");
cy.contains("Grain angularity").should("not.exist");
cy.contains("Organic components").should("not.exist");
cy.contains("Debris").should("not.exist");
cy.contains("Debris lithology").should("not.exist");
cy.contains("Colour").should("not.exist");
cy.contains("Consistency").should("not.exist");
cy.contains("Plasticity").should("not.exist");
cy.contains("Compactness").should("not.exist");
cy.contains("Cohesion").should("not.exist");
cy.contains("Gradation").should("not.exist");
cy.contains("Humidity").should("not.exist");
cy.contains("Alteration").should("not.exist");
cy.contains("Notes").should("not.exist");

returnToOverview();
cy.get('[data-cy="settings-button"]').click();
cy.contains("Lithology fields").click();
waitForSettings();
cy.wait(500);

// manually check some and verify states
cy.get('[data-cy="checkbox-original_lithology"]').click();
cy.get('[data-cy="checkbox-plasticity"]').click();
cy.get('[data-cy="checkbox-uscs_1"]').click();
cy.get('[data-cy="checkbox-plasticity"] input').should("be.checked");
cy.get('[data-cy="checkbox-original_lithology"] input').should("be.checked");
cy.get('[data-cy="checkbox-uscs_1"] input').should("be.checked");

cy.get('[data-cy="checkbox-humidity"] input').should("not.be.checked");
cy.get('[data-cy="checkbox-gradation"] input').should("not.be.checked");
cy.get('[data-cy="checkbox-cohesion"] input').should("not.be.checked");
cy.get('[data-cy="checkbox-compactness"] input').should("not.be.checked");
});
4 changes: 2 additions & 2 deletions src/client/cypress/e2e/settings/mapSettings.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { goToRouteAndAcceptTerms } from "../helpers/testHelpers.js";
import { goToRouteAndAcceptTerms, returnToOverview } from "../helpers/testHelpers.js";

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

// Verify layers are added to overview map
cy.contains("h3", "Done").click();
returnToOverview();
cy.get('[data-cy="layers-button"]').click();
cy.contains(wmsName);
cy.contains(wmtsName);
Expand Down
21 changes: 19 additions & 2 deletions src/client/src/components/buttons/buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { forwardRef } from "react";
import { useTranslation } from "react-i18next";
import CloseIcon from "@mui/icons-material/Close";
import { Button } from "@mui/material";
import { ArrowDownToLine, Check, Pencil, Plus, Save, Trash2 } from "lucide-react";
import { Button, IconButton } from "@mui/material";
import { ArrowDownToLine, Check, ChevronLeft, Pencil, Plus, Save, Trash2 } from "lucide-react";
import CopyIcon from "../../assets/icons/copy.svg?react";
import { capitalizeFirstLetter } from "../../utils.ts";
import { ButtonProps } from "./buttonsInterface";
Expand Down Expand Up @@ -131,3 +131,20 @@ export const ExportButton = forwardRef<HTMLButtonElement, ButtonProps>((props, r
/>
);
});

export const ReturnButton = ({ onClick }: { onClick: () => void }) => {
return (
<IconButton
color="primary"
data-cy="backButton"
onClick={onClick}
sx={{
width: "36px",
height: "36px",
marginRight: "18px",
borderRadius: "2px",
}}>
<ChevronLeft />
</IconButton>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const ListItem = props => {
style={{
padding: "1em",
borderRadius: "inherit",
borderLeft:
location.pathname.indexOf(path) >= 0 && name !== "done" ? "0.25em solid rgb(237, 29, 36)" : null,
borderLeft: location.pathname.indexOf(path) >= 0 ? "0.25em solid rgb(237, 29, 36)" : null,
}}>
<List.Icon name={icon} size="large" verticalAlign="middle" />
<List.Content>
Expand Down
6 changes: 6 additions & 0 deletions src/client/src/components/styledComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ export const DialogFooterContainer = styled(Box)({
borderTop: "1px solid " + theme.palette.border,
padding: theme.spacing(3),
});

export const DetailHeaderStack = styled(Stack)({
borderBottom: "1px solid " + theme.palette.boxShadow,
height: "84px",
padding: "16px",
});
38 changes: 14 additions & 24 deletions src/client/src/pages/detail/detailHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ import { useContext } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { useHistory } from "react-router-dom";
import { Chip, IconButton, Stack, Typography } from "@mui/material";
import { Check, ChevronLeft, Trash2, X } from "lucide-react";
import { Chip, Stack, Typography } from "@mui/material";
import { Check, Trash2, X } from "lucide-react";
import { deleteBorehole, lockBorehole, unlockBorehole } from "../../api-lib";
import { BoreholeV2 } from "../../api/borehole.ts";
import { theme } from "../../AppTheme.ts";
import { useAuth } from "../../auth/useBdmsAuth.tsx";
import { DeleteButton, EditButton, EndEditButton, ExportButton } from "../../components/buttons/buttons.tsx";
import {
DeleteButton,
EditButton,
EndEditButton,
ExportButton,
ReturnButton,
} from "../../components/buttons/buttons.tsx";
import DateText from "../../components/legacyComponents/dateText";
import { PromptContext } from "../../components/prompt/promptContext.tsx";
import { DetailHeaderStack } from "../../components/styledComponents.ts";

interface DetailHeaderProps {
editingEnabled: boolean;
Expand Down Expand Up @@ -93,32 +99,16 @@ const DetailHeader = ({
};

return (
<Stack
direction="row"
alignItems="center"
sx={{
borderBottom: "1px solid " + theme.palette.boxShadow,
height: "84px",
padding: "16px",
}}>
<DetailHeaderStack direction="row" alignItems="center">
<Stack direction="row" sx={{ flex: "1 1 100%" }} alignItems={"center"}>
<IconButton
color="primary"
data-cy="backButton"
<ReturnButton
onClick={() => {
{
editingEnabled && (isFormDirty ? stopEditingWithUnsavedChanges() : stopEditing());
history.push("/");
}
}}
sx={{
width: "36px",
height: "36px",
marginRight: "18px",
borderRadius: "2px",
}}>
<ChevronLeft />
</IconButton>
/>
<Stack>
<Typography variant="h2"> {borehole?.alternateName}</Typography>
{!auth.anonymousModeEnabled && (
Expand Down Expand Up @@ -165,7 +155,7 @@ const DetailHeader = ({
</>
))}
</Stack>
</Stack>
</DetailHeaderStack>
);
};

Expand Down
20 changes: 20 additions & 0 deletions src/client/src/pages/detail/detailHeaderSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useHistory } from "react-router-dom";
import { Stack } from "@mui/material";
import { ReturnButton } from "../../components/buttons/buttons.tsx";
import { DetailHeaderStack } from "../../components/styledComponents.ts";

export const DetailHeaderSettings = () => {
const history = useHistory();

return (
<DetailHeaderStack direction="row" alignItems="center">
<Stack direction="row" sx={{ flex: "1 1 100%" }} alignItems={"center"}>
<ReturnButton
onClick={() => {
history.push("/");
}}
/>
</Stack>
</DetailHeaderStack>
);
};
Loading
Loading