mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Migrated admin and core modules to use nql-filter-expansions
refs https://github.com/TryGhost/Arch/issues/46 - Reused posts expansions from nql-filter-expansions module
This commit is contained in:
parent
9f979917e3
commit
8fa36916d7
5 changed files with 8 additions and 67 deletions
|
@ -6,6 +6,7 @@ import UnpublishPostsModal from './modals/unpublish-posts';
|
||||||
import nql from '@tryghost/nql';
|
import nql from '@tryghost/nql';
|
||||||
import {action} from '@ember/object';
|
import {action} from '@ember/object';
|
||||||
import {capitalizeFirstLetter} from 'ghost-admin/helpers/capitalize-first-letter';
|
import {capitalizeFirstLetter} from 'ghost-admin/helpers/capitalize-first-letter';
|
||||||
|
import {posts as postExpansions} from '@tryghost/nql-filter-expansions';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
import {task} from 'ember-concurrency';
|
import {task} from 'ember-concurrency';
|
||||||
|
|
||||||
|
@ -257,29 +258,7 @@ export default class PostsContextMenu extends Component {
|
||||||
const updatedModels = this.selectionList.availableModels;
|
const updatedModels = this.selectionList.availableModels;
|
||||||
const filter = this.selectionList.allFilter;
|
const filter = this.selectionList.allFilter;
|
||||||
const filterNql = nql(filter, {
|
const filterNql = nql(filter, {
|
||||||
expansions: [
|
expansions: postExpansions
|
||||||
{
|
|
||||||
key: 'primary_tag',
|
|
||||||
replacement: 'tags.slug',
|
|
||||||
expansion: 'posts_tags.sort_order:0+tags.visibility:public'
|
|
||||||
}, {
|
|
||||||
key: 'primary_author',
|
|
||||||
replacement: 'authors.slug',
|
|
||||||
expansion: 'posts_authors.sort_order:0+authors.visibility:public'
|
|
||||||
}, {
|
|
||||||
key: 'authors',
|
|
||||||
replacement: 'authors.slug'
|
|
||||||
}, {
|
|
||||||
key: 'author',
|
|
||||||
replacement: 'authors.slug'
|
|
||||||
}, {
|
|
||||||
key: 'tag',
|
|
||||||
replacement: 'tags.slug'
|
|
||||||
}, {
|
|
||||||
key: 'tags',
|
|
||||||
replacement: 'tags.slug'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const remainingModels = this.selectionList.infinityModel.content.filter((model) => {
|
const remainingModels = this.selectionList.infinityModel.content.filter((model) => {
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
"@tryghost/members-csv": "0.0.0",
|
"@tryghost/members-csv": "0.0.0",
|
||||||
"@tryghost/mobiledoc-kit": "0.12.5-ghost.2",
|
"@tryghost/mobiledoc-kit": "0.12.5-ghost.2",
|
||||||
"@tryghost/nql": "0.11.0",
|
"@tryghost/nql": "0.11.0",
|
||||||
|
"@tryghost/nql-filter-expansions": "0.0.0",
|
||||||
"@tryghost/nql-lang": "0.5.0",
|
"@tryghost/nql-lang": "0.5.0",
|
||||||
"@tryghost/string": "0.2.4",
|
"@tryghost/string": "0.2.4",
|
||||||
"@tryghost/timezone-data": "0.3.0",
|
"@tryghost/timezone-data": "0.3.0",
|
||||||
|
|
|
@ -7,6 +7,7 @@ const tpl = require('@tryghost/tpl');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const nql = require('@tryghost/nql');
|
const nql = require('@tryghost/nql');
|
||||||
const htmlToPlaintext = require('@tryghost/html-to-plaintext');
|
const htmlToPlaintext = require('@tryghost/html-to-plaintext');
|
||||||
|
const {posts: postExpansions} = require('@tryghost/nql-filter-expansions');
|
||||||
const ghostBookshelf = require('./base');
|
const ghostBookshelf = require('./base');
|
||||||
const config = require('../../shared/config');
|
const config = require('../../shared/config');
|
||||||
const settingsCache = require('../../shared/settings-cache');
|
const settingsCache = require('../../shared/settings-cache');
|
||||||
|
@ -290,28 +291,6 @@ Post = ghostBookshelf.Model.extend({
|
||||||
filterExpansions: function filterExpansions() {
|
filterExpansions: function filterExpansions() {
|
||||||
const postsMetaKeys = _.without(ghostBookshelf.model('PostsMeta').prototype.orderAttributes(), 'posts_meta.id', 'posts_meta.post_id');
|
const postsMetaKeys = _.without(ghostBookshelf.model('PostsMeta').prototype.orderAttributes(), 'posts_meta.id', 'posts_meta.post_id');
|
||||||
|
|
||||||
const expansions = [{
|
|
||||||
key: 'primary_tag',
|
|
||||||
replacement: 'tags.slug',
|
|
||||||
expansion: 'posts_tags.sort_order:0+tags.visibility:public'
|
|
||||||
}, {
|
|
||||||
key: 'primary_author',
|
|
||||||
replacement: 'authors.slug',
|
|
||||||
expansion: 'posts_authors.sort_order:0+authors.visibility:public'
|
|
||||||
}, {
|
|
||||||
key: 'authors',
|
|
||||||
replacement: 'authors.slug'
|
|
||||||
}, {
|
|
||||||
key: 'author',
|
|
||||||
replacement: 'authors.slug'
|
|
||||||
}, {
|
|
||||||
key: 'tag',
|
|
||||||
replacement: 'tags.slug'
|
|
||||||
}, {
|
|
||||||
key: 'tags',
|
|
||||||
replacement: 'tags.slug'
|
|
||||||
}];
|
|
||||||
|
|
||||||
const postMetaKeyExpansions = postsMetaKeys.map((pmk) => {
|
const postMetaKeyExpansions = postsMetaKeys.map((pmk) => {
|
||||||
return {
|
return {
|
||||||
key: pmk.split('.')[1],
|
key: pmk.split('.')[1],
|
||||||
|
@ -319,7 +298,7 @@ Post = ghostBookshelf.Model.extend({
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return expansions.concat(postMetaKeyExpansions);
|
return postExpansions.concat(postMetaKeyExpansions);
|
||||||
},
|
},
|
||||||
|
|
||||||
filterRelations: function filterRelations() {
|
filterRelations: function filterRelations() {
|
||||||
|
|
|
@ -3,26 +3,7 @@ const nql = require('@tryghost/nql');
|
||||||
const debug = require('@tryghost/debug')('services:url:generator');
|
const debug = require('@tryghost/debug')('services:url:generator');
|
||||||
const localUtils = require('../../../shared/url-utils');
|
const localUtils = require('../../../shared/url-utils');
|
||||||
|
|
||||||
// @TODO: merge with filter plugin
|
const {posts: postExpansions} = require('@tryghost/nql-filter-expansions');
|
||||||
const EXPANSIONS = [{
|
|
||||||
key: 'author',
|
|
||||||
replacement: 'authors.slug'
|
|
||||||
}, {
|
|
||||||
key: 'tags',
|
|
||||||
replacement: 'tags.slug'
|
|
||||||
}, {
|
|
||||||
key: 'tag',
|
|
||||||
replacement: 'tags.slug'
|
|
||||||
}, {
|
|
||||||
key: 'authors',
|
|
||||||
replacement: 'authors.slug'
|
|
||||||
}, {
|
|
||||||
key: 'primary_tag',
|
|
||||||
replacement: 'primary_tag.slug'
|
|
||||||
}, {
|
|
||||||
key: 'primary_author',
|
|
||||||
replacement: 'primary_author.slug'
|
|
||||||
}];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The UrlGenerator class is responsible to generate urls based on a router's conditions.
|
* The UrlGenerator class is responsible to generate urls based on a router's conditions.
|
||||||
|
@ -57,7 +38,7 @@ class UrlGenerator {
|
||||||
if (filter) {
|
if (filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.nql = nql(this.filter, {
|
this.nql = nql(this.filter, {
|
||||||
expansions: EXPANSIONS,
|
expansions: postExpansions,
|
||||||
transformer: nql.utils.mapKeyValues({
|
transformer: nql.utils.mapKeyValues({
|
||||||
key: {
|
key: {
|
||||||
from: 'page',
|
from: 'page',
|
||||||
|
|
|
@ -135,6 +135,7 @@
|
||||||
"@tryghost/mw-vhost": "0.0.0",
|
"@tryghost/mw-vhost": "0.0.0",
|
||||||
"@tryghost/nodemailer": "0.3.35",
|
"@tryghost/nodemailer": "0.3.35",
|
||||||
"@tryghost/nql": "0.11.0",
|
"@tryghost/nql": "0.11.0",
|
||||||
|
"@tryghost/nql-filter-expansions": "0.0.0",
|
||||||
"@tryghost/oembed-service": "0.0.0",
|
"@tryghost/oembed-service": "0.0.0",
|
||||||
"@tryghost/package-json": "0.0.0",
|
"@tryghost/package-json": "0.0.0",
|
||||||
"@tryghost/post-revisions": "0.0.0",
|
"@tryghost/post-revisions": "0.0.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue