mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
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
This commit is contained in:
parent
7d95d42eda
commit
e28a960970
8 changed files with 40 additions and 23 deletions
|
@ -11,18 +11,25 @@ export default Component.extend({
|
||||||
tagName: '',
|
tagName: '',
|
||||||
triggerId: '',
|
triggerId: '',
|
||||||
|
|
||||||
|
// internal attrs
|
||||||
|
availableAuthors: null,
|
||||||
|
|
||||||
// closure actions
|
// closure actions
|
||||||
updateAuthors() {},
|
updateAuthors() {},
|
||||||
|
|
||||||
// live-query of all users for author input autocomplete
|
|
||||||
availableAuthors: computed(function () {
|
|
||||||
return this.get('store').filter('user', {limit: 'all'}, () => true);
|
|
||||||
}),
|
|
||||||
|
|
||||||
availableAuthorNames: computed('availableAuthors.@each.name', function () {
|
availableAuthorNames: computed('availableAuthors.@each.name', function () {
|
||||||
return this.get('availableAuthors').map(author => author.get('name').toLowerCase());
|
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: {
|
actions: {
|
||||||
updateAuthors(newAuthors) {
|
updateAuthors(newAuthors) {
|
||||||
this.updateAuthors(newAuthors);
|
this.updateAuthors(newAuthors);
|
||||||
|
|
|
@ -10,15 +10,22 @@ export default Component.extend({
|
||||||
post: null,
|
post: null,
|
||||||
tagName: '',
|
tagName: '',
|
||||||
|
|
||||||
// live-query of all tags for tag input autocomplete
|
// internal attrs
|
||||||
availableTags: computed(function () {
|
availableTags: null,
|
||||||
return this.get('store').filter('tag', {limit: 'all'}, () => true);
|
|
||||||
}),
|
|
||||||
|
|
||||||
availableTagNames: computed('availableTags.@each.name', function () {
|
availableTagNames: computed('availableTags.@each.name', function () {
|
||||||
return this.get('availableTags').map(tag => tag.get('name').toLowerCase());
|
return this.get('availableTags').map(tag => tag.get('name').toLowerCase());
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._super(...arguments);
|
||||||
|
// perform a background query to fetch all users and set `availableTags`
|
||||||
|
// 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('tag', {limit: 'all'});
|
||||||
|
this.set('availableTags', this.store.peekAll('tag'));
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
matchTags(tagName, term) {
|
matchTags(tagName, term) {
|
||||||
return tagName.toLowerCase() === term.trim().toLowerCase();
|
return tagName.toLowerCase() === term.trim().toLowerCase();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Controller, {inject as controller} from '@ember/controller';
|
import Controller, {inject as controller} from '@ember/controller';
|
||||||
import {alias, equal, sort} from '@ember/object/computed';
|
import {alias, equal, sort} from '@ember/object/computed';
|
||||||
|
import {computed} from '@ember/object';
|
||||||
import {run} from '@ember/runloop';
|
import {run} from '@ember/runloop';
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
|
@ -12,8 +13,12 @@ export default Controller.extend({
|
||||||
tagListFocused: equal('keyboardFocus', 'tagList'),
|
tagListFocused: equal('keyboardFocus', 'tagList'),
|
||||||
tagContentFocused: equal('keyboardFocus', 'tagContent'),
|
tagContentFocused: equal('keyboardFocus', 'tagContent'),
|
||||||
|
|
||||||
|
filteredTags: computed('tags.@each.isNew', function () {
|
||||||
|
return this.get('tags').filterBy('isNew', false);
|
||||||
|
}),
|
||||||
|
|
||||||
// TODO: replace with ordering by page count once supported by the API
|
// TODO: replace with ordering by page count once supported by the API
|
||||||
sortedTags: sort('tags', function (a, b) {
|
sortedTags: sort('filteredTags', function (a, b) {
|
||||||
let idA = +a.get('id');
|
let idA = +a.get('id');
|
||||||
let idB = +b.get('id');
|
let idB = +b.get('id');
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* eslint-disable ghost/ember/alias-model-in-controller */
|
/* eslint-disable ghost/ember/alias-model-in-controller */
|
||||||
import Controller from '@ember/controller';
|
import Controller from '@ember/controller';
|
||||||
|
import {computed} from '@ember/object';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
import {sort} from '@ember/object/computed';
|
import {sort} from '@ember/object/computed';
|
||||||
|
|
||||||
|
@ -21,10 +22,14 @@ export default Controller.extend({
|
||||||
this.userOrder = ['name', 'email'];
|
this.userOrder = ['name', 'email'];
|
||||||
},
|
},
|
||||||
|
|
||||||
sortedInvites: sort('invites', 'inviteOrder'),
|
sortedInvites: sort('filteredInvites', 'inviteOrder'),
|
||||||
sortedActiveUsers: sort('activeUsers', 'userOrder'),
|
sortedActiveUsers: sort('activeUsers', 'userOrder'),
|
||||||
sortedSuspendedUsers: sort('suspendedUsers', 'userOrder'),
|
sortedSuspendedUsers: sort('suspendedUsers', 'userOrder'),
|
||||||
|
|
||||||
|
filteredInvites: computed('invites.@each.isNew', function () {
|
||||||
|
return this.get('invites').filterBy('isNew', false);
|
||||||
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
toggleInviteUserModal() {
|
toggleInviteUserModal() {
|
||||||
this.toggleProperty('showInviteUserModal');
|
this.toggleProperty('showInviteUserModal');
|
||||||
|
|
|
@ -34,12 +34,12 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, ShortcutsRoute, {
|
||||||
// pausing to show the loading spinner if no tags have been loaded yet
|
// pausing to show the loading spinner if no tags have been loaded yet
|
||||||
model() {
|
model() {
|
||||||
let promise = this.store.query('tag', {limit: 'all', include: 'count.posts'});
|
let promise = this.store.query('tag', {limit: 'all', include: 'count.posts'});
|
||||||
let filter = this.store.filter('tag', tag => !tag.get('isNew'));
|
let tags = this.store.peekAll('tag');
|
||||||
|
|
||||||
if (this.store.peekAll('tag').get('length') === 0) {
|
if (this.store.peekAll('tag').get('length') === 0) {
|
||||||
return promise.then(() => filter);
|
return promise.then(() => tags);
|
||||||
} else {
|
} else {
|
||||||
return filter;
|
return tags;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, Infinit
|
||||||
// authors do not have permission to hit the invites or suspended users endpoint
|
// authors do not have permission to hit the invites or suspended users endpoint
|
||||||
if (!user.get('isAuthorOrContributor')) {
|
if (!user.get('isAuthorOrContributor')) {
|
||||||
modelPromises.invites = this.store.query('invite', {limit: 'all'})
|
modelPromises.invites = this.store.query('invite', {limit: 'all'})
|
||||||
.then(() => this.store.filter('invite', invite => !invite.get('isNew')));
|
.then(() => this.store.peekAll('invite'));
|
||||||
|
|
||||||
// fetch suspended users separately so that infinite scroll still works
|
// fetch suspended users separately so that infinite scroll still works
|
||||||
modelPromises.suspendedUsers = this.store.query('user', {limit: 'all', filter: 'status:inactive'});
|
modelPromises.suspendedUsers = this.store.query('user', {limit: 'all', filter: 'status:inactive'});
|
||||||
|
|
|
@ -69,7 +69,6 @@
|
||||||
"ember-composable-helpers": "2.1.0",
|
"ember-composable-helpers": "2.1.0",
|
||||||
"ember-concurrency": "0.8.17",
|
"ember-concurrency": "0.8.17",
|
||||||
"ember-data": "3.1.1",
|
"ember-data": "3.1.1",
|
||||||
"ember-data-filter": "1.13.0",
|
|
||||||
"ember-drag-drop": "0.4.7",
|
"ember-drag-drop": "0.4.7",
|
||||||
"ember-element-resize-detector": "0.1.5",
|
"ember-element-resize-detector": "0.1.5",
|
||||||
"ember-export-application-global": "2.0.0",
|
"ember-export-application-global": "2.0.0",
|
||||||
|
|
|
@ -3333,7 +3333,7 @@ ember-cli-babel@6.12.0, ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.10,
|
||||||
ember-cli-version-checker "^2.1.0"
|
ember-cli-version-checker "^2.1.0"
|
||||||
semver "^5.4.1"
|
semver "^5.4.1"
|
||||||
|
|
||||||
ember-cli-babel@^5.0.0, ember-cli-babel@^5.1.5, ember-cli-babel@^5.1.6, ember-cli-babel@^5.1.7, ember-cli-babel@^5.2.4:
|
ember-cli-babel@^5.1.5, ember-cli-babel@^5.1.6, ember-cli-babel@^5.1.7, ember-cli-babel@^5.2.4:
|
||||||
version "5.2.8"
|
version "5.2.8"
|
||||||
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-5.2.8.tgz#0356b03cc3fdff5d0f2ecaa46a0e1cfaebffd876"
|
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-5.2.8.tgz#0356b03cc3fdff5d0f2ecaa46a0e1cfaebffd876"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -3824,12 +3824,6 @@ ember-cookies@^0.3.0:
|
||||||
ember-cli-babel "^6.8.2"
|
ember-cli-babel "^6.8.2"
|
||||||
ember-getowner-polyfill "^1.1.0 || ^2.0.0"
|
ember-getowner-polyfill "^1.1.0 || ^2.0.0"
|
||||||
|
|
||||||
ember-data-filter@1.13.0:
|
|
||||||
version "1.13.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ember-data-filter/-/ember-data-filter-1.13.0.tgz#54f9d54706d8ff61e9f0522660c86ec8de34def1"
|
|
||||||
dependencies:
|
|
||||||
ember-cli-babel "^5.0.0"
|
|
||||||
|
|
||||||
ember-data@3.1.1:
|
ember-data@3.1.1:
|
||||||
version "3.1.1"
|
version "3.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.1.1.tgz#8c17c97a4932b0a0a405cc3e38c43140880366d2"
|
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.1.1.tgz#8c17c97a4932b0a0a405cc3e38c43140880366d2"
|
||||||
|
|
Loading…
Add table
Reference in a new issue