1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

Rebind dropzone elements for section attachments

This commit is contained in:
sauls8t 2019-04-29 13:34:38 +01:00
parent 34d1639899
commit b971c52469
4 changed files with 1145 additions and 1126 deletions

View file

@ -25,7 +25,6 @@ export default Component.extend(Modals, Notifier, {
return `page-uploader-${page.id}`;
}),
uploadLabel: 'Upload Attachments',
uploaderReady: false,
didReceiveAttrs() {
this._super(...arguments);
@ -42,12 +41,31 @@ export default Component.extend(Modals, Notifier, {
didRender() {
this._super(...arguments);
// For authenticated users we send server auth token.
let qry = '';
if (this.get('session.hasSecureToken')) {
qry = '?secure=' + this.get('session.secureToken');
} else if (this.get('session.authenticated')) {
qry = '?token=' + this.get('session.authToken');
}
this.set('downloadQuery', qry);
// We don't setup uploader if not edit mode.
if (!this.get('editMode') || this.get('uploaderReady')) {
if (!this.get('editMode')) {
return;
}
// Remove any previous Dropzone init.
for (var j=0; j < 2; j++) {
let dz = this.get('dzone' + j);
if (!_.isNull(dz) && !_.isUndefined(dz)) {
dz.destroy();
this.set('dzone' + j, null);
}
}
let self = this;
let documentId = this.get('document.id');
let pageId = this.get('page.id');
@ -94,9 +112,10 @@ export default Component.extend(Modals, Notifier, {
dzone.on("complete", function (file) {
dzone.removeFile(file);
});
}
this.set('uploaderReady', true);
this.set('dzone' + i, dzone);
}
},
actions: {