-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathnew.js
More file actions
44 lines (36 loc) · 1.04 KB
/
new.js
File metadata and controls
44 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import Ember from 'ember';
import BackNavigateable from 'flaredown/mixins/back-navigateable';
import SearchableDropdown from 'flaredown/mixins/searchable-dropdown';
const {
get,
computed,
Controller,
getProperties,
} = Ember;
export default Controller.extend(BackNavigateable, SearchableDropdown, {
disabled: computed('model.{body,title,topics.[]}', function() {
const { body, title, topics } = getProperties(get(this, 'model'), 'body', 'title', 'topics');
return !(body && title && topics.length);
}),
randomTrackables: computed(function() {
return this.randomSearch('topic');
}),
performSearch(term, resolve, reject) {
this
.searchByTerm('topic', term)
.then(function() { resolve(...arguments); }, reject);
},
actions: {
addTopic(topic) {
get(this, 'model').addTopic(topic);
},
savePost() {
get(this, 'model')
.save()
.then(post => this.transitionToRoute('posts.show', post));
},
removeTopic(topic) {
get(this, 'model').removeTopic(topic);
},
},
});