2018-03-13 14:17:29 +03:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import {computed} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
|
|
|
|
store: service(),
|
|
|
|
|
|
|
|
// public attrs
|
|
|
|
selectedAuthors: null,
|
|
|
|
tagName: '',
|
|
|
|
triggerId: '',
|
|
|
|
|
2018-04-30 15:54:09 +03:00
|
|
|
// internal attrs
|
|
|
|
availableAuthors: null,
|
|
|
|
|
2018-03-13 14:17:29 +03:00
|
|
|
// closure actions
|
|
|
|
updateAuthors() {},
|
|
|
|
|
|
|
|
availableAuthorNames: computed('availableAuthors.@each.name', function () {
|
|
|
|
return this.get('availableAuthors').map(author => author.get('name').toLowerCase());
|
|
|
|
}),
|
|
|
|
|
2018-04-30 15:54:09 +03:00
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
|
|
|
// perform a background query to fetch all users and set `availableAuthors`
|
|
|
|
// to a live-query that will be immediately populated with what's in the
|
|
|
|
// store and be updated when the above query returns
|
|
|
|
this.store.query('user', {limit: 'all'});
|
|
|
|
this.set('availableAuthors', this.store.peekAll('user'));
|
|
|
|
},
|
|
|
|
|
2018-03-13 14:17:29 +03:00
|
|
|
actions: {
|
|
|
|
updateAuthors(newAuthors) {
|
|
|
|
this.updateAuthors(newAuthors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|