diff --git a/assets/javascripts/discourse-assign/connectors/topic-footer-main-buttons-before-create/assign-button.js.es6 b/assets/javascripts/discourse-assign/connectors/topic-footer-main-buttons-before-create/assign-button.js.es6 index e14a552..82366b9 100644 --- a/assets/javascripts/discourse-assign/connectors/topic-footer-main-buttons-before-create/assign-button.js.es6 +++ b/assets/javascripts/discourse-assign/connectors/topic-footer-main-buttons-before-create/assign-button.js.es6 @@ -18,10 +18,10 @@ export default { actions: { unassign() { this.set("topic.assigned_to_user", null); - this.get("taskActions").unassign(this.get("topic.id")); + this.taskActions.unassign(this.get("topic.id")); }, assign() { - this.get("taskActions").assign(this.topic); + this.taskActions.assign(this.topic); } } }; diff --git a/assets/javascripts/discourse-assign/controllers/assign-user.js.es6 b/assets/javascripts/discourse-assign/controllers/assign-user.js.es6 index 13692df..4a4cb35 100644 --- a/assets/javascripts/discourse-assign/controllers/assign-user.js.es6 +++ b/assets/javascripts/discourse-assign/controllers/assign-user.js.es6 @@ -1,19 +1,17 @@ -//import { default as computed } from 'ember-addons/ember-computed-decorators'; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; export default Ember.Controller.extend({ + assignSuggestions: null, taskActions: Ember.inject.service(), - assignSuggestions: function() { - ajax("/assign/suggestions").then(users => { - this.set("assignSuggestions", users); - }); - }.property(), - // @computed("username") - // disabled(username) { - // return Ember.isEmpty(username); - // }, + init() { + this._super(...arguments); + + ajax("/assign/suggestions").then(users => + this.set("assignSuggestions", users) + ); + }, onClose() { if (this.get("model.onClose") && this.get("model.username")) { @@ -23,8 +21,10 @@ export default Ember.Controller.extend({ actions: { assignUser(user) { - this.set("model.username", user.username); - this.set("model.allowedGroups", this.get("taskActions").allowedGroups); + this.setProperties({ + "model.username": user.username, + "model.allowedGroups": this.taskActions.allowedGroups + }); this.send("assign"); }, diff --git a/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 b/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 index 6b65eed..7ca8c5f 100644 --- a/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 +++ b/assets/javascripts/discourse-assign/controllers/user-activity-assigned.js.es6 @@ -6,12 +6,12 @@ export default UserTopicsList.extend({ actions: { unassign(topic) { - this.get("taskActions") + this.taskActions .unassign(topic.get("id")) .then(() => this.send("changeAssigned")); }, reassign(topic) { - const controller = this.get("taskActions").assign(topic); + const controller = this.taskActions.assign(topic); controller.set("model.onSuccess", () => this.send("changeAssigned")); } } diff --git a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 index bb70abb..5b6aac8 100644 --- a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 +++ b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6 @@ -35,13 +35,13 @@ function modifySelectKit(api) { return; } - const topic = context.get("topic"); + const topic = context.topic; const assignedUser = topic.get("assigned_to_user.username"); if (assignedUser) { ajax("/assign/unassign", { type: "PUT", - data: { topic_id: topic.get("id") } + data: { topic_id: topic.id } }) .then(result => { if (result.success && result.success === "OK") { @@ -87,13 +87,14 @@ function initialize(api) { } } - return this.get("actableFilter"); + return this.actableFilter; }, didInsertElement() { - this._super(); + this._super(...arguments); + this.messageBus.subscribe("/staff/topic-assignment", data => { - let flaggedPost = this.get("flaggedPost"); + let flaggedPost = this.flaggedPost; if (data.topic_id === flaggedPost.get("topic.id")) { flaggedPost.set( "topic.assigned_to_user_id", @@ -105,7 +106,8 @@ function initialize(api) { }, willDestroyElement() { - this._super(); + this._super(...arguments); + this.messageBus.unsubscribe("/staff/topic-assignment"); } }, @@ -140,14 +142,14 @@ function initialize(api) { api.addTagsHtmlCallback(topic => { const assignedTo = topic.get("assigned_to_user.username"); if (assignedTo) { - const assignedPath = topic.get("assignedToUserPath"); + const assignedPath = topic.assignedToUserPath; let assignLabels = `${iconHTML( "user-plus" )}${assignedTo}`; if ( ListItemDefaults === undefined && - topic.get("archetype") === "private_message" + topic.archetype === "private_message" ) { assignLabels += `
${iconHTML("envelope")} Message
`; } @@ -157,12 +159,12 @@ function initialize(api) { }); api.addUserMenuGlyph(widget => { - if (widget.currentUser && widget.currentUser.get("can_assign")) { + if (widget.currentUser && widget.currentUser.can_assign) { return { label: "discourse_assign.assigned", className: "assigned", icon: "user-plus", - href: `${widget.currentUser.get("path")}/activity/assigned` + href: `${widget.currentUser.path}/activity/assigned` }; } }); @@ -185,10 +187,11 @@ function initialize(api) { api.modifyClass("controller:topic", { subscribe() { - this._super(); + this._super(...arguments); + this.messageBus.subscribe("/staff/topic-assignment", data => { - const topic = this.get("model"); - const topicId = topic.get("id"); + const topic = this.model; + const topicId = topic.id; if (data.topic_id === topicId) { topic.set( @@ -233,7 +236,7 @@ function initialize(api) { api.modifyClass("controller:preferences/notifications", { actions: { save() { - this.get("saveAttrNames").push("custom_fields"); + this.saveAttrNames.push("custom_fields"); this._super(...arguments); } } diff --git a/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6 b/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6 index 88ed3e4..f0c452f 100644 --- a/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6 +++ b/assets/javascripts/discourse/components/assign-actions-dropdown.js.es6 @@ -28,10 +28,10 @@ export default DropdownSelectBoxComponent.extend({ onSelect(id) { switch (id) { case "unassign": - this.unassign(this.get("topic"), this.get("user")); + this.unassign(this.topic, this.user); break; case "reassign": - this.reassign(this.get("topic"), this.get("user")); + this.reassign(this.topic, this.user); break; } } diff --git a/assets/javascripts/discourse/components/assigned-topic-list-item.js.es6 b/assets/javascripts/discourse/components/assigned-topic-list-item.js.es6 index a9eaa15..9ebe092 100644 --- a/assets/javascripts/discourse/components/assigned-topic-list-item.js.es6 +++ b/assets/javascripts/discourse/components/assigned-topic-list-item.js.es6 @@ -1,11 +1,5 @@ -import computed from "ember-addons/ember-computed-decorators"; import { ListItemDefaults } from "discourse/components/topic-list-item"; -const privateMessageHelper = { - @computed("topic.archetype") - isPrivateMessage(archetype) { - return archetype === "private_message"; - } -}; - -export default Ember.Component.extend(ListItemDefaults, privateMessageHelper); +export default Ember.Component.extend(ListItemDefaults, { + isPrivateMessage: Ember.computed.equal("topic.archetype", "private_message") +}); diff --git a/assets/javascripts/discourse/components/claim-topic.js.es6 b/assets/javascripts/discourse/components/claim-topic.js.es6 index dca72f1..49cda18 100644 --- a/assets/javascripts/discourse/components/claim-topic.js.es6 +++ b/assets/javascripts/discourse/components/claim-topic.js.es6 @@ -25,7 +25,7 @@ export default Ember.Component.extend({ claim() { this.set("claiming", true); - let topic = this.get("topic"); + let topic = this.topic; ajax(`/assign/claim/${topic.id}`, { method: "PUT" }) diff --git a/assets/javascripts/discourse/components/flagged-topic-listener.js.es6 b/assets/javascripts/discourse/components/flagged-topic-listener.js.es6 index 85f5a96..3997a29 100644 --- a/assets/javascripts/discourse/components/flagged-topic-listener.js.es6 +++ b/assets/javascripts/discourse/components/flagged-topic-listener.js.es6 @@ -8,11 +8,11 @@ export default Ember.Component.extend({ didInsertElement() { this._super(); this.messageBus.subscribe("/staff/topic-assignment", data => { - let flaggedTopics = this.get("flaggedTopics"); + let flaggedTopics = this.flaggedTopics; if (flaggedTopics) { flaggedTopics.forEach(ft => assignIfEqual(ft.topic, data)); } else { - assignIfEqual(this.get("topic"), data); + assignIfEqual(this.topic, data); } }); }, diff --git a/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6 b/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6 index 29e9831..80d41b3 100644 --- a/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6 +++ b/assets/javascripts/discourse/components/remind-assigns-frequency.js.es6 @@ -4,8 +4,8 @@ export default Ember.Component.extend({ selectedFrequency: null, @computed("user.reminders_frequency") - availableFrequencies() { - return this.get("user.reminders_frequency").map(freq => { + availableFrequencies(userRemindersFrequency) { + return userRemindersFrequency.map(freq => { return { name: I18n.t(freq.name), value: freq.value, @@ -15,15 +15,17 @@ export default Ember.Component.extend({ }, didInsertElement() { - let current_frequency = this.get( + this._super(...arguments); + + let currentFrequency = this.get( "user.custom_fields.remind_assigns_frequency" ); - if (current_frequency === undefined) { - current_frequency = this.get("siteSettings.remind_assigns_frequency"); + if (currentFrequency === undefined) { + currentFrequency = this.get("siteSettings.remind_assigns_frequency"); } - this.set("selectedFrequency", current_frequency); + this.set("selectedFrequency", currentFrequency); }, actions: { diff --git a/assets/javascripts/discourse/services/task-actions.js.es6 b/assets/javascripts/discourse/services/task-actions.js.es6 index ae25601..75fe9a3 100644 --- a/assets/javascripts/discourse/services/task-actions.js.es6 +++ b/assets/javascripts/discourse/services/task-actions.js.es6 @@ -21,7 +21,7 @@ export default Ember.Service.extend({ assign(topic) { return showModal("assign-user", { model: { - topic: topic, + topic, username: topic.get("assigned_to_user.username"), allowedGroups: this.allowedGroups }