Skip to content

Commit

Permalink
add intended use filter for least list (#490)
Browse files Browse the repository at this point in the history
utilizes choices loaded from metadata with OPTIONS lease/
  • Loading branch information
henrinie-nc committed Jun 14, 2024
1 parent b96077c commit 0edbdd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/components/form/FormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const FormFieldInput = ({
case FieldTypeOptions.STRING:
case FieldTypeOptions.HIDDEN:
case FieldTypeOptions.FRACTIONAL:
case FieldTypeOptions.INTENDED_USE:
return value;

case FieldTypeOptions.REFERENCE_NUMBER:
Expand All @@ -189,9 +190,6 @@ const FormFieldInput = ({
case FieldTypeOptions.USER:
return getUserFullName(value);

case FieldTypeOptions.INTENDED_USE:
return value ? value.label : '-';

default:
console.error(`Field type ${type} is not implemented`);
return 'NOT IMPLEMENTED';
Expand Down
20 changes: 20 additions & 0 deletions src/leases/components/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Props = {
};
type State = {
decisionMakerOptions: Array<Record<string, any>>;
intendedUseOptions: Array<Record<string, any>>;
isBasicSearch: boolean;
leaseAttributes: Attributes;
lessors: LessorList;
Expand All @@ -61,6 +62,7 @@ class Search extends PureComponent<Props, State> {
_isMounted: boolean;
state = {
decisionMakerOptions: [],
intendedUseOptions: [],
isBasicSearch: true,
leaseAttributes: null,
lessors: [],
Expand Down Expand Up @@ -96,6 +98,7 @@ class Search extends PureComponent<Props, State> {
if (props.leaseAttributes !== state.leaseAttributes) {
newState.leaseAttributes = props.leaseAttributes;
newState.decisionMakerOptions = getFieldOptions(props.leaseAttributes, LeaseDecisionsFieldPaths.DECISION_MAKER);
newState.intendedUseOptions = getFieldOptions(props.leaseAttributes, LeaseFieldPaths.INTENDED_USE);
newState.municipalityOptions = getFieldOptions(props.leaseAttributes, LeaseFieldPaths.MUNICIPALITY);
newState.tenantTypeOptions = getFieldOptions(props.leaseAttributes, LeaseTenantContactSetFieldPaths.TYPE, false);
newState.typeOptions = getFieldOptions(props.leaseAttributes, LeaseFieldPaths.TYPE);
Expand Down Expand Up @@ -161,6 +164,7 @@ class Search extends PureComponent<Props, State> {
delete searchQuery.in_bbox;
delete searchQuery.visualization;
delete searchQuery.zoom;
delete searchQuery.intended_use;
delete searchQuery.service_unit;
const keys = Object.keys(searchQuery);

Expand Down Expand Up @@ -215,6 +219,7 @@ class Search extends PureComponent<Props, State> {
} = this.props;
const {
decisionMakerOptions,
intendedUseOptions,
isBasicSearch,
lessorOptions,
municipalityOptions,
Expand Down Expand Up @@ -589,6 +594,21 @@ class Search extends PureComponent<Props, State> {
}} invisibleLabel name='invoice_number' />
</SearchInputColumn>
</SearchRow>

<SearchRow>
<SearchLabelColumn>
<SearchLabel>Vuokrauksen käyttötarkoitus</SearchLabel>
</SearchLabelColumn>
<SearchInputColumn>
<FormField autoBlur disableDirty fieldAttributes={{
label: 'Vuokrauksen käyttötarkoitus',
type: FieldTypes.CHOICE,
read_only: false
}} invisibleLabel name='intended_use' overrideValues={{
options: intendedUseOptions
}} />
</SearchInputColumn>
</SearchRow>
</Column>
</Row>
</Fragment>}
Expand Down

0 comments on commit 0edbdd8

Please sign in to comment.