feat: duplicate page

pull/1641/head
NGPixel 5 years ago
parent 44a0f69a78
commit 951ebb6b61

@ -132,6 +132,9 @@
v-list-item.pl-4(@click='pageSource', v-if='mode !== `source`') v-list-item.pl-4(@click='pageSource', v-if='mode !== `source`')
v-list-item-avatar(size='24'): v-icon(color='indigo') mdi-code-tags v-list-item-avatar(size='24'): v-icon(color='indigo') mdi-code-tags
v-list-item-title.body-2 {{$t('common:header.viewSource')}} v-list-item-title.body-2 {{$t('common:header.viewSource')}}
v-list-item.pl-4(@click='pageDuplicate', v-if='isAuthenticated')
v-list-item-avatar(size='24'): v-icon(color='indigo') mdi-content-duplicate
v-list-item-title.body-2 {{$t('common:header.duplicate')}}
v-list-item.pl-4(@click='pageMove', v-if='isAuthenticated') v-list-item.pl-4(@click='pageMove', v-if='isAuthenticated')
v-list-item-avatar(size='24'): v-icon(color='indigo') mdi-content-save-move-outline v-list-item-avatar(size='24'): v-icon(color='indigo') mdi-content-save-move-outline
v-list-item-content v-list-item-content
@ -197,6 +200,7 @@
page-selector(mode='create', v-model='newPageModal', :open-handler='pageNewCreate', :locale='locale') page-selector(mode='create', v-model='newPageModal', :open-handler='pageNewCreate', :locale='locale')
page-selector(mode='move', v-model='movePageModal', :open-handler='pageMoveRename', :path='path', :locale='locale') page-selector(mode='move', v-model='movePageModal', :open-handler='pageMoveRename', :path='path', :locale='locale')
page-selector(mode='create', v-model='duplicateOpts.modal', :open-handler='pageDuplicateHandle', :path='duplicateOpts.path', :locale='duplicateOpts.locale')
page-delete(v-model='deletePageModal', v-if='path && path.length') page-delete(v-model='deletePageModal', v-if='path && path.length')
.nav-header-dev(v-if='isDevMode') .nav-header-dev(v-if='isDevMode')
@ -238,7 +242,12 @@ export default {
movePageModal: false, movePageModal: false,
deletePageModal: false, deletePageModal: false,
locales: siteLangs, locales: siteLangs,
isDevMode: false isDevMode: false,
duplicateOpts: {
locale: 'en',
path: 'new-page',
modal: false
}
} }
}, },
computed: { computed: {
@ -298,6 +307,9 @@ export default {
this.$root.$on('pageMove', () => { this.$root.$on('pageMove', () => {
this.pageMove() this.pageMove()
}) })
this.$root.$on('pageDuplicate', () => {
this.pageDuplicate()
})
this.$root.$on('pageDelete', () => { this.$root.$on('pageDelete', () => {
this.pageDelete() this.pageDelete()
}) })
@ -346,6 +358,17 @@ export default {
pageSource () { pageSource () {
window.location.assign(`/s/${this.locale}/${this.path}`) window.location.assign(`/s/${this.locale}/${this.path}`)
}, },
pageDuplicate () {
const pathParts = this.path.split('/')
this.duplicateOpts = {
locale: this.locale,
path: (pathParts.length > 1) ? _.initial(pathParts).join('/') + `/new-page` : `new-page`,
modal: true
}
},
pageDuplicateHandle ({ locale, path }) {
window.location.assign(`/e/${locale}/${path}?from=${this.$store.get('page/id')}`)
},
pageMove () { pageMove () {
this.movePageModal = true this.movePageModal = true
}, },

@ -173,7 +173,7 @@
@click='pageHistory' @click='pageHistory'
) )
v-icon(size='20') mdi-history v-icon(size='20') mdi-history
span History span {{$t('common:header.history')}}
v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl') v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl')
template(v-slot:activator='{ on }') template(v-slot:activator='{ on }')
v-btn( v-btn(
@ -185,7 +185,19 @@
@click='pageSource' @click='pageSource'
) )
v-icon(size='20') mdi-code-tags v-icon(size='20') mdi-code-tags
span View Source span {{$t('common:header.viewSource')}}
v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl')
template(v-slot:activator='{ on }')
v-btn(
fab
small
color='white'
light
v-on='on'
@click='pageDuplicate'
)
v-icon(size='20') mdi-content-duplicate
span {{$t('common:header.duplicate')}}
v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl') v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl')
template(v-slot:activator='{ on }') template(v-slot:activator='{ on }')
v-btn( v-btn(
@ -197,7 +209,7 @@
@click='pageMove' @click='pageMove'
) )
v-icon(size='20') mdi-content-save-move-outline v-icon(size='20') mdi-content-save-move-outline
span Move / Rename span {{$t('common:header.move')}}
v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl') v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl')
template(v-slot:activator='{ on }') template(v-slot:activator='{ on }')
v-btn( v-btn(
@ -209,7 +221,7 @@
@click='pageDelete' @click='pageDelete'
) )
v-icon(size='20') mdi-trash-can-outline v-icon(size='20') mdi-trash-can-outline
span Delete span {{$t('common:header.delete')}}
span {{$t('common:page.editPage')}} span {{$t('common:page.editPage')}}
.contents(ref='container') .contents(ref='container')
slot(name='contents') slot(name='contents')
@ -458,6 +470,9 @@ export default {
pageSource () { pageSource () {
this.$root.$emit('pageSource') this.$root.$emit('pageSource')
}, },
pageDuplicate () {
this.$root.$emit('pageDuplicate')
},
pageMove () { pageMove () {
this.$root.$emit('pageMove') this.$root.$emit('pageMove')
}, },

Loading…
Cancel
Save