Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add intended use filter for least list #490

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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