mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
Complete PDF section type
This commit is contained in:
parent
7fde947a52
commit
b5cd378302
8 changed files with 98 additions and 4 deletions
|
@ -54,6 +54,9 @@ export default Component.extend({
|
|||
|
||||
setPDF() {
|
||||
let files = this.get('attachments');
|
||||
this.set('pdfName', '');
|
||||
this.set('pdfOption.fileId', '');
|
||||
|
||||
if (!_.isArray(files)) return;
|
||||
|
||||
for (let i=0; i < files.length; i++) {
|
||||
|
@ -84,7 +87,7 @@ export default Component.extend({
|
|||
let config = this.get('pdfOption');
|
||||
let page = this.get('page');
|
||||
let meta = this.get('meta');
|
||||
|
||||
|
||||
page.set('title', title);
|
||||
page.set('body', JSON.stringify(config));
|
||||
meta.set('config', JSON.stringify(config));
|
||||
|
|
|
@ -51,6 +51,10 @@ export default Component.extend({
|
|||
let orgId = this.get('appMeta.orgId');
|
||||
let fileId = this.get('pdfOption.fileId');
|
||||
|
||||
if (_.isEmpty(fileId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For authenticated users we send server auth token.
|
||||
let qry = '';
|
||||
if (this.get('session.hasSecureToken')) {
|
||||
|
|
|
@ -43,5 +43,19 @@ export default Controller.extend({
|
|||
{ queryParams: { currentPageId: page.get('id')}});
|
||||
});
|
||||
},
|
||||
|
||||
onAttachmentUpload() {
|
||||
this.get('documentService').getAttachments(this.get('model.document.id')).then((files) => {
|
||||
this.set('model.attachments', files);
|
||||
});
|
||||
},
|
||||
|
||||
onAttachmentDelete(attachmentId) {
|
||||
this.get('documentService').deleteAttachment(this.get('model.document.id'), attachmentId).then(() => {
|
||||
this.get('documentService').getAttachments(this.get('model.document.id')).then((files) => {
|
||||
this.set('attachments', files);
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
import { hash } from 'rsvp';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Route from '@ember/routing/route';
|
||||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default Route.extend(AuthenticatedRouteMixin, {
|
||||
documentService: service('document'),
|
||||
|
@ -27,6 +27,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
|
|||
permissions: this.get('folderService').get('permissions'),
|
||||
links: this.modelFor('document').links,
|
||||
sections: this.modelFor('document').sections,
|
||||
attachments: this.modelFor('document').attachments,
|
||||
page: this.get('documentService').getPage(this.modelFor('document').document.get('id'), params.page_id),
|
||||
meta: this.get('documentService').getPageMeta(this.modelFor('document').document.get('id'), params.page_id)
|
||||
});
|
||||
|
|
|
@ -9,6 +9,17 @@
|
|||
{{/layout/master-sidebar}}
|
||||
|
||||
{{#layout/master-content}}
|
||||
{{document/document-editor document=model.document folder=model.folder page=model.page meta=model.meta
|
||||
{{document/document-editor
|
||||
document=model.document
|
||||
folder=model.folder
|
||||
page=model.page
|
||||
meta=model.meta
|
||||
attachments=model.attachments
|
||||
onCancel=(action "onCancel") onAction=(action "onAction")}}
|
||||
|
||||
{{document/section-attachment uploadLabel="Upload Attachments"
|
||||
editMode=true page=model.page document=model.document
|
||||
files=model.attachments
|
||||
onAttachmentUpload=(action "onAttachmentUpload")
|
||||
onAttachmentDelete=(action "onAttachmentDelete")}}
|
||||
{{/layout/master-content}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue