Implement ComboCommunesSearch
This commit is contained in:
parent
4217dcd94b
commit
b6c94a3758
3 changed files with 30 additions and 4 deletions
24
app/javascript/components/ComboCommunesSearch.js
Normal file
24
app/javascript/components/ComboCommunesSearch.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import React from 'react';
|
||||
import { ReactQueryCacheProvider } from 'react-query';
|
||||
|
||||
import ComboSearch from './ComboSearch';
|
||||
import { queryCache } from './shared/queryCache';
|
||||
|
||||
function ComboCommunesSearch(params) {
|
||||
return (
|
||||
<ReactQueryCacheProvider queryCache={queryCache}>
|
||||
<ComboSearch
|
||||
required={params.mandatory}
|
||||
hiddenFieldId={params.hiddenFieldId}
|
||||
scope="communes"
|
||||
minimumInputLength={2}
|
||||
transformResult={({ code, nom, codesPostaux }) => [
|
||||
code,
|
||||
`${nom} (${codesPostaux[0]})`
|
||||
]}
|
||||
/>
|
||||
</ReactQueryCacheProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default ComboCommunesSearch;
|
3
app/javascript/loaders/ComboCommunesSearch.js
Normal file
3
app/javascript/loaders/ComboCommunesSearch.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Loadable from '../components/Loadable';
|
||||
|
||||
export default Loadable(() => import('../components/ComboCommunesSearch'));
|
|
@ -1,4 +1,3 @@
|
|||
= form.select :value, [champ.value].compact,
|
||||
{ include_blank: true },
|
||||
required: champ.mandatory?,
|
||||
class: 'select2 communes'
|
||||
- hidden_field_id = SecureRandom.uuid
|
||||
= form.hidden_field :value, { data: { uuid: hidden_field_id } }
|
||||
= react_component("ComboCommunesSearch", mandatory: champ.mandatory?, hiddenFieldId: hidden_field_id)
|
||||
|
|
Loading…
Reference in a new issue