Skip to content

Commit

Permalink
Disable borehole inputs (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehats authored Jan 24, 2024
2 parents 6961003 + 9070f4b commit ad8f4cd
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 72 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions src/client/src/commons/form/borehole/boreholeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,16 @@ class BoreholeForm extends React.Component {
size={size}
borehole={borehole}
updateChange={this.updateChange}
updateNumber={this.updateNumber}></BoreholeGeneralSegment>
updateNumber={this.updateNumber}
isEditable={isEditable}></BoreholeGeneralSegment>
<BoreholeDetailSegment
size={size}
borehole={borehole}
updateChange={this.updateChange}
updateNumber={this.updateNumber}
t={t}
debug={this.props.developer.debug}></BoreholeDetailSegment>
debug={this.props.developer.debug}
isEditable={isEditable}></BoreholeDetailSegment>
</div>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Segment>
<Form autoComplete="off" error size={size}>
Expand All @@ -41,6 +37,7 @@ const BoreholeDetailSegment = props => {
: borehole.data.total_depth
}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -53,6 +50,7 @@ const BoreholeDetailSegment = props => {
}}
schema="custom.qt_top_bedrock"
selected={borehole.data.custom.qt_depth}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -78,6 +76,7 @@ const BoreholeDetailSegment = props => {
: borehole.data.total_depth_tvd
}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>

Expand All @@ -91,6 +90,7 @@ const BoreholeDetailSegment = props => {
}}
schema="custom.qt_top_bedrock"
selected={borehole.data.qt_total_depth_tvd}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -116,6 +116,7 @@ const BoreholeDetailSegment = props => {
: borehole.data.extended.top_bedrock
}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -135,6 +136,7 @@ const BoreholeDetailSegment = props => {
spellCheck="false"
value={borehole.data.custom.qt_top_bedrock}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -160,6 +162,7 @@ const BoreholeDetailSegment = props => {
: borehole.data.extended.top_bedrock_tvd
}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>

Expand All @@ -180,6 +183,7 @@ const BoreholeDetailSegment = props => {
spellCheck="false"
value={borehole.data.custom.qt_top_bedrock_tvd}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand Down Expand Up @@ -208,17 +212,17 @@ const BoreholeDetailSegment = props => {
}}>
<FormControlLabel
value="TRUE"
control={<Radio />}
control={<DisabledRadio isEditable={!isEditable} />}
label={<TranslationText id={"yes"} />}
/>
<FormControlLabel
value="FALSE"
control={<Radio />}
control={<DisabledRadio isEditable={!isEditable} />}
label={<TranslationText id={"no"} />}
/>
<FormControlLabel
value="NULL"
control={<Radio />}
control={<DisabledRadio isEditable={!isEditable} />}
label={<TranslationText id={"np"} />}
/>
</RadioGroup>
Expand All @@ -240,6 +244,7 @@ const BoreholeDetailSegment = props => {
schema="custom.lithology_top_bedrock"
selected={borehole.data.custom.lithology_top_bedrock}
title={<TranslationText id="lithology_top_bedrock" />}
isEditable={isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -264,6 +269,7 @@ const BoreholeDetailSegment = props => {
schema="custom.lithostratigraphy_top_bedrock"
selected={borehole.data.custom.lithostratigraphy_top_bedrock}
title={<TranslationText id="lithostratigraphy_top_bedrock" />}
isEditable={isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -289,6 +295,7 @@ const BoreholeDetailSegment = props => {
schema="custom.chronostratigraphy_top_bedrock"
selected={borehole.data.custom.chronostratigraphy_top_bedrock}
title={<TranslationText id="chronostratigraphy_top_bedrock" />}
isEditable={isEditable}
/>
</Form.Field>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Segment>
<div
Expand All @@ -36,6 +36,7 @@ const BoreholeGeneralSegment = props => {
}}
schema="kind"
selected={borehole.data.kind}
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -52,6 +53,7 @@ const BoreholeGeneralSegment = props => {
}}
schema="extended.drilling_method"
selected={borehole.data.extended.drilling_method}
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -64,6 +66,7 @@ const BoreholeGeneralSegment = props => {
}}
schema="extended.purpose"
selected={borehole.data.extended.purpose}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -84,6 +87,7 @@ const BoreholeGeneralSegment = props => {
}}
schema="custom.cuttings"
selected={borehole.data.custom.cuttings}
readOnly={!isEditable}
/>
</Form.Field>
</div>
Expand All @@ -97,6 +101,7 @@ const BoreholeGeneralSegment = props => {
onChange={selected => {
updateChange("spud_date", selected, false);
}}
isEditable={isEditable}
/>
</Form.Field>
</div>
Expand All @@ -116,6 +121,7 @@ const BoreholeGeneralSegment = props => {
onChange={selected => {
updateChange("drilling_date", selected, false);
}}
isEditable={isEditable}
/>
</Form.Field>
</div>
Expand All @@ -138,6 +144,7 @@ const BoreholeGeneralSegment = props => {
? ""
: borehole.data.custom.drill_diameter
}
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -161,6 +168,7 @@ const BoreholeGeneralSegment = props => {
return r;
})()}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -173,6 +181,7 @@ const BoreholeGeneralSegment = props => {
}}
schema="extended.status"
selected={borehole.data.extended.status}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -197,6 +206,7 @@ const BoreholeGeneralSegment = props => {
? ""
: borehole.data.inclination
}
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -219,6 +229,7 @@ const BoreholeGeneralSegment = props => {
? ""
: borehole.data.inclination_direction
}
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -231,6 +242,7 @@ const BoreholeGeneralSegment = props => {
}}
schema="custom.qt_bore_inc_dir"
selected={borehole.data.custom.qt_bore_inc_dir}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -251,6 +263,7 @@ const BoreholeGeneralSegment = props => {
}}
rows={14}
value={borehole.data.custom.remarks}
readOnly={!isEditable}
/>
</Form.Field>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -388,16 +388,7 @@ const CoordinatesSegment = props => {
<FormControlLabel
value={referenceSystems.LV95.code}
sx={{ flexGrow: 1 }}
control={
<Radio
disabled={!isEditable}
sx={{
"&.Mui-disabled input": {
zIndex: -1,
},
}}
/>
}
control={<DisabledRadio isEditable={!isEditable} />}
label={
<DomainText
id={referenceSystems.LV95.code}
Expand All @@ -408,16 +399,7 @@ const CoordinatesSegment = props => {
<FormControlLabel
value={referenceSystems.LV03.code}
sx={{ flexGrow: 1 }}
control={
<Radio
disabled={!isEditable}
sx={{
"&.Mui-disabled input": {
zIndex: -1,
},
}}
/>
}
control={<DisabledRadio isEditable={!isEditable} />}
label={
<DomainText
id={referenceSystems.LV03.code}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import React from "react";
import TranslationText from "../../translationText";
import { Form, Segment } from "semantic-ui-react";
import {
FormControl,
RadioGroup,
FormControlLabel,
Radio,
} from "@mui/material";
import { FormControl, RadioGroup, FormControlLabel } from "@mui/material";
import { DisabledRadio } from "./styledComponents";

import _ from "lodash";
import moment from "moment";
Expand Down Expand Up @@ -88,44 +84,17 @@ const RestrictionSegment = props => {
}}>
<FormControlLabel
value="TRUE"
control={
<Radio
disabled={!isEditable}
sx={{
"&.Mui-disabled input": {
zIndex: -1,
},
}}
/>
}
control={<DisabledRadio isEditable={!isEditable} />}
label={<TranslationText id={"yes"} />}
/>
<FormControlLabel
value="FALSE"
control={
<Radio
disabled={!isEditable}
sx={{
"&.Mui-disabled input": {
zIndex: -1,
},
}}
/>
}
control={<DisabledRadio isEditable={!isEditable} />}
label={<TranslationText id={"no"} />}
/>
<FormControlLabel
value="NULL"
control={
<Radio
disabled={!isEditable}
sx={{
"&.Mui-disabled input": {
zIndex: -1,
},
}}
/>
}
control={<DisabledRadio isEditable={!isEditable} />}
label={<TranslationText id={"np"} />}
/>
</RadioGroup>
Expand Down
Loading

0 comments on commit ad8f4cd

Please sign in to comment.