FIX: watched word counts always show as 0

This commit is contained in:
Neil Lalonde 2018-03-27 17:26:53 -04:00
parent ddefc29c4e
commit 90c0198a57
2 changed files with 11 additions and 5 deletions

View File

@ -10,11 +10,11 @@ export default Ember.Controller.extend({
return (this.get('adminWatchedWords.model') || []).findBy('nameKey', actionName); return (this.get('adminWatchedWords.model') || []).findBy('nameKey', actionName);
}, },
@computed('adminWatchedWords.model', 'actionNameKey') @computed('actionNameKey', 'adminWatchedWords.model')
filteredContent() { filteredContent(actionNameKey) {
if (!this.get('actionNameKey')) { return []; } if (!actionNameKey) { return []; }
const a = this.findAction(this.get('actionNameKey')); const a = this.findAction(actionNameKey);
return a ? a.words : []; return a ? a.words : [];
}, },
@ -23,6 +23,12 @@ export default Ember.Controller.extend({
return I18n.t('admin.watched_words.action_descriptions.' + actionNameKey); 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: { actions: {
recordAdded(arg) { recordAdded(arg) {
const a = this.findAction(this.get('actionNameKey')); const a = this.findAction(this.get('actionNameKey'));

View File

@ -22,6 +22,6 @@
<div class="watched-word-box">{{admin-watched-word word=word action="recordRemoved"}}</div> <div class="watched-word-box">{{admin-watched-word word=word action="recordRemoved"}}</div>
{{/each}} {{/each}}
{{else}} {{else}}
{{i18n 'admin.watched_words.word_count' count=model.words.length}} {{i18n 'admin.watched_words.word_count' count=wordCount}}
{{/if}} {{/if}}
</div> </div>