From 34126eb9e0c84fa058e616464c1702fa53e6d99c Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Mon, 19 Jun 2017 22:20:09 +0530 Subject: [PATCH] optimize 'hide help button' code --- .../discourse/controllers/forgot-password.js.es6 | 4 ++-- .../javascripts/discourse/routes/application.js.es6 | 2 +- .../discourse/templates/modal/forgot-password.hbs | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 b/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 index 5f8d7de2758..4311368186c 100644 --- a/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 +++ b/app/assets/javascripts/discourse/controllers/forgot-password.js.es6 @@ -6,6 +6,7 @@ import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend(ModalFunctionality, { offerHelp: null, + helpSeen: false, @computed('accountEmailOrUsername', 'disabled') submitDisabled(accountEmailOrUsername, disabled) { @@ -59,8 +60,7 @@ export default Ember.Controller.extend(ModalFunctionality, { }, help() { - this.set('offerHelp', I18n.t('forgot_password.help')); - $('.forgot-password-help-btn').hide(); + this.setProperties({ offerHelp: I18n.t('forgot_password.help'), helpSeen: true }); } } diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 7ac6c37a344..60e895a81b3 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -94,7 +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); + this.controllerFor('forgot-password').setProperties({ offerHelp: null, helpSeen: false }); 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 9039f1d25fe..c739f771979 100644 --- a/app/assets/javascripts/discourse/templates/modal/forgot-password.hbs +++ b/app/assets/javascripts/discourse/templates/modal/forgot-password.hbs @@ -17,9 +17,11 @@ {{d-button class="btn-large btn-primary" label="forgot_password.button_ok" action="ok"}} - {{d-button class="btn-large forgot-password-help-btn" - label="forgot_password.button_help" - action="help"}} + {{#unless helpSeen}} + {{d-button class="btn-large" + label="forgot_password.button_help" + action="help"}} + {{/unless}} {{/unless}}