From e17bd6174c3497ccb349d1a697fb013156f10213 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 28 Dec 2016 11:45:41 +0100 Subject: [PATCH] Extract helper i18n-yes-no. --- .../admin/templates/user-index.hbs | 48 +++---------------- .../discourse-common/helpers/i18n.js.es6 | 1 + 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/app/assets/javascripts/admin/templates/user-index.hbs b/app/assets/javascripts/admin/templates/user-index.hbs index 53dc3a8d999..9cc35a3dce3 100644 --- a/app/assets/javascripts/admin/templates/user-index.hbs +++ b/app/assets/javascripts/admin/templates/user-index.hbs @@ -175,13 +175,7 @@
{{i18n 'admin.users.active'}}
-
- {{#if model.active}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.active}}
{{#if model.active}} {{#if model.can_deactivate}} @@ -221,13 +215,7 @@
{{i18n 'admin.user.admin'}}
-
- {{#if model.admin}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.admin}}
{{#if model.can_revoke_admin}} {{d-button action="revokeAdmin" icon="shield" label="admin.user.revoke_admin"}} @@ -240,13 +228,7 @@
{{i18n 'admin.user.moderator'}}
-
- {{#if model.moderator}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.moderator}}
{{#if model.can_revoke_moderation}} {{d-button action="revokeModeration" icon="shield" label="admin.user.revoke_moderation"}} @@ -284,13 +266,7 @@
{{i18n 'admin.user.suspended'}}
-
- {{#if model.isSuspended}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.isSuspended}}
{{#if model.isSuspended}} {{d-button class="btn-danger" action="unsuspend" icon="ban" label="admin.user.unsuspend"}} @@ -321,13 +297,7 @@
{{i18n 'admin.user.blocked'}}
-
- {{#if model.blocked}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.blocked}}
{{#conditional-loading-spinner size="small" condition=model.blockingUser}} {{#if model.blocked}} @@ -343,13 +313,7 @@
{{i18n 'admin.user.staged'}}
-
- {{#if model.staged}} - {{i18n 'yes_value'}} - {{else}} - {{i18n 'no_value'}} - {{/if}} -
+
{{i18n-yes-no model.staged}}
{{i18n 'admin.user.staged_explanation'}}
diff --git a/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 b/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 index 455cc65a355..40fd2893d52 100644 --- a/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 +++ b/app/assets/javascripts/discourse-common/helpers/i18n.js.es6 @@ -1,3 +1,4 @@ import { registerUnbound } from 'discourse-common/lib/helpers'; registerUnbound('i18n', (key, params) => I18n.t(key, params)); +registerUnbound('i18n-yes-no', (value, params) => I18n.t(value ? 'yes_value' : 'no_value', params));