From 9e858ae5ad644d4c00a350c18754e0f9b369d857 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 27 Jan 2020 12:42:04 +0100 Subject: [PATCH 1/2] possibilite de selectionner un resultat quand il n'y a rien dans le champ adresse --- app/javascript/new_design/select2.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/javascript/new_design/select2.js b/app/javascript/new_design/select2.js index 7a82b9115..8db01fe6f 100644 --- a/app/javascript/new_design/select2.js +++ b/app/javascript/new_design/select2.js @@ -122,12 +122,14 @@ const adresseOptions = { }; }, processResults(data) { + let r = data.features.map(({ properties: { label }, geometry }) => ({ + id: label, + text: label, + geometry + })); + r.unshift({ id: data.query, text: data.query }); return { - results: data.features.map(({ properties: { label }, geometry }) => ({ - id: label, - text: label, - geometry - })) + results: r }; } } From 455f164d0250e9c15d1b700ef719996d23e9bee9 Mon Sep 17 00:00:00 2001 From: Keirua Date: Mon, 27 Jan 2020 16:47:32 +0100 Subject: [PATCH 2/2] Detail the reason why we include the search term in the results Co-Authored-By: Pierre de La Morinerie --- app/javascript/new_design/select2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/javascript/new_design/select2.js b/app/javascript/new_design/select2.js index 8db01fe6f..ca55d1dd9 100644 --- a/app/javascript/new_design/select2.js +++ b/app/javascript/new_design/select2.js @@ -127,6 +127,8 @@ const adresseOptions = { text: label, geometry })); + // Allow the user to select an arbitrary address missing from the results, + // by adding the plain-text query to the list of results. r.unshift({ id: data.query, text: data.query }); return { results: r