From 90c0198a57939777591dda7255de5773f543fd25 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 27 Mar 2018 17:26:53 -0400 Subject: [PATCH] FIX: watched word counts always show as 0 --- .../controllers/admin-watched-words-action.js.es6 | 14 ++++++++++---- .../admin/templates/watched-words-action.hbs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin-watched-words-action.js.es6 b/app/assets/javascripts/admin/controllers/admin-watched-words-action.js.es6 index bd11f15fcff..9e899c4296d 100644 --- a/app/assets/javascripts/admin/controllers/admin-watched-words-action.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-watched-words-action.js.es6 @@ -10,11 +10,11 @@ export default Ember.Controller.extend({ return (this.get('adminWatchedWords.model') || []).findBy('nameKey', actionName); }, - @computed('adminWatchedWords.model', 'actionNameKey') - filteredContent() { - if (!this.get('actionNameKey')) { return []; } + @computed('actionNameKey', 'adminWatchedWords.model') + filteredContent(actionNameKey) { + if (!actionNameKey) { return []; } - const a = this.findAction(this.get('actionNameKey')); + const a = this.findAction(actionNameKey); return a ? a.words : []; }, @@ -23,6 +23,12 @@ export default Ember.Controller.extend({ return I18n.t('admin.watched_words.action_descriptions.' + actionNameKey); }, + @computed('actionNameKey', 'adminWatchedWords.model') + wordCount(actionNameKey) { + const a = this.findAction(actionNameKey); + return a ? a.words.length : 0; + }, + actions: { recordAdded(arg) { const a = this.findAction(this.get('actionNameKey')); diff --git a/app/assets/javascripts/admin/templates/watched-words-action.hbs b/app/assets/javascripts/admin/templates/watched-words-action.hbs index d58f1a9430e..ac0bc4175b5 100644 --- a/app/assets/javascripts/admin/templates/watched-words-action.hbs +++ b/app/assets/javascripts/admin/templates/watched-words-action.hbs @@ -22,6 +22,6 @@
{{admin-watched-word word=word action="recordRemoved"}}
{{/each}} {{else}} - {{i18n 'admin.watched_words.word_count' count=model.words.length}} + {{i18n 'admin.watched_words.word_count' count=wordCount}} {{/if}}