mirror of
https://github.com/documize/community.git
synced 2025-08-04 21:15:24 +02:00
Provide copy document option
Duplicates entire document tree into a new document (same space).
This commit is contained in:
parent
b75969ae90
commit
ec8d5c78e2
10 changed files with 304 additions and 12 deletions
|
@ -48,6 +48,7 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
|
|||
this.get('permissions.documentEdit')) return true;
|
||||
|
||||
}),
|
||||
duplicateName: '',
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
@ -57,7 +58,7 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
|
|||
pinId: '',
|
||||
newName: ''
|
||||
};
|
||||
|
||||
|
||||
this.saveTemplate = {
|
||||
name: '',
|
||||
description: ''
|
||||
|
@ -88,6 +89,10 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
|
|||
this.modalOpen("#document-template-modal", {show:true}, "#new-template-name");
|
||||
},
|
||||
|
||||
onShowDuplicateModal() {
|
||||
this.modalOpen("#document-duplicate-modal", {show:true}, "#duplicate-name");
|
||||
},
|
||||
|
||||
onShowDeleteModal() {
|
||||
this.modalOpen("#document-delete-modal", {show:true});
|
||||
},
|
||||
|
@ -183,6 +188,25 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
|
|||
return true;
|
||||
},
|
||||
|
||||
onDuplicate() {
|
||||
let name = this.get('duplicateName');
|
||||
|
||||
if (_.isEmpty(name)) {
|
||||
$("#duplicate-name").addClass("is-invalid").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
$("#duplicate-name").removeClass("is-invalid");
|
||||
|
||||
this.set('duplicateName', '');
|
||||
|
||||
this.get('onDuplicate')(name);
|
||||
|
||||
this.modalClose('#document-duplicate-modal');
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
onExport() {
|
||||
let spec = {
|
||||
spaceId: this.get('document.spaceId'),
|
||||
|
|
|
@ -189,6 +189,12 @@ export default Controller.extend(Notifier, {
|
|||
});
|
||||
},
|
||||
|
||||
onDuplicate(name) {
|
||||
this.get('documentService').duplicate(this.get('folder.id'), this.get('document.id'), name).then(() => {
|
||||
this.notifySuccess('Duplicated');
|
||||
});
|
||||
},
|
||||
|
||||
onPageSequenceChange(currentPageId, changes) {
|
||||
this.set('currentPageId', currentPageId);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
refresh=(action "refresh")
|
||||
onSaveTemplate=(action "onSaveTemplate")
|
||||
onSaveDocument=(action "onSaveDocument")
|
||||
onDuplicate=(action "onDuplicate")
|
||||
onDocumentDelete=(action "onDocumentDelete")}}
|
||||
</div>
|
||||
</Layout::MasterToolbar>
|
||||
|
@ -63,7 +64,7 @@
|
|||
|
||||
<Ui::UiSpacer @size="300" />
|
||||
|
||||
<div class="document-meta {{if permissions.documentEdit "cursor-pointer"}}" {{action "onEditMeta"}}>
|
||||
<div class="document-meta">
|
||||
<div class="document-heading">
|
||||
<h1 class="name">{{document.name}}</h1>
|
||||
<h2 class="desc">{{document.excerpt}}</h2>
|
||||
|
|
|
@ -78,6 +78,21 @@ export default Service.extend({
|
|||
});
|
||||
},
|
||||
|
||||
|
||||
// Duplicate creates a copy.
|
||||
duplicate(spaceId, docId, docName) {
|
||||
let data = {
|
||||
spaceId: spaceId,
|
||||
documentId: docId,
|
||||
documentName: docName
|
||||
};
|
||||
|
||||
return this.get('ajax').request(`document/duplicate`, {
|
||||
method: 'POST',
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
},
|
||||
|
||||
//**************************************************
|
||||
// Page
|
||||
//**************************************************
|
||||
|
|
|
@ -33,18 +33,17 @@
|
|||
<li class="item" {{action "onExport"}}>Download</li>
|
||||
{{#if permissions.documentAdd}}
|
||||
<li class="divider"/>
|
||||
<li class="item" {{action "onShowTemplateModal"}}>Publish template</li>
|
||||
<li class="item" {{action "onShowTemplateModal"}}>Template</li>
|
||||
<li class="item" {{action "onShowDuplicateModal"}}>Duplicate</li>
|
||||
{{/if}}
|
||||
{{#if permissions.documentDelete}}
|
||||
<li class="divider"/>
|
||||
<li class="item red" {{action "onShowDeleteModal"}}>Delete</li>
|
||||
{{/if}}
|
||||
|
||||
</ul>
|
||||
{{/attach-popover}}
|
||||
{{/ui/ui-toolbar-dropdown}}
|
||||
|
||||
|
||||
{{#if (or showActivity showRevisions)}}
|
||||
{{#ui/ui-toolbar-dropdown label="History" arrow=true}}
|
||||
{{#attach-popover class="ember-attacher-popper" hideOn="click clickout" showOn="click" isShown=false}}
|
||||
|
@ -129,3 +128,25 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="document-duplicate-modal" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">Duplicate</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={{action "onDuplicate"}}>
|
||||
<div class="form-group">
|
||||
<label for="duplicate-name">Name</label>
|
||||
{{input id="duplicate-name" value=duplicateName type="email" class="form-control mousetrap" placeholder="Name"}}
|
||||
<small class="form-text text-muted">Content will be duplicated within this space</small>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{ui/ui-button color=constants.Color.Gray light=true label=constants.Label.Cancel dismiss=true}}
|
||||
{{ui/ui-button-gap}}
|
||||
{{ui/ui-button color=constants.Color.Green light=true label=constants.Label.Duplicate onClick=(action "onDuplicate")}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue