From aae283b5bdb4cd9bf764e5bea7a816abb9af457c Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Thu, 3 Oct 2024 15:54:13 +0200 Subject: [PATCH 1/2] Fix style of name segment --- .../cypress/e2e/detailPage/location.cy.js | 4 +- .../src/pages/detail/detailPageContent.jsx | 6 +- .../detail/form/location/nameSegment.tsx | 99 +++++++------------ 3 files changed, 44 insertions(+), 65 deletions(-) diff --git a/src/client/cypress/e2e/detailPage/location.cy.js b/src/client/cypress/e2e/detailPage/location.cy.js index 24d57556f..7ce901c1c 100644 --- a/src/client/cypress/e2e/detailPage/location.cy.js +++ b/src/client/cypress/e2e/detailPage/location.cy.js @@ -38,10 +38,10 @@ describe("Tests for 'Location' edit page.", () => { createBorehole({ "extended.original_name": "PHOTOSQUIRREL" }).as("borehole_id"); cy.get("@borehole_id").then(id => { goToRouteAndAcceptTerms(`/${id}`); - cy.get('[data-cy="original-name"]').within(() => { + cy.get('[data-cy="original_name-formInput"]').within(() => { cy.get("input").as("originalNameInput"); }); - cy.get('[data-cy="alternate-name"]').within(() => { + cy.get('[data-cy="alternate_name-formInput"]').within(() => { cy.get("input").as("alternateNameInput"); }); diff --git a/src/client/src/pages/detail/detailPageContent.jsx b/src/client/src/pages/detail/detailPageContent.jsx index c0543ca80..e4f00b4fe 100644 --- a/src/client/src/pages/detail/detailPageContent.jsx +++ b/src/client/src/pages/detail/detailPageContent.jsx @@ -30,7 +30,6 @@ class DetailPageContent extends React.Component { constructor(props) { super(props); - this.checkattribute = false; this.updateAttributeDelay = {}; this.state = { tab: 0, @@ -286,7 +285,10 @@ class DetailPageContent extends React.Component { setState={this.setStateBound} updateBorehole={this.props.updateBorehole} user={user}> - + void; - user: User; + editingEnabled: boolean; } -const NameSegment = ({ borehole, updateChange, user }: NameSegmentProps) => { +const NameSegment = ({ borehole, updateChange, editingEnabled }: NameSegmentProps) => { const [alternateName, setAlternateName] = useState(""); - const { t } = useTranslation(); const auth = useAuth(); - const isEditable = - borehole?.data.role === "EDIT" && borehole?.data.lock !== null && borehole?.data.lock?.id === user?.data.id; - useEffect(() => { setAlternateName(borehole.data.custom.alternate_name || borehole.data.extended.original_name); }, [borehole.data]); @@ -27,61 +23,42 @@ const NameSegment = ({ borehole, updateChange, user }: NameSegmentProps) => { return ( -
- + + + { + setAlternateName(e); + updateChange("custom.alternate_name", e); + }} + /> + + { + updateChange("custom.project_name", e); + }} + /> + + {!auth.anonymousModeEnabled && ( - - - { - 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 ?? ""} - readOnly={!isEditable} - /> - - )} - - - { - updateChange("custom.project_name", e.target.value); + { + setAlternateName(e); + updateChange("extended.original_name", e); + updateChange("custom.alternate_name", e); }} - spellCheck="false" - value={borehole.data.custom.project_name ?? ""} - readOnly={!isEditable} /> - - - - - - { - setAlternateName(e.target.value); - updateChange("custom.alternate_name", e.target.value); - }} - spellCheck="false" - value={alternateName} - readOnly={!isEditable} - /> - - -
+ )} + +
); From a3bd22896ac1d3533011a3e27b709b3de473de07 Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Thu, 3 Oct 2024 17:39:09 +0200 Subject: [PATCH 2/2] Add entries to test --- src/client/cypress/e2e/detailPage/boreholeform.cy.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/cypress/e2e/detailPage/boreholeform.cy.js b/src/client/cypress/e2e/detailPage/boreholeform.cy.js index 118da0f8c..875e5d316 100644 --- a/src/client/cypress/e2e/detailPage/boreholeform.cy.js +++ b/src/client/cypress/e2e/detailPage/boreholeform.cy.js @@ -65,6 +65,9 @@ describe("Test for the borehole form.", () => { sortBy("Name"); clickOnRowWithText("Zena Rath"); + evaluateInput("original_name", "Zena Rath"); + evaluateInput("alternate_name", "Zena Rath"); + evaluateInput("project_name", "Reactive asymmetric alliance"); evaluateSelect("restriction", ""); evaluateSelect("national_interest", "0"); // No evaluateSelect("spatial_reference_system", "20104002"); // LV03 @@ -78,6 +81,9 @@ describe("Test for the borehole form.", () => { returnToOverview(); clickOnRowWithText("Zena Mraz"); + evaluateInput("original_name", "Zena Mraz"); + evaluateInput("alternate_name", "Zena Mraz"); + evaluateInput("project_name", "Ergonomic heuristic installation"); evaluateSelect("restriction", ""); evaluateSelect("national_interest", "1"); // Yes evaluateSelect("spatial_reference_system", "20104002"); // LV03