mirror of https://github.com/Requarks/wiki.git
11 changed files with 289 additions and 53 deletions
Split View
Diff Options
-
99client/components/editor.vue
-
17client/components/editor/editor-modal-properties.vue
-
39client/components/setup.vue
-
12client/graph/editor/update.gql
-
1client/store/editor.js
-
26server/db/migrations/2.0.0.js
-
100server/db/models/pageHistory.js
-
30server/db/models/pages.js
-
4server/db/models/storage.js
-
11server/graph/resolvers/page.js
-
3server/graph/schemas/page.graphql
@ -0,0 +1,12 @@ |
|||
mutation ($id: Int!, $content: String, $description: String, $editor: String, $isPrivate: Boolean, $isPublished: Boolean, $locale: String, $path: String, $publishEndDate: Date, $publishStartDate: Date, $tags: [String], $title: String) { |
|||
pages { |
|||
update(id: $id, content: $content, description: $description, editor: $editor, isPrivate: $isPrivate, isPublished: $isPublished, locale: $locale, path: $path, publishEndDate: $publishEndDate, publishStartDate: $publishStartDate, tags: $tags, title: $title) { |
|||
responseResult { |
|||
succeeded |
|||
errorCode |
|||
slug |
|||
message |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,100 @@ |
|||
const Model = require('objection').Model |
|||
|
|||
/* global WIKI */ |
|||
|
|||
/** |
|||
* Page History model |
|||
*/ |
|||
module.exports = class PageHistory extends Model { |
|||
static get tableName() { return 'pageHistory' } |
|||
|
|||
static get jsonSchema () { |
|||
return { |
|||
type: 'object', |
|||
required: ['path', 'title'], |
|||
|
|||
properties: { |
|||
id: {type: 'integer'}, |
|||
path: {type: 'string'}, |
|||
title: {type: 'string'}, |
|||
description: {type: 'string'}, |
|||
isPublished: {type: 'boolean'}, |
|||
publishStartDate: {type: 'string'}, |
|||
publishEndDate: {type: 'string'}, |
|||
content: {type: 'string'}, |
|||
|
|||
createdAt: {type: 'string'} |
|||
} |
|||
} |
|||
} |
|||
|
|||
static get relationMappings() { |
|||
return { |
|||
tags: { |
|||
relation: Model.ManyToManyRelation, |
|||
modelClass: require('./tags'), |
|||
join: { |
|||
from: 'pageHistory.id', |
|||
through: { |
|||
from: 'pageHistoryTags.pageId', |
|||
to: 'pageHistoryTags.tagId' |
|||
}, |
|||
to: 'tags.id' |
|||
} |
|||
}, |
|||
page: { |
|||
relation: Model.BelongsToOneRelation, |
|||
modelClass: require('./pages'), |
|||
join: { |
|||
from: 'pageHistory.pageId', |
|||
to: 'pages.id' |
|||
} |
|||
}, |
|||
author: { |
|||
relation: Model.BelongsToOneRelation, |
|||
modelClass: require('./users'), |
|||
join: { |
|||
from: 'pageHistory.authorId', |
|||
to: 'users.id' |
|||
} |
|||
}, |
|||
editor: { |
|||
relation: Model.BelongsToOneRelation, |
|||
modelClass: require('./editors'), |
|||
join: { |
|||
from: 'pageHistory.editorKey', |
|||
to: 'editors.key' |
|||
} |
|||
}, |
|||
locale: { |
|||
relation: Model.BelongsToOneRelation, |
|||
modelClass: require('./locales'), |
|||
join: { |
|||
from: 'pageHistory.localeCode', |
|||
to: 'locales.code' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
$beforeInsert() { |
|||
this.createdAt = new Date().toISOString() |
|||
} |
|||
|
|||
static async addVersion(opts) { |
|||
await WIKI.db.pageHistory.query().insert({ |
|||
pageId: opts.id, |
|||
authorId: opts.authorId, |
|||
content: opts.content, |
|||
description: opts.description, |
|||
editorKey: opts.editorKey, |
|||
isPrivate: opts.isPrivate, |
|||
isPublished: opts.isPublished, |
|||
localeCode: opts.localeCode, |
|||
path: opts.path, |
|||
publishEndDate: opts.publishEndDate, |
|||
publishStartDate: opts.publishStartDate, |
|||
title: opts.title |
|||
}) |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save