2017-05-21 03:21:16 +00:00
|
|
|
<template lang="pug">
|
|
|
|
.modal(v-if='isShown')
|
|
|
|
.modal-background
|
|
|
|
.modal-container
|
|
|
|
.modal-content
|
|
|
|
header.is-light-blue Create New Document
|
|
|
|
section
|
|
|
|
label.label Enter the new document path:
|
|
|
|
p.control.is-fullwidth(v-class='{ "is-loading": isLoading }')
|
|
|
|
input.input(type='text', placeholder='page-name', v-model='entrypath', autofocus)
|
|
|
|
span.help.is-danger(v-show='isInvalid') This document path is invalid!
|
|
|
|
footer
|
2017-05-23 04:27:16 +00:00
|
|
|
a.button.is-grey.is-outlined(v-on:click='cancel') Discard
|
2017-05-21 03:21:16 +00:00
|
|
|
a.button.is-light-blue(v-on:click='create') Create
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-05-23 04:27:16 +00:00
|
|
|
import { isEmpty } from 'lodash'
|
|
|
|
// import { makeSafePath } from '../helpers/pages'
|
|
|
|
import { mapState } from 'vuex'
|
2017-05-21 03:21:16 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'modal-create',
|
|
|
|
data () {
|
|
|
|
return {
|
2017-05-23 04:27:16 +00:00
|
|
|
isLoading: false
|
2017-05-21 03:21:16 +00:00
|
|
|
}
|
|
|
|
},
|
2017-05-23 04:27:16 +00:00
|
|
|
computed: mapState('createPage', {
|
|
|
|
entrypath: '',
|
|
|
|
isShown: 'shown',
|
|
|
|
isInvalid: 'invalid'
|
|
|
|
}),
|
2017-05-21 03:21:16 +00:00
|
|
|
methods: {
|
2017-05-23 04:27:16 +00:00
|
|
|
cancel: function () {
|
|
|
|
this.$store.dispatch('createPageClose')
|
2017-05-21 03:21:16 +00:00
|
|
|
},
|
|
|
|
create: function () {
|
|
|
|
this.isInvalid = false
|
|
|
|
let newDocPath = makeSafePath(this.entrypath)
|
2017-05-23 04:27:16 +00:00
|
|
|
if (isEmpty(newDocPath)) {
|
|
|
|
this.$store.createPage.commit('')
|
2017-05-21 03:21:16 +00:00
|
|
|
} else {
|
2017-05-23 04:27:16 +00:00
|
|
|
this.isLoading = true
|
2017-05-21 03:21:16 +00:00
|
|
|
window.location.assign('/create/' + newDocPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted () {
|
2017-05-23 04:27:16 +00:00
|
|
|
// this.entrypath = currentBasePath + '/new-page'
|
2017-05-21 03:21:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|