Skip to content

Commit

Permalink
Merge branch 'main' into show-disclaimer
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt authored Aug 19, 2024
2 parents ee33895 + d9b7f37 commit 7709260
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Changed boreholes table design.
- Migrated `Workgroup` API endpoints to .NET API.
- Use `filled` style for form components.
- The borehole table now displays the attribute `alternate_name` instead of `origianal_name` in the `Name` column.

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions src/api-legacy/v1/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def getordering(self, orderby, direction):
if orderby == 'original_name':
_orderby = 'original_name_bho'

if orderby == 'alternate_name':
_orderby = 'alternate_name_bho'

elif orderby == 'restriction':
_orderby = 'restriction_id_cli'

Expand Down
1 change: 1 addition & 0 deletions src/api-legacy/v1/borehole/editinglist.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ async def execute(
)
END AS lock,
original_name_bho as original_name,
alternate_name_bho as alternate_name,
borehole_type_id as borehole_type,
restriction_id_cli as restriction,
to_char(
Expand Down
4 changes: 2 additions & 2 deletions src/api-legacy/v1/setting/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ async def execute(self, user_id, tree, value, key=None):
"filter": {},
"viewerFilter": {},
"boreholetable": {
"orderby": "original_name",
"orderby": "alternate_name",
"direction": "ASC"
},
"eboreholetable": {
"orderby": "original_name",
"orderby": "alternate_name",
"direction": "ASC"
},
"map": {
Expand Down
5 changes: 3 additions & 2 deletions src/api/BdmsContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static void SeedData(this BdmsContext context)
.RuleFor(o => o.Restriction, _ => default!)
.RuleFor(o => o.RestrictionUntil, f => f.Date.Future().ToUniversalTime().OrNull(f, .9f))
.RuleFor(o => o.OriginalName, f => f.Name.FullName())
.RuleFor(o => o.AlternateName, f => f.Person.UserName.OrNull(f, .1f))
.RuleFor(o => o.AlternateName, f => "")
.RuleFor(o => o.LocationPrecisionId, f => f.PickRandom(locationPrecisionIds).OrNull(f, .1f))
.RuleFor(o => o.LocationPrecision, _ => default!)
.RuleFor(o => o.ElevationPrecisionId, f => f.PickRandom(elevationPrecisionIds).OrNull(f, .1f))
Expand Down Expand Up @@ -186,7 +186,8 @@ public static void SeedData(this BdmsContext context)
.RuleFor(o => o.PrecisionLocationX, f => f.PickRandom(Enumerable.Range(0, 10)))
.RuleFor(o => o.PrecisionLocationY, f => f.PickRandom(Enumerable.Range(0, 10)))
.RuleFor(o => o.PrecisionLocationXLV03, f => f.PickRandom(Enumerable.Range(0, 10)))
.RuleFor(o => o.PrecisionLocationYLV03, f => f.PickRandom(Enumerable.Range(0, 10)));
.RuleFor(o => o.PrecisionLocationYLV03, f => f.PickRandom(Enumerable.Range(0, 10)))
.FinishWith((f, o) => { o.AlternateName = o.OriginalName; });

Borehole SeededBoreholes(int seed) => fakeBoreholes.UseSeed(seed).Generate();
context.BulkInsert(boreholeRange.Select(SeededBoreholes).ToList(), bulkConfig);
Expand Down
6 changes: 3 additions & 3 deletions src/client/cypress/e2e/editor/boreholeTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ describe("Borehole editor table tests", () => {

// sort by reference elevation
sortBy("Reference elevation");
verifyRowContains("3.36", 0);
verifyRowContains("4.26", 1);
verifyRowContains("4.58", 2);
verifyRowContains("1.8", 0);
verifyRowContains("3.47", 1);
verifyRowContains("13.13", 2);

// sort by borehole type
sortBy("Borehole type");
Expand Down
12 changes: 9 additions & 3 deletions src/client/cypress/e2e/editor/bulkedit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ describe("Test the borehole bulk edit feature.", () => {

it("fills all bulkedit fields and saves.", () => {
// create boreholes
createBorehole({ "extended.original_name": "AAA_NINTIC" }).as("borehole_id_1");
createBorehole({ "extended.original_name": "AAA_LOMONE" }).as("borehole_id_2");
createBorehole({ "extended.original_name": "AAA_NINTIC", "custom.alternate_name": "AAA_NINTIC" }).as(
"borehole_id_1",
);
createBorehole({ "extended.original_name": "AAA_LOMONE", "custom.alternate_name": "AAA_LOMONE" }).as(
"borehole_id_2",
);

loginAsAdmin();
showTableAndWaitForData();
Expand Down Expand Up @@ -121,7 +125,9 @@ describe("Test the borehole bulk edit feature.", () => {
});

it("cannot select locked boreholes for bulk edit", () => {
createBorehole({ "extended.original_name": "AAA_JUNIORSOUFFLE" }).as("borehole_id");
createBorehole({ "extended.original_name": "AAA_JUNIORSOUFFLE", "custom.alternate_name": "AAA_JUNIORSOUFFLE" }).as(
"borehole_id",
);
cy.get("@borehole_id").then(id => {
goToRouteAndAccptTerms(`/${id}/borehole`);
startBoreholeEditing();
Expand Down
24 changes: 23 additions & 1 deletion src/client/cypress/e2e/editor/location.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,32 @@ describe("Tests for 'Location' edit page.", () => {
it("creates and deletes a borehole.", () => {
newEditableBorehole();

const originalNameInput = cy.contains("label", "Original name").next().children("input");
const alternateNameInput = cy.contains("label", "Name").next().children("input");

// enter original name
cy.contains("label", "Original name").next().children("input").type("AAA_SCATORPS");
originalNameInput.type("Original Name");
cy.wait("@edit_patch");

// ensure alternate name contains original name
alternateNameInput.should("have.value", "Original Name");

// change alternate name
alternateNameInput.clear().type("Alternate name changed");
cy.wait("@edit_patch");

// ensure alternate name and original name contain correct values
originalNameInput.should("have.value", "Original Name");
alternateNameInput.should("have.value", "Alternate name changed");

// change original name
originalNameInput.clear().type("AAA_SCATORPS");
cy.wait("@edit_patch");

// ensure alternate name and original name contain correct values
originalNameInput.should("have.value", "AAA_SCATORPS");
alternateNameInput.should("have.value", "AAA_SCATORPS");

// stop editing
stopBoreholeEditing();
returnToOverview();
Expand Down
9 changes: 8 additions & 1 deletion src/client/src/pages/detail/form/location/nameSegment.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Form, Input, Segment } from "semantic-ui-react";
import { useTranslation } from "react-i18next";
import { useState } from "react";

const NameSegment = props => {
const { size, borehole, updateChange, user } = props;
const [alternateName, setAlternateName] = useState(
borehole.data.custom.alternate_name || borehole.data.extended.original_name,
);
const { t } = useTranslation();

const isEditable =
Expand All @@ -19,7 +23,9 @@ const NameSegment = props => {
autoComplete="off"
autoCorrect="off"
onChange={e => {
setAlternateName(e.target.value);
updateChange("extended.original_name", e.target.value);
updateChange("custom.alternate_name", e.target.value);
}}
spellCheck="false"
value={borehole.data.extended.original_name ?? ""}
Expand Down Expand Up @@ -49,10 +55,11 @@ const NameSegment = props => {
autoComplete="off"
autoCorrect="off"
onChange={e => {
setAlternateName(e.target.value);
updateChange("custom.alternate_name", e.target.value);
}}
spellCheck="false"
value={borehole.data.custom.alternate_name ?? ""}
value={alternateName}
readOnly={!isEditable}
/>
</Form.Field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const BoreholeTable: FC<BoreholeTableProps> = ({
}, [boreholes?.length]);

const columns: GridColDef[] = [
{ field: "original_name", headerName: t("name"), flex: 1 },
{ field: "alternate_name", headerName: t("name"), flex: 1 },
{
field: "workgroup",
valueGetter: (value: { name: string }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const BottomBarContainer = ({
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>([]);
const [sortModel, setSortModel] = useState<GridSortModel>([
{
field: boreholes.orderby ?? "original_name",
field: boreholes.orderby ?? "alternate_name",
sort: boreholes.direction ? (boreholes.direction.toLowerCase() as GridSortDirection) : "asc",
},
]);
Expand All @@ -57,7 +57,7 @@ const BottomBarContainer = ({
paginationModel.page + 1, // MUI pagination starts at 0, whereas server pagination starts at 1
paginationModel.pageSize,
search.filter,
sortModel[0]?.field || "original_name",
sortModel[0]?.field || "alternate_name",
sortModel[0]?.sort === "desc" ? "DESC" : "ASC",
featureIds,
);
Expand Down
2 changes: 1 addition & 1 deletion src/client/src/pages/overview/layout/mapView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const mapDispatchToProps = (dispatch, ownprops) => {
page,
limit = 100,
filter = {},
orderby = "original_name",
orderby = "alternate_name",
direction = "ASC",
featureIds = [],
) => {
Expand Down

0 comments on commit 7709260

Please sign in to comment.