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 {
|
switch spec.FilterType {
|
||||||
case "space":
|
case "space":
|
||||||
|
|
||||||
for _, spaceID := range spec.Data {
|
for _, spaceID := range spec.Data {
|
||||||
t, c, e := exportSpace(ctx, s, spaceID)
|
t, c, e := exportSpace(ctx, s, spaceID)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
|
@ -55,7 +54,6 @@ func BuildExport(ctx domain.RequestContext, s domain.Store, spec exportSpec) (ht
|
||||||
}
|
}
|
||||||
|
|
||||||
case "category":
|
case "category":
|
||||||
|
|
||||||
t, c, e := exportCategory(ctx, s, spec.SpaceID, spec.Data)
|
t, c, e := exportCategory(ctx, s, spec.SpaceID, spec.Data)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
content.WriteString(c)
|
content.WriteString(c)
|
||||||
|
@ -63,7 +61,6 @@ func BuildExport(ctx domain.RequestContext, s domain.Store, spec exportSpec) (ht
|
||||||
}
|
}
|
||||||
|
|
||||||
case "document":
|
case "document":
|
||||||
|
|
||||||
t, c, e := exportDocument(ctx, s, spec.SpaceID, spec.Data)
|
t, c, e := exportDocument(ctx, s, spec.SpaceID, spec.Data)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
content.WriteString(c)
|
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
|
// Turn each document into TOC entry and HTML content export
|
||||||
b := strings.Builder{}
|
b := strings.Builder{}
|
||||||
for _, documentID := range document {
|
for _, documentID := range document {
|
||||||
|
fmt.Println(documentID)
|
||||||
for _, d := range docs {
|
for _, d := range docs {
|
||||||
if d.RefID == documentID && d.Lifecycle == workflow.LifecycleLive {
|
if d.RefID == documentID {
|
||||||
docHTML, e := processDocument(ctx, s, d.RefID)
|
if permission.CanViewDocument(ctx, s, d.RefID) {
|
||||||
if e == nil && len(docHTML) > 0 {
|
docHTML, e := processDocument(ctx, s, d.RefID)
|
||||||
toc = append(toc, exportTOC{ID: d.RefID, Entry: d.Title})
|
if e == nil && len(docHTML) > 0 {
|
||||||
b.WriteString(docHTML)
|
toc = append(toc, exportTOC{ID: d.RefID, Entry: d.Title})
|
||||||
} else {
|
b.WriteString(docHTML)
|
||||||
return toc, b.String(), err
|
} else {
|
||||||
|
return toc, b.String(), err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,16 @@ export default Component.extend(TooltipMixin, {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onExport() {
|
||||||
|
let list = this.get('selectedDocuments');
|
||||||
|
this.set('selectedDocuments', A([]));
|
||||||
|
|
||||||
|
let cb = this.get('onExportDocument');
|
||||||
|
cb(list);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
selectDocument(documentId) {
|
selectDocument(documentId) {
|
||||||
let doc = this.get('documents').findBy('id', documentId);
|
let doc = this.get('documents').findBy('id', documentId);
|
||||||
let list = this.get('selectedDocuments');
|
let list = this.get('selectedDocuments');
|
||||||
|
|
|
@ -14,14 +14,17 @@ import { inject as service } from '@ember/service';
|
||||||
import AuthMixin from '../../mixins/auth';
|
import AuthMixin from '../../mixins/auth';
|
||||||
import TooltipMixin from '../../mixins/tooltip';
|
import TooltipMixin from '../../mixins/tooltip';
|
||||||
import ModalMixin from '../../mixins/modal';
|
import ModalMixin from '../../mixins/modal';
|
||||||
|
import Notifier from '../../mixins/notifier';
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
|
|
||||||
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
|
||||||
store: service(),
|
store: service(),
|
||||||
spaceSvc: service('folder'),
|
spaceSvc: service('folder'),
|
||||||
session: service(),
|
session: service(),
|
||||||
appMeta: service(),
|
appMeta: service(),
|
||||||
pinned: service(),
|
pinned: service(),
|
||||||
|
browserSvc: service('browser'),
|
||||||
|
documentSvc: service('document'),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
@ -130,5 +133,22 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
||||||
|
|
||||||
return true;
|
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 TooltipMixin from '../../mixins/tooltip';
|
||||||
import ModalMixin from '../../mixins/modal';
|
import ModalMixin from '../../mixins/modal';
|
||||||
import AuthMixin from '../../mixins/auth';
|
import AuthMixin from '../../mixins/auth';
|
||||||
|
import Notifier from '../../mixins/notifier';
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
|
|
||||||
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, Notifier, {
|
||||||
spaceService: service('folder'),
|
spaceService: service('folder'),
|
||||||
localStorage: service(),
|
localStorage: service(),
|
||||||
templateService: service('template'),
|
templateService: service('template'),
|
||||||
|
@ -307,11 +308,13 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onExport() {
|
onExport() {
|
||||||
|
this.showWait();
|
||||||
|
|
||||||
let spec = {
|
let spec = {
|
||||||
spaceId: this.get('space.id'),
|
spaceId: this.get('space.id'),
|
||||||
data: [],
|
data: [],
|
||||||
filterType: '',
|
filterType: '',
|
||||||
}
|
};
|
||||||
|
|
||||||
let cats = this.get('categories');
|
let cats = this.get('categories');
|
||||||
cats.forEach((cat) => {
|
cats.forEach((cat) => {
|
||||||
|
@ -327,6 +330,7 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
||||||
|
|
||||||
this.get('documentSvc').export(spec).then((htmlExport) => {
|
this.get('documentSvc').export(spec).then((htmlExport) => {
|
||||||
this.get('browserSvc').downloadFile(htmlExport, this.get('space.slug') + '.html');
|
this.get('browserSvc').downloadFile(htmlExport, this.get('space.slug') + '.html');
|
||||||
|
this.showDone();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.modalClose("#space-export-modal");
|
this.modalClose("#space-export-modal");
|
||||||
|
|
|
@ -18,6 +18,8 @@ export default Controller.extend(NotifierMixin, {
|
||||||
documentService: service('document'),
|
documentService: service('document'),
|
||||||
folderService: service('folder'),
|
folderService: service('folder'),
|
||||||
localStorage: service('localStorage'),
|
localStorage: service('localStorage'),
|
||||||
|
browserSvc: service('browser'),
|
||||||
|
documentSvc: service('document'),
|
||||||
queryParams: ['category'],
|
queryParams: ['category'],
|
||||||
category: '',
|
category: '',
|
||||||
filteredDocs: null,
|
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) {
|
onFiltered(docs) {
|
||||||
this.set('filteredDocs', docs);
|
this.set('filteredDocs', docs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
space=model.folder
|
space=model.folder
|
||||||
templates=model.templates
|
templates=model.templates
|
||||||
permissions=model.permissions
|
permissions=model.permissions
|
||||||
|
onExportDocument=(action 'onExportDocument')
|
||||||
onDeleteDocument=(action 'onDeleteDocument')
|
onDeleteDocument=(action 'onDeleteDocument')
|
||||||
onMoveDocument=(action 'onMoveDocument')}}
|
onMoveDocument=(action 'onMoveDocument')}}
|
||||||
{{/layout/middle-zone-content}}
|
{{/layout/middle-zone-content}}
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
</div>
|
</div>
|
||||||
{{#if document.selected}}
|
{{#if document.selected}}
|
||||||
<div class="actions">
|
<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}}
|
{{#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">
|
<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>
|
<i class="material-icons">compare_arrows</i>
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="button-icon-gap" />
|
<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}}
|
{{#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'}}>
|
<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>
|
<i class="material-icons">star</i>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue