diff --git a/CHANGELOG.md b/CHANGELOG.md index dad618c04..1770a17a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Removed the functionality to add new users since they are now managed by the IAM. - Removed the functionality to edit user details (first name, surname and password) since they are now managed by the IAM. - Removed middle name from user details because it was not used until now. +- Disable inputs of the editor view's _borehole_ tab, when editing mode is not active or borehole status does not allow editing. ### Fixed diff --git a/src/client/src/commons/form/borehole/boreholeForm.js b/src/client/src/commons/form/borehole/boreholeForm.js index 6f0ef7508..8a11c3010 100644 --- a/src/client/src/commons/form/borehole/boreholeForm.js +++ b/src/client/src/commons/form/borehole/boreholeForm.js @@ -340,14 +340,16 @@ class BoreholeForm extends React.Component { size={size} borehole={borehole} updateChange={this.updateChange} - updateNumber={this.updateNumber}> + updateNumber={this.updateNumber} + isEditable={isEditable}> + debug={this.props.developer.debug} + isEditable={isEditable}> )} /> diff --git a/src/client/src/commons/form/borehole/segments/boreholeDetailSegment.js b/src/client/src/commons/form/borehole/segments/boreholeDetailSegment.js index c9972ef7e..ec7f4b0f7 100644 --- a/src/client/src/commons/form/borehole/segments/boreholeDetailSegment.js +++ b/src/client/src/commons/form/borehole/segments/boreholeDetailSegment.js @@ -6,16 +6,12 @@ import DomainTree from "../../domain/tree/domainTree"; import TranslationText from "../../translationText"; import { NumericFormat } from "react-number-format"; import { Form, Segment } from "semantic-ui-react"; -import { - FormControl, - RadioGroup, - FormControlLabel, - Radio, -} from "@mui/material"; +import { FormControl, RadioGroup, FormControlLabel } from "@mui/material"; import { parseIfString } from "../../formUtils"; +import { DisabledRadio } from "./styledComponents"; const BoreholeDetailSegment = props => { - const { size, borehole, updateChange, updateNumber } = props; + const { size, borehole, updateChange, updateNumber, isEditable } = props; return (
@@ -41,6 +37,7 @@ const BoreholeDetailSegment = props => { : borehole.data.total_depth } thousandSeparator="'" + readOnly={!isEditable} /> @@ -53,6 +50,7 @@ const BoreholeDetailSegment = props => { }} schema="custom.qt_top_bedrock" selected={borehole.data.custom.qt_depth} + readOnly={!isEditable} /> @@ -78,6 +76,7 @@ const BoreholeDetailSegment = props => { : borehole.data.total_depth_tvd } thousandSeparator="'" + readOnly={!isEditable} /> @@ -91,6 +90,7 @@ const BoreholeDetailSegment = props => { }} schema="custom.qt_top_bedrock" selected={borehole.data.qt_total_depth_tvd} + readOnly={!isEditable} /> @@ -116,6 +116,7 @@ const BoreholeDetailSegment = props => { : borehole.data.extended.top_bedrock } thousandSeparator="'" + readOnly={!isEditable} /> @@ -135,6 +136,7 @@ const BoreholeDetailSegment = props => { spellCheck="false" value={borehole.data.custom.qt_top_bedrock} thousandSeparator="'" + readOnly={!isEditable} /> @@ -160,6 +162,7 @@ const BoreholeDetailSegment = props => { : borehole.data.extended.top_bedrock_tvd } thousandSeparator="'" + readOnly={!isEditable} /> @@ -180,6 +183,7 @@ const BoreholeDetailSegment = props => { spellCheck="false" value={borehole.data.custom.qt_top_bedrock_tvd} thousandSeparator="'" + readOnly={!isEditable} /> @@ -208,17 +212,17 @@ const BoreholeDetailSegment = props => { }}> } + control={} label={} /> } + control={} label={} /> } + control={} label={} /> @@ -240,6 +244,7 @@ const BoreholeDetailSegment = props => { schema="custom.lithology_top_bedrock" selected={borehole.data.custom.lithology_top_bedrock} title={} + isEditable={isEditable} /> @@ -264,6 +269,7 @@ const BoreholeDetailSegment = props => { schema="custom.lithostratigraphy_top_bedrock" selected={borehole.data.custom.lithostratigraphy_top_bedrock} title={} + isEditable={isEditable} /> @@ -289,6 +295,7 @@ const BoreholeDetailSegment = props => { schema="custom.chronostratigraphy_top_bedrock" selected={borehole.data.custom.chronostratigraphy_top_bedrock} title={} + isEditable={isEditable} /> diff --git a/src/client/src/commons/form/borehole/segments/boreholeGeneralSegment.js b/src/client/src/commons/form/borehole/segments/boreholeGeneralSegment.js index 9e6e84c0c..dcab19aae 100644 --- a/src/client/src/commons/form/borehole/segments/boreholeGeneralSegment.js +++ b/src/client/src/commons/form/borehole/segments/boreholeGeneralSegment.js @@ -10,7 +10,7 @@ import { Form, Input, Segment, TextArea } from "semantic-ui-react"; import { parseIfString } from "../../formUtils"; const BoreholeGeneralSegment = props => { - const { size, borehole, updateChange, updateNumber } = props; + const { size, borehole, updateChange, updateNumber, isEditable } = props; return (
{ }} schema="kind" selected={borehole.data.kind} + readOnly={!isEditable} /> @@ -52,6 +53,7 @@ const BoreholeGeneralSegment = props => { }} schema="extended.drilling_method" selected={borehole.data.extended.drilling_method} + readOnly={!isEditable} /> @@ -64,6 +66,7 @@ const BoreholeGeneralSegment = props => { }} schema="extended.purpose" selected={borehole.data.extended.purpose} + readOnly={!isEditable} /> @@ -84,6 +87,7 @@ const BoreholeGeneralSegment = props => { }} schema="custom.cuttings" selected={borehole.data.custom.cuttings} + readOnly={!isEditable} />
@@ -97,6 +101,7 @@ const BoreholeGeneralSegment = props => { onChange={selected => { updateChange("spud_date", selected, false); }} + isEditable={isEditable} /> @@ -116,6 +121,7 @@ const BoreholeGeneralSegment = props => { onChange={selected => { updateChange("drilling_date", selected, false); }} + isEditable={isEditable} /> @@ -138,6 +144,7 @@ const BoreholeGeneralSegment = props => { ? "" : borehole.data.custom.drill_diameter } + readOnly={!isEditable} /> @@ -161,6 +168,7 @@ const BoreholeGeneralSegment = props => { return r; })()} thousandSeparator="'" + readOnly={!isEditable} /> @@ -173,6 +181,7 @@ const BoreholeGeneralSegment = props => { }} schema="extended.status" selected={borehole.data.extended.status} + readOnly={!isEditable} /> @@ -197,6 +206,7 @@ const BoreholeGeneralSegment = props => { ? "" : borehole.data.inclination } + readOnly={!isEditable} /> @@ -219,6 +229,7 @@ const BoreholeGeneralSegment = props => { ? "" : borehole.data.inclination_direction } + readOnly={!isEditable} /> @@ -231,6 +242,7 @@ const BoreholeGeneralSegment = props => { }} schema="custom.qt_bore_inc_dir" selected={borehole.data.custom.qt_bore_inc_dir} + readOnly={!isEditable} /> @@ -251,6 +263,7 @@ const BoreholeGeneralSegment = props => { }} rows={14} value={borehole.data.custom.remarks} + readOnly={!isEditable} /> diff --git a/src/client/src/commons/form/borehole/segments/coordinatesSegment.js b/src/client/src/commons/form/borehole/segments/coordinatesSegment.js index 7504be4ea..4be33557f 100644 --- a/src/client/src/commons/form/borehole/segments/coordinatesSegment.js +++ b/src/client/src/commons/form/borehole/segments/coordinatesSegment.js @@ -5,7 +5,6 @@ import { Stack, RadioGroup, FormControlLabel, - Radio, } from "@mui/material"; import { Controller, useForm } from "react-hook-form"; import DomainDropdown from "../../domain/dropdown/domainDropdown"; @@ -15,6 +14,7 @@ import { Form, Segment } from "semantic-ui-react"; import { NumericFormat } from "react-number-format"; import { parseIfString, getPrecision } from "../../formUtils"; import { fetchApiV2 } from "../../../../api/fetchApiV2"; +import { DisabledRadio } from "./styledComponents"; const webApilv95tolv03 = "https://geodesy.geo.admin.ch/reframe/lv95tolv03"; const webApilv03tolv95 = "https://geodesy.geo.admin.ch/reframe/lv03tolv95"; @@ -388,16 +388,7 @@ const CoordinatesSegment = props => { - } + control={} label={ { - } + control={} label={ { }}> - } + control={} label={} /> - } + control={} label={} /> - } + control={} label={} /> diff --git a/src/client/src/commons/form/borehole/segments/styledComponents.js b/src/client/src/commons/form/borehole/segments/styledComponents.js new file mode 100644 index 000000000..d978d9b8e --- /dev/null +++ b/src/client/src/commons/form/borehole/segments/styledComponents.js @@ -0,0 +1,16 @@ +import React from "react"; +import { Radio } from "@mui/material"; + +export const DisabledRadio = ({ isEditable, ...props }) => { + return ( + + ); +}; diff --git a/src/client/src/commons/form/domain/tree/domainTree.js b/src/client/src/commons/form/domain/tree/domainTree.js index 5768392ad..fc32059dd 100644 --- a/src/client/src/commons/form/domain/tree/domainTree.js +++ b/src/client/src/commons/form/domain/tree/domainTree.js @@ -135,7 +135,9 @@ class DomainTree extends React.Component { } handleOpen() { - this.setState({ modalOpen: true }); + if (this.props.isEditable === true) { + this.setState({ modalOpen: true }); + } } handleClose() { @@ -168,7 +170,7 @@ class DomainTree extends React.Component { } render() { - const { domains, schema } = this.props; + const { domains, schema, isEditable } = this.props; if (!domains.data.hasOwnProperty(schema)) { if (domains.isFetching === true) { return "loading translations"; @@ -415,6 +417,7 @@ class DomainTree extends React.Component { icon="sitemap" onClick={this.handleOpen} value={this.getDomainText(this.state.selected)} + readOnly={!isEditable} /> }> @@ -543,6 +546,7 @@ class DomainTree extends React.Component { ? this.state.selectedFilters[lev].id : null } + readOnly={!isEditable} /> ) : null; @@ -575,6 +579,7 @@ class DomainTree extends React.Component { }} placeholder="Search..." value={this.state.search} + readOnly={!isEditable} /> diff --git a/src/client/src/commons/form/multiple/multipleForm.js b/src/client/src/commons/form/multiple/multipleForm.js index 8517cd995..51957c827 100644 --- a/src/client/src/commons/form/multiple/multipleForm.js +++ b/src/client/src/commons/form/multiple/multipleForm.js @@ -177,6 +177,7 @@ class MultipleForm extends React.Component { schema={schema === null ? this.state.data[field].api : schema} selected={this.state.data[field].value} title={} + isEditable={true} /> ); diff --git a/src/client/src/commons/form/profile/components/profileAttributes/components/profileAttributeList/profileAttributeList.js b/src/client/src/commons/form/profile/components/profileAttributes/components/profileAttributeList/profileAttributeList.js index ebd422fe3..154eefd2d 100644 --- a/src/client/src/commons/form/profile/components/profileAttributes/components/profileAttributeList/profileAttributeList.js +++ b/src/client/src/commons/form/profile/components/profileAttributes/components/profileAttributeList/profileAttributeList.js @@ -200,6 +200,7 @@ const ProfileAttributeList = props => { _.isNil(layer?.[item.value]) ? null : layer[item.value] } title={} + isEditable={true} /> )} diff --git a/src/client/src/commons/search/components/listFilter.js b/src/client/src/commons/search/components/listFilter.js index 7e9bcd577..51b375c14 100644 --- a/src/client/src/commons/search/components/listFilter.js +++ b/src/client/src/commons/search/components/listFilter.js @@ -387,6 +387,7 @@ const ListFilter = props => { : search.filter[item.value] } title={} + isEditable={true} /> )}