From 2c7ee82d316be80f0c9bfacaeed59d6f317345fe Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 7 Oct 2020 17:41:51 +0200 Subject: [PATCH] Implement ComboRegionsSearch --- .../components/ComboRegionsSearch.js | 21 +++++++++++++++++++ app/javascript/loaders/ComboRegionsSearch.js | 3 +++ .../editable_champs/_regions.html.haml | 7 +++---- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 app/javascript/components/ComboRegionsSearch.js create mode 100644 app/javascript/loaders/ComboRegionsSearch.js diff --git a/app/javascript/components/ComboRegionsSearch.js b/app/javascript/components/ComboRegionsSearch.js new file mode 100644 index 000000000..630ed5742 --- /dev/null +++ b/app/javascript/components/ComboRegionsSearch.js @@ -0,0 +1,21 @@ +import React from 'react'; +import { ReactQueryCacheProvider } from 'react-query'; + +import ComboSearch from './ComboSearch'; +import { queryCache } from './shared/queryCache'; + +function ComboRegionsSearch(params) { + return ( + + [code, nom]} + /> + + ); +} + +export default ComboRegionsSearch; diff --git a/app/javascript/loaders/ComboRegionsSearch.js b/app/javascript/loaders/ComboRegionsSearch.js new file mode 100644 index 000000000..4b281012d --- /dev/null +++ b/app/javascript/loaders/ComboRegionsSearch.js @@ -0,0 +1,3 @@ +import Loadable from '../components/Loadable'; + +export default Loadable(() => import('../components/ComboRegionsSearch')); diff --git a/app/views/shared/dossiers/editable_champs/_regions.html.haml b/app/views/shared/dossiers/editable_champs/_regions.html.haml index 4b16bea2d..6119f7a4e 100644 --- a/app/views/shared/dossiers/editable_champs/_regions.html.haml +++ b/app/views/shared/dossiers/editable_champs/_regions.html.haml @@ -1,4 +1,3 @@ -= form.select :value, [champ.value].compact, - { include_blank: true }, - required: champ.mandatory?, - class: 'select2 regions' +- hidden_field_id = SecureRandom.uuid += form.hidden_field :value, { data: { uuid: hidden_field_id } } += react_component("ComboRegionsSearch", mandatory: champ.mandatory?, hiddenFieldId: hidden_field_id)