Skip to content

Commit

Permalink
Merge branch 'main' into adapt-borehole-general-segment
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt authored Nov 18, 2024
2 parents df2cc62 + adaa370 commit b6a3f88
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- WMTS Services are now supported as custom user layers.
- Added data extraction API.
- Added support to extract coordinates from a borehole attachment.
- Show ChangedAt and ChangedBy information in borehole detail header.

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1536,13 +1536,13 @@ INSERT INTO new_lithostrati(geolcode, text_cli, order_cli, conf_cli, path_cli)
(15200493, 'Murchisonaeoolith-Formation', 15140, '{""color"":[190,165,160]}', '15200493');
-- remove references to codelists that get deleted
UPDATE bdms.layer SET lithostratigraphy_id_cli = NULL
UPDATE bdms.layer SET lithostratigraphy_id_cli = NULL
WHERE lithostratigraphy_id_cli NOT IN (SELECT geolcode FROM new_lithostrati nl);
UPDATE bdms.lithostratigraphy SET lithostratigraphy_id = NULL
UPDATE bdms.lithostratigraphy SET lithostratigraphy_id = NULL
WHERE lithostratigraphy_id NOT IN (SELECT geolcode FROM new_lithostrati nl);
UPDATE bdms.bdms.borehole SET lithostrat_id_cli = NULL
UPDATE bdms.borehole SET lithostrat_id_cli = NULL
WHERE lithostrat_id_cli NOT IN (SELECT geolcode FROM new_lithostrati nl);
-- insert new lithostratigraphy codelist
Expand All @@ -1555,7 +1555,7 @@ INSERT INTO bdms.codelist (id_cli, geolcode, schema_cli, code_cli, text_cli_en,
UPDATE bdms.lithostratigraphy SET lithostratigraphy_id = lithostratigraphy_id + 100000;
UPDATE bdms.bdms.borehole SET lithostrat_id_cli = lithostrat_id_cli + 100000;
UPDATE bdms.borehole SET lithostrat_id_cli = lithostrat_id_cli + 100000;
-- delete old codelist entries
DELETE FROM bdms.codelist cl WHERE schema_cli = 'custom.lithostratigraphy_top_bedrock' AND id_cli = geolcode;
Expand Down
1 change: 1 addition & 0 deletions src/client/public/locale/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
"role": "Rolle",
"roles": "Rollen",
"save": "Speichern",
"savedChanges": "Änderungen gespeichert",
"saving": "Speichern",
"search": "Suchen",
"searchFilterLocation": "Suchfilter Standort",
Expand Down
1 change: 1 addition & 0 deletions src/client/public/locale/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@
"role": "Role",
"roles": "Roles",
"save": "Save",
"savedChanges": "Changes saved",
"saving": "Saving",
"search": "Search",
"searchFilterLocation": "Location filters",
Expand Down
1 change: 1 addition & 0 deletions src/client/public/locale/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
"role": "Rôle",
"roles": "Rôles",
"save": "Enregistrer",
"savedChanges": "Modifications enregistrées",
"saving": "Enregistrement",
"search": "Rechercher",
"searchFilterLocation": "Filtres par position",
Expand Down
1 change: 1 addition & 0 deletions src/client/public/locale/it/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
"role": "Ruolo",
"roles": "Ruoli",
"save": "Salvare",
"savedChanges": "Modifiche salvate",
"saving": "Salvataggio",
"search": "Ricercare",
"searchFilterLocation": "Filtri specifici alla posizione",
Expand Down
2 changes: 2 additions & 0 deletions src/client/src/api/borehole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export interface BoreholeV2 {
referenceElevationTypeId: number;
locationPrecisionId: number | null;
hrsId: number;
updated: Date | string | null;
updatedById: number;
}

export const getBoreholeById = async (id: number) => await fetchApiV2(`borehole/${id}`, "GET");
Expand Down
14 changes: 13 additions & 1 deletion src/client/src/pages/detail/detailHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import { useHistory } from "react-router-dom";
import { Chip, IconButton, Stack, Typography } from "@mui/material";
import { Check, ChevronLeft, Trash2, X } from "lucide-react";
import { deleteBorehole, lockBorehole, unlockBorehole } from "../../api-lib";
import { User } from "../../api/apiInterfaces.ts";
import { BoreholeV2 } from "../../api/borehole.ts";
import { theme } from "../../AppTheme.ts";
import { useAuth } from "../../auth/useBdmsAuth.tsx";
import { DeleteButton, EditButton, EndEditButton } from "../../components/buttons/buttons.tsx";
import DateText from "../../components/legacyComponents/dateText";
import { PromptContext } from "../../components/prompt/promptContext.tsx";

interface DetailHeaderProps {
editingEnabled: boolean;
setEditingEnabled: (editingEnabled: boolean) => void;
editableByCurrentUser: boolean;
borehole: BoreholeV2;
updatedBy: User;
isFormDirty: boolean;
triggerReset: () => void;
}
Expand All @@ -26,11 +30,13 @@ const DetailHeader = ({
isFormDirty,
triggerReset,
borehole,
updatedBy,
}: DetailHeaderProps) => {
const history = useHistory();
const dispatch = useDispatch();
const { t } = useTranslation();
const { showPrompt } = useContext(PromptContext);
const auth = useAuth();

const toggleEditing = (editing: boolean) => {
if (!editing) {
Expand Down Expand Up @@ -84,7 +90,7 @@ const DetailHeader = ({
height: "84px",
padding: "16px",
}}>
<Stack direction="row" sx={{ flex: "1 1 100%" }}>
<Stack direction="row" sx={{ flex: "1 1 100%" }} alignItems={"center"}>
<IconButton
color="primary"
data-cy="backButton"
Expand All @@ -109,6 +115,12 @@ const DetailHeader = ({
color={borehole?.workflows[borehole?.workflows.length - 1]?.finished != null ? "success" : "warning"}
icon={borehole?.workflows[borehole?.workflows.length - 1]?.finished != null ? <Check /> : <div />}
/>
{!auth.anonymousModeEnabled && (
<Typography variant="body1" sx={{ marginLeft: "18px" }}>
Changed at: <DateText date={borehole?.updated} /> <br />
Changed by: {updatedBy?.firstName}
</Typography>
)}
</Stack>
<Stack direction="row" data-cy="detail-header" gap={2}>
{editableByCurrentUser &&
Expand Down
14 changes: 13 additions & 1 deletion src/client/src/pages/detail/detailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { useLocation, useParams } from "react-router-dom";
import { Box, CircularProgress, Stack } from "@mui/material";
import { loadBorehole } from "../../api-lib";
import { Borehole, ReduxRootState } from "../../api-lib/ReduxStateInterfaces.ts";
import { User } from "../../api/apiInterfaces.ts";
import { BoreholeV2, getBoreholeById, updateBorehole } from "../../api/borehole.ts";
import { fetchUser } from "../../api/user.ts";
import { LabelingToggleButton } from "../../components/buttons/labelingButton.tsx";
import {
prepareBoreholeDataForSubmit,
Expand All @@ -26,6 +28,7 @@ export const DetailPage: FC = () => {
const [isFormDirty, setIsFormDirty] = useState(false);
const [editableByCurrentUser, setEditableByCurrentUser] = useState(false);
const [borehole, setBorehole] = useState<BoreholeV2 | null>(null);
const [updatedBy, setUpdatedBy] = useState<User | null>(null);
const legacyBorehole: Borehole = useSelector((state: ReduxRootState) => state.core_borehole);
const user = useSelector((state: ReduxRootState) => state.core_user);
const workflowStatus = useSelector((state: ReduxRootState) => state.core_workflow);
Expand All @@ -43,6 +46,14 @@ export const DetailPage: FC = () => {
});
}, [id, user.data.id, workflowStatus]);

useEffect(() => {
if (borehole?.updatedById) {
fetchUser(borehole.updatedById).then(user => {
setUpdatedBy(user);
});
}
}, [borehole?.updatedById]);

const loadOrCreate = useCallback(
(id: string) => {
setLoading(true);
Expand Down Expand Up @@ -120,7 +131,7 @@ export const DetailPage: FC = () => {
setEditableByCurrentUser(userRoleMatches && (isStatusPage || isBoreholeInEditWorkflow));
}, [editingEnabled, user, legacyBorehole, location, togglePanel]);

if (loading || !borehole)
if (loading || !borehole || !updatedBy)
return (
<Stack height="100%" alignItems="center" justifyContent="center">
<CircularProgress />
Expand All @@ -135,6 +146,7 @@ export const DetailPage: FC = () => {
<>
<DetailHeader
borehole={borehole}
updatedBy={updatedBy}
editingEnabled={editingEnabled}
setEditingEnabled={setEditingEnabled}
editableByCurrentUser={editableByCurrentUser}
Expand Down
14 changes: 13 additions & 1 deletion src/client/src/pages/detail/saveBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Box, Stack } from "@mui/material";
import { CircleX } from "lucide-react";
import { CircleCheck, CircleX } from "lucide-react";
import { theme } from "../../AppTheme.ts";
import { DeleteButton, SaveButton } from "../../components/buttons/buttons.tsx";

Expand All @@ -10,13 +11,21 @@ interface SaveBarProps {
isFormDirty: boolean;
}
export const SaveBar = ({ triggerSubmit, triggerReset, isFormDirty }: SaveBarProps) => {
const [showSaveFeedback, setShowSaveFeedback] = useState(false);
const { t } = useTranslation();
const changesMessage = (
<>
<CircleX />
<Box> {t("unsavedChanges")}</Box>
</>
);

const savedMessage = (
<>
<CircleCheck />
<Box> {t("savedChanges")}</Box>
</>
);
return (
<Stack
direction="row"
Expand All @@ -34,6 +43,7 @@ export const SaveBar = ({ triggerSubmit, triggerReset, isFormDirty }: SaveBarPro
spacing={1}
sx={{ flexGrow: 1, color: isFormDirty ? theme.palette.error.light : theme.palette.success.main }}>
{isFormDirty && changesMessage}
{showSaveFeedback && !isFormDirty && savedMessage}
</Stack>

<Stack spacing={1} direction="row">
Expand All @@ -48,7 +58,9 @@ export const SaveBar = ({ triggerSubmit, triggerReset, isFormDirty }: SaveBarPro
disabled={!isFormDirty}
variant="contained"
onClick={() => {
setShowSaveFeedback(true);
triggerSubmit();
setTimeout(() => setShowSaveFeedback(false), 5000);
}}
/>
</Stack>
Expand Down

0 comments on commit b6a3f88

Please sign in to comment.