From 951ebb6b61547bb148185f110d277b422018a7b4 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 29 Mar 2020 17:48:45 -0400 Subject: [PATCH] feat: duplicate page --- client/components/common/nav-header.vue | 25 ++++++++++++++++++++++- client/themes/default/components/page.vue | 23 +++++++++++++++++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/client/components/common/nav-header.vue b/client/components/common/nav-header.vue index f9d90510..b613e160 100644 --- a/client/components/common/nav-header.vue +++ b/client/components/common/nav-header.vue @@ -132,6 +132,9 @@ 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-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-avatar(size='24'): v-icon(color='indigo') mdi-content-save-move-outline v-list-item-content @@ -197,6 +200,7 @@ 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='create', v-model='duplicateOpts.modal', :open-handler='pageDuplicateHandle', :path='duplicateOpts.path', :locale='duplicateOpts.locale') page-delete(v-model='deletePageModal', v-if='path && path.length') .nav-header-dev(v-if='isDevMode') @@ -238,7 +242,12 @@ export default { movePageModal: false, deletePageModal: false, locales: siteLangs, - isDevMode: false + isDevMode: false, + duplicateOpts: { + locale: 'en', + path: 'new-page', + modal: false + } } }, computed: { @@ -298,6 +307,9 @@ export default { this.$root.$on('pageMove', () => { this.pageMove() }) + this.$root.$on('pageDuplicate', () => { + this.pageDuplicate() + }) this.$root.$on('pageDelete', () => { this.pageDelete() }) @@ -346,6 +358,17 @@ export default { pageSource () { 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 () { this.movePageModal = true }, diff --git a/client/themes/default/components/page.vue b/client/themes/default/components/page.vue index 0e8fedc0..0d6288ef 100644 --- a/client/themes/default/components/page.vue +++ b/client/themes/default/components/page.vue @@ -173,7 +173,7 @@ @click='pageHistory' ) v-icon(size='20') mdi-history - span History + span {{$t('common:header.history')}} v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl') template(v-slot:activator='{ on }') v-btn( @@ -185,7 +185,19 @@ @click='pageSource' ) 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') template(v-slot:activator='{ on }') v-btn( @@ -197,7 +209,7 @@ @click='pageMove' ) 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') template(v-slot:activator='{ on }') v-btn( @@ -209,7 +221,7 @@ @click='pageDelete' ) v-icon(size='20') mdi-trash-can-outline - span Delete + span {{$t('common:header.delete')}} span {{$t('common:page.editPage')}} .contents(ref='container') slot(name='contents') @@ -458,6 +470,9 @@ export default { pageSource () { this.$root.$emit('pageSource') }, + pageDuplicate () { + this.$root.$emit('pageDuplicate') + }, pageMove () { this.$root.$emit('pageMove') },