Skip to content

Commit

Permalink
georchestra#123 Always show owner selection when ambiguous
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz committed Jun 4, 2021
1 parent 1b96c43 commit 8bd8583
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 1 addition & 7 deletions js/extension/components/search/OwnersSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ export default function OwnersSearch({ loading, onSearch = () => { }, onOwnersSe
valid={isSearchValid(currentTab, searchState[currentTab])}
onClear={() => resetFormState(currentTab)}
onSearch={() => {
// text search opens the owners tab
if (currentTab === SEARCH_TYPES.USER && isString(searchState[SEARCH_TYPES.USER]?.proprietaire)) {
onOwnersSearch(SEARCH_TYPES.USER, searchState[currentTab]);
} else {
// plot search
onSearch(currentTab, searchState[currentTab]);
}
onOwnersSearch(SEARCH_TYPES.USER, searchState[currentTab]);
}} />
</div>
);
Expand Down
9 changes: 5 additions & 4 deletions js/extension/epics/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Rx from 'rxjs';
import uuid from 'uuid';
import {head, trim} from 'lodash';
import {head, trim, isString} from 'lodash';
import { SEARCH_TYPES } from '../constants';
import { getCadastrappLayer, cadastreLayerIdParcelle } from '../selectors/cadastrapp';
import { getLayerJSONFeature } from '@mapstore/observables/wfs';
Expand All @@ -10,7 +10,7 @@ import { error } from '@mapstore/actions/notifications';
import { getCoProprietaireList, getParcelle, getParcelleByCompteCommunal, getProprietaire } from '../api/api';

import { workaroundDuplicatedParcelle } from '../utils/workarounds';
import { SEARCH, addPlots, OWNERS_SEARCH, showOwners, loading } from '../actions/cadastrapp';
import { SEARCH, addPlots, OWNERS_SEARCH, showOwners, loading, search } from '../actions/cadastrapp';
import { isValidParcelle } from '../utils/validation';

const DELIMITER_REGEX = /[\s\;\,\n]/;
Expand Down Expand Up @@ -202,11 +202,12 @@ export function cadastrappOwnersSearch(action$) {
const { commune, proprietaire, birthsearch, comptecommunal } = rawParams; // proprietaire in this case is a string
// ddenom birthsearch=true
const { cgocommune } = commune;
const ddenom = isString(proprietaire) ? proprietaire : proprietaire?.value;
return Rx.Observable.defer(() => searchType === SEARCH_TYPES.USER
? getProprietaire({ ddenom: proprietaire, birthsearch, cgocommune, details: 2 })
? getProprietaire({ ddenom, birthsearch, cgocommune, details: 2 })
: getCoProprietaireList({ ddenom: proprietaire, cgocommune, comptecommunal, details: 1})
)
.switchMap( owners => Rx.Observable.of(showOwners(owners)))
.switchMap( owners => Rx.Observable.of(owners.length > 1 ? showOwners(owners) : search(searchType, rawParams)))
.let(wrapStartStop(loading(true, 'search'), loading(false, 'search')));
});
}

0 comments on commit 8bd8583

Please sign in to comment.