mirror of
https://github.com/documize/community.git
synced 2025-07-23 07:09:43 +02:00
Export single or multiple documents
This commit is contained in:
parent
cf0b06923d
commit
def01b6265
8 changed files with 74 additions and 13 deletions
|
@ -45,7 +45,6 @@ func BuildExport(ctx domain.RequestContext, s domain.Store, spec exportSpec) (ht
|
|||
|
||||
switch spec.FilterType {
|
||||
case "space":
|
||||
|
||||
for _, spaceID := range spec.Data {
|
||||
t, c, e := exportSpace(ctx, s, spaceID)
|
||||
if e == nil {
|
||||
|
@ -55,7 +54,6 @@ func BuildExport(ctx domain.RequestContext, s domain.Store, spec exportSpec) (ht
|
|||
}
|
||||
|
||||
case "category":
|
||||
|
||||
t, c, e := exportCategory(ctx, s, spec.SpaceID, spec.Data)
|
||||
if e == nil {
|
||||
content.WriteString(c)
|
||||
|
@ -63,7 +61,6 @@ func BuildExport(ctx domain.RequestContext, s domain.Store, spec exportSpec) (ht
|
|||
}
|
||||
|
||||
case "document":
|
||||
|
||||
t, c, e := exportDocument(ctx, s, spec.SpaceID, spec.Data)
|
||||
if e == nil {
|
||||
content.WriteString(c)
|
||||
|
@ -233,14 +230,17 @@ func exportDocument(ctx domain.RequestContext, s domain.Store, spaceID string, d
|
|||
// Turn each document into TOC entry and HTML content export
|
||||
b := strings.Builder{}
|
||||
for _, documentID := range document {
|
||||
fmt.Println(documentID)
|
||||
for _, d := range docs {
|
||||
if d.RefID == documentID && d.Lifecycle == workflow.LifecycleLive {
|
||||
docHTML, e := processDocument(ctx, s, d.RefID)
|
||||
if e == nil && len(docHTML) > 0 {
|
||||
toc = append(toc, exportTOC{ID: d.RefID, Entry: d.Title})
|
||||
b.WriteString(docHTML)
|
||||
} else {
|
||||
return toc, b.String(), err
|
||||
if d.RefID == documentID {
|
||||
if permission.CanViewDocument(ctx, s, d.RefID) {
|
||||
docHTML, e := processDocument(ctx, s, d.RefID)
|
||||
if e == nil && len(docHTML) > 0 {
|
||||
toc = append(toc, exportTOC{ID: d.RefID, Entry: d.Title})
|
||||
b.WriteString(docHTML)
|
||||
} else {
|
||||
return toc, b.String(), err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,16 @@ export default Component.extend(TooltipMixin, {
|
|||
return true;
|
||||
},
|
||||
|
||||
onExport() {
|
||||
let list = this.get('selectedDocuments');
|
||||
this.set('selectedDocuments', A([]));
|
||||
|
||||
let cb = this.get('onExportDocument');
|
||||
cb(list);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
selectDocument(documentId) {
|
||||
let doc = this.get('documents').findBy('id', documentId);
|
||||
let list = this.get('selectedDocuments');
|
||||
|
|
|
@ -14,14 +14,17 @@ import { inject as service } from '@ember/service';
|
|||
import AuthMixin from '../../mixins/auth';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
import ModalMixin from '../../mixins/modal';
|
||||
import Notifier from '../../mixins/notifier';
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
||||
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
|
||||
store: service(),
|
||||
spaceSvc: service('folder'),
|
||||
session: service(),
|
||||
appMeta: service(),
|
||||
pinned: service(),
|
||||
browserSvc: service('browser'),
|
||||
documentSvc: service('document'),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
@ -130,5 +133,22 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
|||
|
||||
return true;
|
||||
},
|
||||
|
||||
onExport() {
|
||||
this.showWait();
|
||||
|
||||
let spec = {
|
||||
spaceId: this.get('document.folderId'),
|
||||
data: [],
|
||||
filterType: 'document',
|
||||
};
|
||||
|
||||
spec.data.push(this.get('document.id'));
|
||||
|
||||
this.get('documentSvc').export(spec).then((htmlExport) => {
|
||||
this.get('browserSvc').downloadFile(htmlExport, this.get('document.slug') + '.html');
|
||||
this.showDone();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,9 +16,10 @@ import { inject as service } from '@ember/service';
|
|||
import TooltipMixin from '../../mixins/tooltip';
|
||||
import ModalMixin from '../../mixins/modal';
|
||||
import AuthMixin from '../../mixins/auth';
|
||||
import Notifier from '../../mixins/notifier';
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
||||
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
|
||||
spaceService: service('folder'),
|
||||
localStorage: service(),
|
||||
templateService: service('template'),
|
||||
|
@ -307,11 +308,13 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
|||
},
|
||||
|
||||
onExport() {
|
||||
this.showWait();
|
||||
|
||||
let spec = {
|
||||
spaceId: this.get('space.id'),
|
||||
data: [],
|
||||
filterType: '',
|
||||
}
|
||||
};
|
||||
|
||||
let cats = this.get('categories');
|
||||
cats.forEach((cat) => {
|
||||
|
@ -327,6 +330,7 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
|||
|
||||
this.get('documentSvc').export(spec).then((htmlExport) => {
|
||||
this.get('browserSvc').downloadFile(htmlExport, this.get('space.slug') + '.html');
|
||||
this.showDone();
|
||||
});
|
||||
|
||||
this.modalClose("#space-export-modal");
|
||||
|
|
|
@ -18,6 +18,8 @@ export default Controller.extend(NotifierMixin, {
|
|||
documentService: service('document'),
|
||||
folderService: service('folder'),
|
||||
localStorage: service('localStorage'),
|
||||
browserSvc: service('browser'),
|
||||
documentSvc: service('document'),
|
||||
queryParams: ['category'],
|
||||
category: '',
|
||||
filteredDocs: null,
|
||||
|
@ -71,6 +73,21 @@ export default Controller.extend(NotifierMixin, {
|
|||
});
|
||||
},
|
||||
|
||||
onExportDocument(documents) {
|
||||
this.showWait();
|
||||
|
||||
let spec = {
|
||||
spaceId: this.get('model.folder.id'),
|
||||
data: documents,
|
||||
filterType: 'document',
|
||||
};
|
||||
|
||||
this.get('documentSvc').export(spec).then((htmlExport) => {
|
||||
this.get('browserSvc').downloadFile(htmlExport, this.get('model.folder.slug') + '.html');
|
||||
this.showDone();
|
||||
});
|
||||
},
|
||||
|
||||
onFiltered(docs) {
|
||||
this.set('filteredDocs', docs);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
space=model.folder
|
||||
templates=model.templates
|
||||
permissions=model.permissions
|
||||
onExportDocument=(action 'onExportDocument')
|
||||
onDeleteDocument=(action 'onDeleteDocument')
|
||||
onMoveDocument=(action 'onMoveDocument')}}
|
||||
{{/layout/middle-zone-content}}
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
</div>
|
||||
{{#if document.selected}}
|
||||
<div class="actions">
|
||||
<div class="move-documents-button button-icon-green button-icon-small align-middle" {{action 'onExport'}} data-toggle="tooltip" data-placement="top" title="Export as HTML">
|
||||
<i class="material-icons">import_export</i>
|
||||
</div>
|
||||
<div class="button-icon-gap" />
|
||||
{{#if permissions.documentMove}}
|
||||
<div class="move-documents-button button-icon-green button-icon-small align-middle" {{action 'onShowMoveDocuments'}} data-toggle="tooltip" data-placement="top" title="Move">
|
||||
<i class="material-icons">compare_arrows</i>
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
</div>
|
||||
<div class="button-icon-gap" />
|
||||
|
||||
<div id="space-export-button" class="button-icon-danger align-middle" data-toggle="tooltip" data-placement="top" title="Export as HTML" {{action 'onExport'}}>
|
||||
<i class="material-icons">import_export</i>
|
||||
</div>
|
||||
<div class="button-icon-gap" />
|
||||
|
||||
{{#if pinState.isPinned}}
|
||||
<div id="document-pin-button" class="button-icon-gold align-middle" data-toggle="tooltip" data-placement="top" title="Remove favorite" {{action 'onUnpin'}}>
|
||||
<i class="material-icons">star</i>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue