43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
//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: function(){
|
|
ajax("/assign/suggestions").then(users => {
|
|
this.set("assignSuggestions", users);
|
|
});
|
|
}.property(),
|
|
|
|
// @computed("username")
|
|
// disabled(username) {
|
|
// return Ember.isEmpty(username);
|
|
// },
|
|
|
|
actions: {
|
|
assignUser(user) {
|
|
this.set('model.username', user.username);
|
|
this.send('assign');
|
|
},
|
|
assign(){
|
|
|
|
let path = '/assign/assign';
|
|
|
|
if (Ember.isEmpty(this.get('model.username'))) {
|
|
path = '/assign/unassign';
|
|
this.set('model.assigned_to_user', null);
|
|
}
|
|
|
|
this.send('closeModal');
|
|
|
|
return ajax(path,{
|
|
type: 'PUT',
|
|
data: { username: this.get('model.username'), topic_id: this.get('model.topic.id') }
|
|
}).then(()=>{
|
|
// done
|
|
}).catch(popupAjaxError);
|
|
}
|
|
}
|
|
});
|