From c14f9900d669c5ae5ebc2eec28a694fcf0f93b6f Mon Sep 17 00:00:00 2001 From: pedong Date: Thu, 29 Nov 2018 17:03:32 +0100 Subject: [PATCH] [fix #2969] use JS replace semicolon by comma in the list email --- app/javascript/new_design/avis.js | 4 ++++ app/javascript/packs/application.js | 4 +++- app/views/new_gestionnaire/shared/avis/_form.html.haml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/javascript/new_design/avis.js b/app/javascript/new_design/avis.js index 99b4f869c..1d84d4d67 100644 --- a/app/javascript/new_design/avis.js +++ b/app/javascript/new_design/avis.js @@ -3,3 +3,7 @@ import { toggle } from '@utils'; export function toggleCondidentielExplanation() { toggle(document.querySelector('.confidentiel-explanation')); } + +export function replaceSemicolonByComma(event) { + event.target.value = event.target.value.replace(/;/g, ','); +} diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index a8ec784e8..206b4526f 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -25,6 +25,7 @@ import { toggleCondidentielExplanation } from '../new_design/avis'; import { scrollMessagerie } from '../new_design/messagerie'; import { showMotivation, motivationCancel } from '../new_design/state-button'; import { toggleChart } from '../new_design/toggle-chart'; +import { replaceSemicolonByComma } from '../new_design/avis'; // This is the global application namespace where we expose helpers used from rails views const DS = { @@ -32,7 +33,8 @@ const DS = { scrollMessagerie, showMotivation, motivationCancel, - toggleChart + toggleChart, + replaceSemicolonByComma }; // Start Rails helpers diff --git a/app/views/new_gestionnaire/shared/avis/_form.html.haml b/app/views/new_gestionnaire/shared/avis/_form.html.haml index 609d871e3..15f317f8f 100644 --- a/app/views/new_gestionnaire/shared/avis/_form.html.haml +++ b/app/views/new_gestionnaire/shared/avis/_form.html.haml @@ -3,7 +3,7 @@ %p.avis-notice Les invités pourront consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais ils ne pourront pas le modifier. = form_for avis, url: url, html: { class: 'form' } do |f| - = f.email_field :emails, placeholder: 'Adresses email, séparées par des virgules', required: true, multiple: true + = f.email_field :emails, placeholder: 'Adresses email, séparées par des virgules', required: true, multiple: true, onchange: "javascript:DS.replaceSemicolonByComma(event);" = f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true .flex.justify-between.align-baseline - if must_be_confidentiel