feat: branch off / create from template

This commit is contained in:
NGPixel
2020-03-01 18:22:26 -05:00
committed by Nicolas Giard
parent e85de92715
commit 13a995133b
7 changed files with 142 additions and 21 deletions

View File

@@ -171,7 +171,7 @@ export default {
this.initContentParsed = this.initContent ? Base64.decode(this.initContent) : ''
this.$store.set('editor/content', this.initContentParsed)
if (this.mode === 'create') {
if (this.mode === 'create' && !this.initEditor) {
_.delay(() => {
this.dialogEditorSelector = true
}, 500)

View File

@@ -474,7 +474,7 @@ export default {
mounted() {
this.$store.set('editor/editorKey', 'markdown')
if (this.mode === 'create') {
if (this.mode === 'create' && !this.$store.get('editor/content')) {
this.$store.set('editor/content', '# Header\nYour content here')
}

View File

@@ -122,6 +122,8 @@
v-btn(text, @click='isRestoreConfirmDialogShown = false', :disabled='restoreLoading') {{$t('common:actions.cancel')}}
v-btn(color='orange darken-2', dark, @click='restoreConfirm', :loading='restoreLoading') {{$t('history:restore.confirmButton')}}
page-selector(mode='create', v-model='branchOffOpts.modal', :open-handler='branchOffHandle', :path='branchOffOpts.path', :locale='branchOffOpts.locale')
nav-footer
notify
search-results
@@ -211,6 +213,12 @@ export default {
versionId: 0,
versionDate: ''
},
branchOffOpts: {
versionId: 0,
locale: 'en',
path: 'new-page',
modal: false
},
isRestoreConfirmDialogShown: false,
restoreLoading: false
}
@@ -408,7 +416,16 @@ export default {
this.restoreLoading = false
},
branchOff (versionId) {
const pathParts = this.path.split('/')
this.branchOffOpts = {
versionId: versionId,
locale: this.locale,
path: (pathParts.length > 1) ? _.initial(pathParts).join('/') + `/new-page` : `new-page`,
modal: true
}
},
branchOffHandle ({ locale, path }) {
window.location.assign(`/e/${locale}/${path}?from=${this.pageId},${this.branchOffOpts.versionId}`)
},
toggleViewMode () {
this.viewMode = (this.viewMode === 'line-by-line') ? 'side-by-side' : 'line-by-line'