From b6c94a37587c3276d1264a1b45ade35e0271ed80 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 7 Oct 2020 17:42:41 +0200 Subject: [PATCH] Implement ComboCommunesSearch --- .../components/ComboCommunesSearch.js | 24 +++++++++++++++++++ app/javascript/loaders/ComboCommunesSearch.js | 3 +++ .../editable_champs/_communes.html.haml | 7 +++--- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 app/javascript/components/ComboCommunesSearch.js create mode 100644 app/javascript/loaders/ComboCommunesSearch.js diff --git a/app/javascript/components/ComboCommunesSearch.js b/app/javascript/components/ComboCommunesSearch.js new file mode 100644 index 000000000..56d43ffee --- /dev/null +++ b/app/javascript/components/ComboCommunesSearch.js @@ -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 ( + + [ + code, + `${nom} (${codesPostaux[0]})` + ]} + /> + + ); +} + +export default ComboCommunesSearch; diff --git a/app/javascript/loaders/ComboCommunesSearch.js b/app/javascript/loaders/ComboCommunesSearch.js new file mode 100644 index 000000000..7689f27f7 --- /dev/null +++ b/app/javascript/loaders/ComboCommunesSearch.js @@ -0,0 +1,3 @@ +import Loadable from '../components/Loadable'; + +export default Loadable(() => import('../components/ComboCommunesSearch')); diff --git a/app/views/shared/dossiers/editable_champs/_communes.html.haml b/app/views/shared/dossiers/editable_champs/_communes.html.haml index 0087a725e..394aeb460 100644 --- a/app/views/shared/dossiers/editable_champs/_communes.html.haml +++ b/app/views/shared/dossiers/editable_champs/_communes.html.haml @@ -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)