mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
6a3cfc2ca8
requires https://github.com/TryGhost/Ghost/pull/9426 - fixed default token component display in {{gh-token-input}} - if no `tokenComponent` is passed to `{{gh-token-input}}` then it should default to the ember-drag-drop `draggable-object` component but instead it didn't output anything - put `draggable-object` in quotes because `{{component}}` needs a component name rather than an object - rename `option` attribute to `content` to match the default `{{draggable-object}}` interface - add embedded `authors` attr to the Post model - ensure authors is populated when starting new post - add validation for empty authors list - swap author dropdown for a token input in PSM - show all post authors in posts list - update tests for `authors` - always provide through an authors array - fix mirage serialisation for paginated responses (embedded records were not being serialised) - unify tags and author inputs design - remove highlight of primary tags - highlight internal tags - remove unnecessary/redundant title attributes on tags - use SVG icon for "remove option" button in token inputs
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import {Factory, faker} from 'ember-cli-mirage';
|
|
import {isEmpty} from '@ember/utils';
|
|
|
|
export default Factory.extend({
|
|
codeinjectionFoot: null,
|
|
codeinjectionHead: null,
|
|
createdAt: '2015-09-11T09:44:29.871Z',
|
|
createdBy: 1,
|
|
customExcerpt: null,
|
|
customTemplate: null,
|
|
description(i) { return `Title for post ${i}.`; },
|
|
featured: false,
|
|
featureImage(i) { return `/content/images/2015/10/post-${i}.jpg`; },
|
|
html(i) { return `<p>HTML for post ${i}.</p>`; },
|
|
locale: null,
|
|
metaDescription(i) { return `Meta description for post ${i}.`; },
|
|
metaTitle(i) { return `Meta Title for post ${i}`; },
|
|
ogDescription: null,
|
|
ogImage: null,
|
|
ogTitle: null,
|
|
page: false,
|
|
plaintext(i) { return `Plaintext for post ${i}.`; },
|
|
publishedAt: '2015-12-19T16:25:07.000Z',
|
|
publishedBy: 1,
|
|
status(i) { return faker.list.cycle('draft', 'published', 'scheduled')(i); },
|
|
title(i) { return `Post ${i}`; },
|
|
twitterDescription: null,
|
|
twitterImage: null,
|
|
twitterTitle: null,
|
|
updatedAt: '2015-10-19T16:25:07.756Z',
|
|
updatedBy: 1,
|
|
uuid(i) { return `post-${i}`; },
|
|
|
|
authors() { return []; },
|
|
tags() { return []; },
|
|
|
|
afterCreate(post, server) {
|
|
if (isEmpty(post.authors)) {
|
|
let user = server.schema.users.find(1);
|
|
|
|
if (!user) {
|
|
let role = server.schema.roles.find({name: 'Administrator'}) || server.create('role', {name: 'Administrator'});
|
|
user = server.create('user', {roles: [role]});
|
|
}
|
|
|
|
post.authors = [user];
|
|
post.save();
|
|
}
|
|
}
|
|
});
|