[FIX] allows usage with select-box-kit

This commit also removes usage of observers.
This commit is contained in:
Joffrey JAFFEUX 2017-10-20 06:23:31 -07:00
parent 3e024779fa
commit 7fd0cd43bf
1 changed files with 28 additions and 21 deletions

View File

@ -1,5 +1,5 @@
import { withPluginApi } from 'discourse/lib/plugin-api'; import { withPluginApi } from 'discourse/lib/plugin-api';
import { default as computed, observes } from 'ember-addons/ember-computed-decorators'; import { default as computed } from 'ember-addons/ember-computed-decorators';
// should this be in API ? // should this be in API ?
import showModal from 'discourse/lib/show-modal'; import showModal from 'discourse/lib/show-modal';
@ -41,36 +41,43 @@ function initialize(api) {
// doing this mess while we come up with a better API // doing this mess while we come up with a better API
api.modifyClass('component:topic-footer-mobile-dropdown', { api.modifyClass('component:topic-footer-mobile-dropdown', {
_createContent() { @computed("value")
this._super(); content() {
const content = this._super();
if (!this.get('currentUser.staff') || !this.siteSettings.assign_enabled) { if (!this.get('currentUser.staff') || !this.siteSettings.assign_enabled) {
return; return;
} }
const content = this.get('content');
content.push({ id: 'assign', icon: 'user-plus', name: I18n.t('discourse_assign.assign.title') }); content.pushObject({
id: 'assign',
icon: 'user-plus',
name: I18n.t('discourse_assign.assign.title')
});
return content;
}, },
@observes('value') actions: {
_gotAssigned() { onSelect(value) {
this._super(value);
if (!this.get('currentUser.staff')) { if (!this.get('currentUser.staff')) {
return; return;
} }
const value = this.get('value'); const topic = this.get('topic');
const topic = this.get('topic');
if (value === 'assign') { if (value === 'assign') {
showModal("assign-user", { showModal("assign-user", {
model: { model: {
topic: topic, topic: topic,
username: topic.get('assigned_to_user.username') username: topic.get('assigned_to_user.username')
} }
}); });
this._createContent(); this.set('value', null);
this.set('value', null); }
} }
} }
}); });