From 74e6717b40fda1cb6cb69b6cc035c8212a84ae04 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Mon, 19 Jun 2017 13:55:28 +0530 Subject: [PATCH] FEATURE: offer help on forgot password modal --- .../controllers/forgot-password.js.es6 | 12 ++++++++-- .../discourse/routes/application.js.es6 | 1 + .../templates/modal/forgot-password.hbs | 22 ++++++++++++++++--- config/locales/client.en.yml | 3 +++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 b/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 index fb159186400..13fb76d7946 100644 --- a/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 +++ b/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 @@ -5,6 +5,7 @@ import { extractError } from 'discourse/lib/ajax-error'; import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend(ModalFunctionality, { + offerHelp: null, @computed('accountEmailOrUsername', 'disabled') submitDisabled(accountEmailOrUsername, disabled) { @@ -35,8 +36,7 @@ export default Ember.Controller.extend(ModalFunctionality, { if (data.user_found === true) { key += '_found'; this.set('accountEmailOrUsername', ''); - bootbox.alert(I18n.t(key, {email: escaped, username: escaped})); - this.send("closeModal"); + this.set('offerHelp', I18n.t(key, {email: escaped, username: escaped})); } else { if (data.user_found === false) { key += '_not_found'; @@ -52,6 +52,14 @@ export default Ember.Controller.extend(ModalFunctionality, { }); return false; + }, + + ok() { + this.send('closeModal'); + }, + + help() { + this.set('offerHelp', I18n.t('forgot_password.help')); } } diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 2c800ff1998..7ac6c37a344 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -94,6 +94,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, { showCreateAccount: unlessReadOnly('handleShowCreateAccount', I18n.t("read_only_mode.login_disabled")), showForgotPassword() { + this.controllerFor('forgot-password').set('offerHelp', null); showModal('forgotPassword', { title: 'forgot_password.title' }); }, diff --git a/app/assets/javascripts/discourse/templates/modal/forgot-password.hbs b/app/assets/javascripts/discourse/templates/modal/forgot-password.hbs index 8a8db45cce2..6210b63b0e3 100644 --- a/app/assets/javascripts/discourse/templates/modal/forgot-password.hbs +++ b/app/assets/javascripts/discourse/templates/modal/forgot-password.hbs @@ -1,9 +1,25 @@
{{#d-modal-body}} - - {{text-field value=accountEmailOrUsername placeholderKey="login.email_placeholder" id="username-or-email" autocorrect="off" autocapitalize="off"}} + {{#unless offerHelp}} + + {{text-field value=accountEmailOrUsername placeholderKey="login.email_placeholder" id="username-or-email" autocorrect="off" autocapitalize="off"}} + {{else}} + {{{offerHelp}}} + {{/unless}} {{/d-modal-body}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 5163d91ef42..83368513068 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1036,6 +1036,9 @@ en: complete_username_not_found: "No account matches the username %{username}" complete_email_not_found: "No account matches %{email}" + help: "Please contact site administrator." + button_ok: "OK" + button_help: "Help" login: title: "Log In" username: "User"