Skip to content

Commit

Permalink
Add site setup custom area size option
Browse files Browse the repository at this point in the history
  • Loading branch information
kazlauskis committed Jan 30, 2025
1 parent 335debd commit b6b460a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Survey/AreaCount/Area/NewLocationModal/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const siteNameAttr = {
container: 'inline',
} as const;

export const OTHER_SITE_SIZE_VALUE = '23733';

export const siteAreaAttr = {
id: 'locAttr:376',
type: 'choice_input',
Expand All @@ -15,7 +17,7 @@ export const siteAreaAttr = {
{ title: '20 x 25 m', data_name: '23730' },
{ title: '10 x 50 m', data_name: '23731' },
{ title: '5 x 100 m', data_name: '23732' },
{ title: 'other', data_name: '23733' },
{ title: 'other', data_name: OTHER_SITE_SIZE_VALUE },
],
} as const;

Expand Down Expand Up @@ -59,6 +61,16 @@ export const grainsNumberAttr = {
validations: { min: 0, max: 100 },
} as const;

export const customAreaSizeAttr = {
id: 'locAttr:159',
type: 'number_input',
title: 'Area size',
appearance: 'counter',
placeholder: '0',
suffix: 'm²',
validations: { min: 0 },
} as const;

export const vegetablesNumberAttr = {
id: 'locAttr:342',
type: 'number_input',
Expand Down
8 changes: 8 additions & 0 deletions src/Survey/AreaCount/Area/NewLocationModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ import Media from 'common/models/media';
import { Group } from 'common/models/sample';
import HeaderButton from 'Survey/common/HeaderButton';
import {
OTHER_SITE_SIZE_VALUE,
buildingsNumberAttr,
commentAttr,
cornNumberAttr,
croppingNumberAttr,
customAreaSizeAttr,
fallowNumberAttr,
fertilizedAttr,
forestNumberAttr,
Expand Down Expand Up @@ -195,6 +197,9 @@ const NewLocationModal = (
},
});

const isOtherSiteSize =
(newLocation as any)[siteAreaAttr.id] === OTHER_SITE_SIZE_VALUE;

return (
<>
<IonModal
Expand Down Expand Up @@ -238,6 +243,9 @@ const NewLocationModal = (
isUNPplus) && (
<>
<Block {...getBlockAttrs(siteAreaAttr)} />
{isOtherSiteSize && (
<Block {...getBlockAttrs(customAreaSizeAttr)} />
)}
<InfoMessage inline>
Approximate size of your observation site.
</InfoMessage>
Expand Down

0 comments on commit b6b460a

Please sign in to comment.