From b0e62e4dc133153a2e978e0f7512214e7d4db0cf Mon Sep 17 00:00:00 2001 From: Kane York Date: Thu, 25 Jun 2015 12:48:37 -0700 Subject: [PATCH 1/2] FEATURE: addPluralization() in the store adapter --- app/assets/javascripts/discourse/models/store.js.es6 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/javascripts/discourse/models/store.js.es6 b/app/assets/javascripts/discourse/models/store.js.es6 index be669b84dab..24dd56577d0 100644 --- a/app/assets/javascripts/discourse/models/store.js.es6 +++ b/app/assets/javascripts/discourse/models/store.js.es6 @@ -37,10 +37,18 @@ function findAndRemoveMap(type, id) { flushMap(); export default Ember.Object.extend({ + plurals: {}, pluralize(thing) { + if (this.get('plurals')[thing]) { + return this.get('plurals')[thing]; + } return thing + "s"; }, + addPluralization(thing, plural) { + this.get('plurals')[thing] = plural; + }, + findAll(type) { const self = this; return this.adapterFor(type).findAll(this, type).then(function(result) { From 20ccbc79c2f67d60185447b932a077a257d6b089 Mon Sep 17 00:00:00 2001 From: Kane York Date: Thu, 25 Jun 2015 12:53:50 -0700 Subject: [PATCH 2/2] Use the underscore-private convention, simplify --- app/assets/javascripts/discourse/models/store.js.es6 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/models/store.js.es6 b/app/assets/javascripts/discourse/models/store.js.es6 index 24dd56577d0..cda112cefb6 100644 --- a/app/assets/javascripts/discourse/models/store.js.es6 +++ b/app/assets/javascripts/discourse/models/store.js.es6 @@ -37,16 +37,13 @@ function findAndRemoveMap(type, id) { flushMap(); export default Ember.Object.extend({ - plurals: {}, + _plurals: {}, pluralize(thing) { - if (this.get('plurals')[thing]) { - return this.get('plurals')[thing]; - } - return thing + "s"; + return this._plurals[thing] || thing + "s"; }, addPluralization(thing, plural) { - this.get('plurals')[thing] = plural; + this._plurals[thing] = plural; }, findAll(type) {