mirror of
https://github.com/documize/community.git
synced 2025-07-20 13:49:42 +02:00
implemented move content to another document
This commit is contained in:
parent
07ee2248d4
commit
b5a595e305
9 changed files with 105 additions and 19 deletions
|
@ -78,6 +78,10 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||||
this.attrs.onCopyPage(pageId, documentId);
|
this.attrs.onCopyPage(pageId, documentId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onMovePage(pageId, documentId) {
|
||||||
|
this.attrs.onMovePage(pageId, documentId);
|
||||||
|
},
|
||||||
|
|
||||||
onDeletePage(id, deleteChildren) {
|
onDeletePage(id, deleteChildren) {
|
||||||
let page = this.get('pages').findBy("id", id);
|
let page = this.get('pages').findBy("id", id);
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,13 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
let id = this.get('page.id');
|
let id = this.get('page.id');
|
||||||
return `delete-page-button-${id}`;
|
return `delete-page-button-${id}`;
|
||||||
}),
|
}),
|
||||||
saveAsTarget: computed('page', function () {
|
publishButtonId: computed('page', function () {
|
||||||
let id = this.get('page.id');
|
let id = this.get('page.id');
|
||||||
return `saveas-page-button-${id}`;
|
return `publish-button-${id}`;
|
||||||
}),
|
}),
|
||||||
saveAsDialogId: computed('page', function () {
|
publishDialogId: computed('page', function () {
|
||||||
let id = this.get('page.id');
|
let id = this.get('page.id');
|
||||||
return `save-as-dialog-${id}`;
|
return `publish-dialog-${id}`;
|
||||||
}),
|
}),
|
||||||
blockTitleId: computed('page', function () {
|
blockTitleId: computed('page', function () {
|
||||||
let id = this.get('page.id');
|
let id = this.get('page.id');
|
||||||
|
@ -63,6 +63,14 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
let id = this.get('page.id');
|
let id = this.get('page.id');
|
||||||
return `copy-dialog-${id}`;
|
return `copy-dialog-${id}`;
|
||||||
}),
|
}),
|
||||||
|
moveButtonId: computed('page', function () {
|
||||||
|
let id = this.get('page.id');
|
||||||
|
return `move-page-button-${id}`;
|
||||||
|
}),
|
||||||
|
moveDialogId: computed('page', function () {
|
||||||
|
let id = this.get('page.id');
|
||||||
|
return `move-dialog-${id}`;
|
||||||
|
}),
|
||||||
|
|
||||||
didRender() {
|
didRender() {
|
||||||
if (this.get('isEditor')) {
|
if (this.get('isEditor')) {
|
||||||
|
@ -82,7 +90,13 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onMenuOpen() {
|
onMenuOpen() {
|
||||||
if ($('#' + this.get('saveAsDialogId')).is( ":visible" )) {
|
if ($('#' + this.get('publishDialogId')).is( ":visible" )) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($('#' + this.get('copyDialogId')).is( ":visible" )) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($('#' + this.get('moveDialogId')).is( ":visible" )) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +151,7 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Copy action
|
// Copy/move actions
|
||||||
onCopyDialogOpen() {
|
onCopyDialogOpen() {
|
||||||
// Fetch document targets once.
|
// Fetch document targets once.
|
||||||
if (this.get('documentList').length > 0) {
|
if (this.get('documentList').length > 0) {
|
||||||
|
@ -156,13 +170,34 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onCopyPage(page) {
|
onCopyPage(page) {
|
||||||
|
// can't proceed if no data
|
||||||
|
if (this.get('documentList'.length) === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let targetDocumentId = this.get('document.id');
|
let targetDocumentId = this.get('document.id');
|
||||||
if (is.not.null(this.get('selectedDocument'))) {
|
if (is.not.null(this.get('selectedDocument'))) {
|
||||||
targetDocumentId = this.get('selectedDocument.id')
|
targetDocumentId = this.get('selectedDocument.id');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.attrs.onCopyPage(page.get('id'), targetDocumentId);
|
this.attrs.onCopyPage(page.get('id'), targetDocumentId);
|
||||||
return true;
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
onMovePage(page) {
|
||||||
|
// can't proceed if no data
|
||||||
|
if (this.get('documentListOthers.length') === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is.null(this.get('selectedDocument'))) {
|
||||||
|
this.set('selectedDocument', this.get('documentListOthers')[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let targetDocumentId = this.get('selectedDocument.id');
|
||||||
|
|
||||||
|
this.attrs.onMovePage(page.get('id'), targetDocumentId);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -94,7 +94,7 @@ export default Ember.Controller.extend(NotifierMixin, {
|
||||||
|
|
||||||
onCopyPage(pageId, targetDocumentId) {
|
onCopyPage(pageId, targetDocumentId) {
|
||||||
let documentId = this.get('model.document.id');
|
let documentId = this.get('model.document.id');
|
||||||
this.get('documentService').copyPage(documentId, pageId, targetDocumentId).then((page) => {
|
this.get('documentService').copyPage(documentId, pageId, targetDocumentId).then(() => {
|
||||||
this.showNotification("Copied");
|
this.showNotification("Copied");
|
||||||
|
|
||||||
// refresh data if copied to same document
|
// refresh data if copied to same document
|
||||||
|
@ -104,6 +104,16 @@ export default Ember.Controller.extend(NotifierMixin, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onMovePage(pageId, targetDocumentId) {
|
||||||
|
let documentId = this.get('model.document.id');
|
||||||
|
|
||||||
|
this.get('documentService').copyPage(documentId, pageId, targetDocumentId).then(() => {
|
||||||
|
this.showNotification("Moved");
|
||||||
|
|
||||||
|
this.send('onPageDeleted', { id: pageId, children: false });
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
onPageDeleted(deletePage) {
|
onPageDeleted(deletePage) {
|
||||||
let documentId = this.get('model.document.id');
|
let documentId = this.get('model.document.id');
|
||||||
let pages = this.get('model.pages');
|
let pages = this.get('model.pages');
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
{{document/document-view document=model.document links=model.links allPages=model.allPages tabs=model.tabs pages=model.pages folder=model.folder folders=model.folders isEditor=model.isEditor
|
{{document/document-view document=model.document links=model.links allPages=model.allPages tabs=model.tabs pages=model.pages folder=model.folder folders=model.folders isEditor=model.isEditor
|
||||||
gotoPage=(action 'gotoPage') onAddBlock=(action 'onAddBlock') onCopyPage=(action 'onCopyPage') onDeletePage=(action 'onPageDeleted')}}
|
gotoPage=(action 'gotoPage') onAddBlock=(action 'onAddBlock') onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onPageDeleted')}}
|
||||||
|
|
|
@ -325,6 +325,16 @@ export default Ember.Service.extend({
|
||||||
let data = this.get('store').normalize('page', response);
|
let data = this.get('store').normalize('page', response);
|
||||||
return this.get('store').push(data);
|
return this.get('store').push(data);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// Move existing page to different document.
|
||||||
|
movePage(documentId, pageId, targetDocumentId) {
|
||||||
|
return this.get('ajax').request(`documents/${documentId}/pages/${pageId}/move/${targetDocumentId}`, {
|
||||||
|
method: 'POST'
|
||||||
|
}).then((response) => {
|
||||||
|
let data = this.get('store').normalize('page', response);
|
||||||
|
return this.get('store').push(data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,13 @@
|
||||||
> .is-a-page {
|
> .is-a-page {
|
||||||
.page-title {
|
.page-title {
|
||||||
> .page-toolbar {
|
> .page-toolbar {
|
||||||
opacity: 0.5;
|
// opacity: 0.5;
|
||||||
|
opacity: 0;
|
||||||
@extend .transition-all;
|
@extend .transition-all;
|
||||||
|
|
||||||
&:hover {
|
// &:hover {
|
||||||
opacity: 1;
|
// opacity: 1;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<div class="wysiwyg">
|
<div class="wysiwyg">
|
||||||
<div id="page-{{ page.id }}" class="is-a-page" data-id="{{ page.id }}" data-type="{{ page.contentType }}">
|
<div id="page-{{ page.id }}" class="is-a-page" data-id="{{ page.id }}" data-type="{{ page.contentType }}">
|
||||||
{{document/page-heading tagName=page.tagName document=document folder=folder page=page isEditor=isEditor
|
{{document/page-heading tagName=page.tagName document=document folder=folder page=page isEditor=isEditor
|
||||||
onAddBlock=(action 'onAddBlock') onCopyPage=(action 'onCopyPage') onDeletePage=(action 'onDeletePage')}}
|
onAddBlock=(action 'onAddBlock') onCopyPage=(action 'onCopyPage') onMovePage=(action 'onMovePage') onDeletePage=(action 'onDeletePage')}}
|
||||||
{{section/base-renderer page=page}}
|
{{section/base-renderer page=page}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
{{#dropdown-menu target=menuTarget position="bottom right" open="click" onOpenCallback=(action 'onMenuOpen') onCloseCallback=(action 'onMenuOpen')}}
|
{{#dropdown-menu target=menuTarget position="bottom right" open="click" onOpenCallback=(action 'onMenuOpen') onCloseCallback=(action 'onMenuOpen')}}
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
<li class="item" id={{copyButtonId}}>Copy</li>
|
<li class="item" id={{copyButtonId}}>Copy</li>
|
||||||
<li class="item">Move</li>
|
<li class="item" id={{moveButtonId}}>Move</li>
|
||||||
<li class="item" id="saveas-page-button-{{page.id}}">Publish</li>
|
<li class="item" id={{publishButtonId}}>Publish</li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li class="item danger" id={{deleteButtonId}}>Delete</li>
|
<li class="item danger" id={{deleteButtonId}}>Delete</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<label for="{{checkId}}"> Delete child pages</label>
|
<label for="{{checkId}}"> Delete child pages</label>
|
||||||
</p>
|
</p>
|
||||||
{{/dropdown-dialog}}
|
{{/dropdown-dialog}}
|
||||||
{{#dropdown-dialog id=saveAsDialogId target=saveAsTarget position="bottom right" button="Publish" color="flat-green" focusOn=blockTitleId onAction=(action 'onAddBlock' page)}}
|
{{#dropdown-dialog id=publishDialogId target=publishButtonId position="bottom right" button="Publish" color="flat-green" focusOn=blockTitleId onAction=(action 'onAddBlock' page)}}
|
||||||
<div class="form-header">
|
<div class="form-header">
|
||||||
<div class="tip">
|
<div class="tip">
|
||||||
<span class="bold">{{folder.name}}:</span> Content Block
|
<span class="bold">{{folder.name}}:</span> Content Block
|
||||||
|
@ -58,6 +58,18 @@
|
||||||
<div class="tip">Select where the content should be copied to</div>
|
<div class="tip">Select where the content should be copied to</div>
|
||||||
{{ui-select content=documentList action=(action 'onTargetChange') optionValuePath="id" optionLabelPath="name" selection=document}}
|
{{ui-select content=documentList action=(action 'onTargetChange') optionValuePath="id" optionLabelPath="name" selection=document}}
|
||||||
</div>
|
</div>
|
||||||
|
{{/dropdown-dialog}}
|
||||||
|
{{#dropdown-dialog id=moveDialogId target=moveButtonId position="bottom right" button="Move" color="flat-green" onOpenCallback=(action 'onCopyDialogOpen') onAction=(action 'onMovePage' page)}}
|
||||||
|
<div class="form-header">
|
||||||
|
<div class="tip">
|
||||||
|
<span class="bold">move:</span> {{page.title}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Target</label>
|
||||||
|
<div class="tip">Select where the content should be moved to</div>
|
||||||
|
{{ui-select content=documentListOthers action=(action 'onTargetChange') optionValuePath="id" optionLabelPath="name"}}
|
||||||
|
</div>
|
||||||
{{/dropdown-dialog}}
|
{{/dropdown-dialog}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -496,3 +496,17 @@ func (p *Persister) DeletePageRevisions(pageID string) (rows int64, err error) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNextPageSequence returns the next sequence numbner to use for a page in given document.
|
||||||
|
func (p *Persister) GetNextPageSequence(documentID string) (maxSeq float64, err error) {
|
||||||
|
row := Db.QueryRow("SELECT max(sequence) FROM page WHERE orgid=? AND documentid=? AND pagetype='section'", p.Context.OrgID, documentID)
|
||||||
|
|
||||||
|
err = row.Scan(&maxSeq)
|
||||||
|
if err != nil {
|
||||||
|
maxSeq = 2048
|
||||||
|
}
|
||||||
|
|
||||||
|
maxSeq = maxSeq * 2
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue