From 0a2f615aab78bac663db114c2f491ea1351f0ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 14 Aug 2015 17:44:33 +0200 Subject: [PATCH] FIX: pin a topic globally wasn't working --- .../controllers/feature-topic.js.es6 | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 b/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 index 03bcebfcad4..1cadd78ca49 100644 --- a/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/feature-topic.js.es6 @@ -1,5 +1,6 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; import { categoryLinkHTML } from 'discourse/helpers/category-link'; +import computed from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend(ModalFunctionality, { needs: ["topic"], @@ -9,7 +10,7 @@ export default Ember.Controller.extend(ModalFunctionality, { pinnedGloballyCount: 0, bannerCount: 0, - reset: function() { + reset() { this.set("model.pinnedInCategoryUntil", null); this.set("model.pinnedGloballyUntil", null); }, @@ -27,21 +28,24 @@ export default Ember.Controller.extend(ModalFunctionality, { return I18n.t(name, { categoryLink: this.get("categoryLink"), until: until }); }.property("categoryLink", "model.{pinned_globally,pinned_until}"), - pinMessage: function() { - return I18n.t("topic.feature_topic.pin", { categoryLink: this.get("categoryLink") }); - }.property("categoryLink"), + @computed("categoryLink") + pinMessage(categoryLink) { + return I18n.t("topic.feature_topic.pin", { categoryLink }); + }, alreadyPinnedMessage: function() { return I18n.t("topic.feature_topic.already_pinned", { categoryLink: this.get("categoryLink"), count: this.get("pinnedInCategoryCount") }); }.property("categoryLink", "pinnedInCategoryCount"), - pinDisabled: function() { - return !this._isDateValid(this.get("parsedPinnedInCategoryUntil")); - }.property("parsedPinnedInCategoryUntil"), + @computed("parsedPinnedInCategoryUntil") + pinDisabled(parsedPinnedInCategoryUntil) { + return !this._isDateValid(parsedPinnedInCategoryUntil); + }, - pinGloballyDisabled: function() { - return !this._isDateValid(this.get("parsedPinnedGloballyUntil")); - }.property("pinnedGloballyUntil"), + @computed("parsedPinnedGloballyUntil") + pinGloballyDisabled(parsedPinnedGloballyUntil) { + return !this._isDateValid(parsedPinnedGloballyUntil); + }, parsedPinnedInCategoryUntil: function() { return this._parseDate(this.get("model.pinnedInCategoryUntil"));