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 () {
|
2019-03-06 16:53:54 +03:00
|
|
|
return this.availableAuthors.map(author => author.get('name').toLowerCase());
|
2018-03-13 14:17:29 +03:00
|
|
|
}),
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|