mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
e28a960970
closes https://github.com/TryGhost/Ghost/issues/9591 - swapped use of `store.filter` for a combination `store.peekAll` and CPs to filter the result set
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
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: '',
|
|
|
|
// internal attrs
|
|
availableAuthors: null,
|
|
|
|
// closure actions
|
|
updateAuthors() {},
|
|
|
|
availableAuthorNames: computed('availableAuthors.@each.name', function () {
|
|
return this.get('availableAuthors').map(author => author.get('name').toLowerCase());
|
|
}),
|
|
|
|
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'));
|
|
},
|
|
|
|
actions: {
|
|
updateAuthors(newAuthors) {
|
|
this.updateAuthors(newAuthors);
|
|
}
|
|
}
|
|
|
|
});
|