2018-02-11 05:20:17 +00:00
|
|
|
<template lang="pug">
|
2018-02-19 07:00:55 +00:00
|
|
|
.editor
|
2018-03-19 03:12:56 +00:00
|
|
|
nav-header
|
|
|
|
template(slot='actions')
|
|
|
|
v-btn(outline, color='green', @click.native.stop='save')
|
2018-05-20 22:50:51 +00:00
|
|
|
v-icon(color='green', left) check
|
2018-07-16 02:40:41 +00:00
|
|
|
span.white--text(v-if='mode === "create"') {{ $t('common:actions.create') }}
|
|
|
|
span.white--text(v-else) {{ $t('common:actions.save') }}
|
|
|
|
v-btn.is-icon(outline, color='red').mx-0: v-icon(color='red') close
|
|
|
|
v-btn(outline, color='blue', @click.native.stop='openModal(`properties`)', dark)
|
|
|
|
v-icon(left) sort_by_alpha
|
|
|
|
span.white--text {{ $t('editor:page') }}
|
2018-03-19 03:12:56 +00:00
|
|
|
v-content
|
|
|
|
editor-code
|
|
|
|
component(:is='currentModal')
|
2018-05-20 22:50:51 +00:00
|
|
|
v-dialog(v-model='dialogProgress', persistent, max-width='350')
|
|
|
|
v-card(color='blue darken-3', dark)
|
|
|
|
v-card-text.text-xs-center.py-4
|
2018-07-15 23:16:19 +00:00
|
|
|
atom-spinner.is-inline(
|
|
|
|
:animation-duration='1000'
|
|
|
|
:size='60'
|
|
|
|
color='#FFF'
|
|
|
|
)
|
2018-07-22 04:29:39 +00:00
|
|
|
.subheading {{ $t('editor:save.processing') }}
|
|
|
|
.caption.blue--text.text--lighten-3 {{ $t('editor:save.pleaseWait') }}
|
|
|
|
|
|
|
|
v-snackbar(
|
|
|
|
:color='notification.style'
|
|
|
|
bottom,
|
|
|
|
right,
|
|
|
|
multi-line,
|
|
|
|
v-model='notificationState'
|
|
|
|
)
|
|
|
|
.text-xs-left
|
|
|
|
v-icon.mr-3(dark) {{ notification.icon }}
|
|
|
|
span {{ notification.message }}
|
2018-02-11 05:20:17 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-02-19 20:41:36 +00:00
|
|
|
import _ from 'lodash'
|
2018-07-22 04:29:39 +00:00
|
|
|
import { get, sync } from 'vuex-pathify'
|
2018-07-15 23:16:19 +00:00
|
|
|
import { AtomSpinner } from 'epic-spinners'
|
|
|
|
|
2018-07-22 04:29:39 +00:00
|
|
|
import createPageMutation from 'gql/editor/create.gql'
|
2018-07-15 23:16:19 +00:00
|
|
|
|
|
|
|
import editorStore from '@/store/editor'
|
|
|
|
|
|
|
|
/* global WIKI */
|
|
|
|
|
|
|
|
WIKI.$store.registerModule('editor', editorStore)
|
2018-02-19 20:41:36 +00:00
|
|
|
|
2018-02-11 05:20:17 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2018-07-15 23:16:19 +00:00
|
|
|
AtomSpinner,
|
2018-03-28 04:02:32 +00:00
|
|
|
editorCode: () => import(/* webpackChunkName: "editor-code" */ './editor/editor-code.vue'),
|
|
|
|
editorModalProperties: () => import(/* webpackChunkName: "editor" */ './editor/editor-modal-properties.vue')
|
2018-02-19 07:00:55 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2018-02-19 20:41:36 +00:00
|
|
|
currentModal: '',
|
|
|
|
dialogProgress: false
|
|
|
|
}
|
|
|
|
},
|
2018-07-16 02:40:41 +00:00
|
|
|
computed: {
|
2018-07-22 04:29:39 +00:00
|
|
|
mode: get('editor/mode'),
|
|
|
|
notification: get('notification'),
|
|
|
|
notificationState: sync('notification@isActive')
|
2018-07-16 02:40:41 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.mode === 'create') {
|
|
|
|
_.delay(() => {
|
|
|
|
this.openModal('properties')
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
},
|
2018-02-19 20:41:36 +00:00
|
|
|
methods: {
|
|
|
|
openModal(name) {
|
|
|
|
this.currentModal = `editorModal${_.startCase(name)}`
|
|
|
|
},
|
|
|
|
closeModal() {
|
|
|
|
_.delay(() => {
|
|
|
|
this.currentModal = ``
|
|
|
|
}, 500)
|
|
|
|
},
|
|
|
|
showProgressDialog(textKey) {
|
|
|
|
this.dialogProgress = true
|
|
|
|
},
|
|
|
|
hideProgressDialog() {
|
|
|
|
this.dialogProgress = false
|
|
|
|
},
|
2018-07-15 23:16:19 +00:00
|
|
|
async save() {
|
2018-02-19 20:41:36 +00:00
|
|
|
this.showProgressDialog('saving')
|
2018-07-22 04:29:39 +00:00
|
|
|
if (this.$store.get('editor/mode') === 'create') {
|
|
|
|
const resp = await this.$apollo.mutate({
|
|
|
|
mutation: createPageMutation,
|
|
|
|
variables: {
|
|
|
|
description: this.$store.get('editor/description'),
|
|
|
|
editor: 'markdown',
|
|
|
|
locale: this.$store.get('editor/locale'),
|
|
|
|
isPublished: this.$store.get('editor/isPublished'),
|
|
|
|
path: this.$store.get('editor/path'),
|
|
|
|
publishEndDate: this.$store.get('editor/publishEndDate'),
|
|
|
|
publishStartDate: this.$store.get('editor/publishStartDate'),
|
|
|
|
tags: this.$store.get('editor/tags'),
|
|
|
|
title: this.$store.get('editor/title')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if (_.get(resp, 'data.pages.create.responseResult.succeeded')) {
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: this.$t('editor:save.success'),
|
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
|
|
|
})
|
|
|
|
this.$store.set('editor/mode', 'update')
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
2018-07-15 23:16:19 +00:00
|
|
|
|
2018-07-22 04:29:39 +00:00
|
|
|
}
|
|
|
|
this.hideProgressDialog()
|
2018-02-19 07:00:55 +00:00
|
|
|
}
|
2018-02-11 05:20:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
|
2018-07-15 23:16:19 +00:00
|
|
|
.atom-spinner.is-inline {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
2018-02-11 05:20:17 +00:00
|
|
|
</style>
|