fermeture et acceptation de la suggestion d'email

This commit is contained in:
clemkeirua 2019-12-02 13:07:40 +01:00 committed by Pierre de La Morinerie
parent 3db2d44fc0
commit 0bfdb2d5da
3 changed files with 30 additions and 5 deletions

View file

@ -0,0 +1,20 @@
import { on, show, hide } from '@utils';
const USER_NEW_EMAIL_SELECTOR = '#new_user > #user_email';
const suspectSuggestionsBox = document.querySelector('.suspect-email');
const emailSuggestionSpan = document.querySelector(".suspect-email .question .suggested-email");
on(USER_NEW_EMAIL_SELECTOR, 'blur', _ => {
emailSuggestionSpan.innerHTML = 'bidou@plop.com';
show(suspectSuggestionsBox)
});
export function acceptEmailSuggestion() {
document.querySelector(USER_NEW_EMAIL_SELECTOR).value = emailSuggestionSpan.innerHTML;
hide(suspectSuggestionsBox);
}
export function discardEmailSuggestionBox() {
hide(suspectSuggestionsBox);
}

View file

@ -40,6 +40,7 @@ import {
} from '../new_design/state-button';
import { toggleChart } from '../new_design/toggle-chart';
import { replaceSemicolonByComma } from '../new_design/avis';
import { acceptEmailSuggestion, discardEmailSuggestionBox } from '../new_design/user-sign_up';
// This is the global application namespace where we expose helpers used from rails views
const DS = {
@ -50,7 +51,9 @@ const DS = {
motivationCancel,
showImportJustificatif,
toggleChart,
replaceSemicolonByComma
replaceSemicolonByComma,
acceptEmailSuggestion,
discardEmailSuggestionBox
};
// Start Rails helpers

View file

@ -5,11 +5,13 @@
= form_for resource, url: user_registration_path, html: { class: "form" } do |f|
%h1 Créez-vous un compte demarches-simplifiees.fr
.suspect-email
.question Vouliez-vous dire blabla@gmail.com ?
.suspect-email.hidden
.question Vouliez-vous dire <span class="suggested-email">blabla@gmail.com</span>&nbsp;?
.answer
.button Oui
.button Non
= button_tag type: 'button', class:'button', onclick: "DS.acceptEmailSuggestion()" do
Oui
= button_tag type: 'button', class:'button', onclick: "DS.discardEmailSuggestionBox()" do
Non
= f.label :email, "Email"
= f.text_field :email, autofocus: true, placeholder: "Votre adresse email"