Skip to content

Commit

Permalink
Edit coordinates with wrong status (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehats authored Dec 11, 2023
2 parents 9f5b99c + 5e225f7 commit 5bbd263
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Use numeric input instead of dropdown for top bedrock quality fields.
- Proxy requests to legacy api through .NET API with authentication.
- Disable spatial reference inputs when editing mode is not active or borehole status does not allow editing.

## v2.0.476 - 2023-12-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ const CoordinatesSegment = props => {
<FormControlLabel
value={referenceSystems.LV95.code}
sx={{ flexGrow: 1 }}
control={<Radio />}
control={<Radio disabled={!isEditable} />}
label={
<DomainText
id={referenceSystems.LV95.code}
Expand All @@ -399,7 +399,7 @@ const CoordinatesSegment = props => {
<FormControlLabel
value={referenceSystems.LV03.code}
sx={{ flexGrow: 1 }}
control={<Radio />}
control={<Radio disabled={!isEditable} />}
label={
<DomainText
id={referenceSystems.LV03.code}
Expand Down Expand Up @@ -444,7 +444,7 @@ const CoordinatesSegment = props => {
autoCapitalize="off"
autoComplete="off"
autoCorrect="off"
readOnly={!isLV95}
readOnly={!isLV95 || !isEditable}
onChange={e => {
changeCoordinate("LV95", "X", e.target.value);
}}
Expand Down Expand Up @@ -479,7 +479,7 @@ const CoordinatesSegment = props => {
autoCapitalize="off"
autoComplete="off"
autoCorrect="off"
readOnly={!isLV95}
readOnly={!isLV95 || !isEditable}
onChange={e => {
changeCoordinate("LV95", "Y", e.target.value);
}}
Expand Down Expand Up @@ -516,7 +516,7 @@ const CoordinatesSegment = props => {
autoCapitalize="off"
autoComplete="off"
autoCorrect="off"
readOnly={isLV95}
readOnly={isLV95 || !isEditable}
onChange={e => {
changeCoordinate("LV03", "X", e.target.value);
}}
Expand Down Expand Up @@ -551,7 +551,7 @@ const CoordinatesSegment = props => {
autoCapitalize="off"
autoComplete="off"
autoCorrect="off"
readOnly={isLV95}
readOnly={isLV95 || !isEditable}
onChange={e => {
changeCoordinate("LV03", "Y", e.target.value);
}}
Expand All @@ -576,6 +576,7 @@ const CoordinatesSegment = props => {
}}
schema="qt_location"
selected={borehole.data.qt_location}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -597,6 +598,7 @@ const CoordinatesSegment = props => {
spellCheck="false"
value={borehole.data.elevation_z ?? ""}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>

Expand All @@ -610,6 +612,7 @@ const CoordinatesSegment = props => {
}}
schema="qt_elevation"
selected={borehole.data.qt_elevation}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand Down Expand Up @@ -640,6 +643,7 @@ const CoordinatesSegment = props => {
spellCheck="false"
value={borehole.data.reference_elevation ?? ""}
thousandSeparator="'"
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand All @@ -652,6 +656,7 @@ const CoordinatesSegment = props => {
}}
schema="qt_elevation"
selected={borehole.data.qt_reference_elevation}
readOnly={!isEditable}
/>
</Form.Field>
</Form.Group>
Expand All @@ -668,6 +673,7 @@ const CoordinatesSegment = props => {
}}
schema="ibor117"
selected={borehole.data.reference_elevation_type}
readOnly={!isEditable}
/>
</Form.Field>
<Form.Field required>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class DomainDropdown extends React.Component {
}

render() {
const { domains, schema, search, multiple, additionalValues } = this.props,
const { domains, schema, search, multiple, additionalValues, readOnly } =
this.props,
{ selected } = this.state;
if (!domains.data.hasOwnProperty(schema)) {
if (domains.isFetching === true) {
Expand Down Expand Up @@ -222,6 +223,10 @@ class DomainDropdown extends React.Component {
),
})),
);
if (readOnly) {
let selectedOption = options.find(option => option.value === selected);
return <Form.Input fluid readOnly value={selectedOption.text} />;
}
return (
<Form.Select
data-cy="domain-dropdown"
Expand Down Expand Up @@ -252,6 +257,7 @@ DomainDropdown.propTypes = {
PropTypes.number,
PropTypes.arrayOf(PropTypes.number),
]),
readOnly: PropTypes.bool,
};

DomainDropdown.defaultProps = {
Expand Down

0 comments on commit 5bbd263

Please sign in to comment.