Ghost/ghost/admin/app/components/gh-psm-authors-input.js
Kevin Ansfield e28a960970 Removed used of ember-data-filter
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
2018-04-30 13:54:09 +01:00

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);
}
}
});