1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-28 09:39:42 +02:00

fixed doc import and add space bugs

This commit is contained in:
Harvey Kandola 2016-10-07 10:42:20 -07:00
parent cbcb7a380f
commit 34199ae8e6

View file

@ -29,6 +29,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
importedDocuments: [], importedDocuments: [],
isFolderOwner: computed.equal('folder.userId', 'session.user.id'), isFolderOwner: computed.equal('folder.userId', 'session.user.id'),
moveFolderId: "", moveFolderId: "",
drop: null,
didReceiveAttrs() { didReceiveAttrs() {
this.set('isFolderOwner', this.get('folder.userId') === this.get("session.user.id")); this.set('isFolderOwner', this.get('folder.userId') === this.get("session.user.id"));
@ -56,55 +57,60 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.addTooltip(document.getElementById("import-document-button")); this.addTooltip(document.getElementById("import-document-button"));
} }
} }
},
didInsertElement() { if (this.get('folderService').get('canEditCurrentFolder')) {
let self = this; let self = this;
let folderId = this.get('folder.id'); let folderId = this.get('folder.id');
let url = this.get('appMeta.endpoint'); let url = this.get('appMeta.endpoint');
let importUrl = `${url}/import/folder/${folderId}`; let importUrl = `${url}/import/folder/${folderId}`;
Dropzone.options.uploadDocuments = false; let dzone = new Dropzone("#import-document-button > i", {
headers: {
'Authorization': 'Bearer ' + self.get('session.session.content.authenticated.token')
},
url: importUrl,
method: "post",
paramName: 'attachment',
acceptedFiles: ".doc,.docx,.txt,.md,.markdown",
clickable: true,
maxFilesize: 10,
parallelUploads: 3,
uploadMultiple: false,
addRemoveLinks: false,
autoProcessQueue: true,
let dzone = new Dropzone("#import-document-button > i", { init: function () {
headers: { this.on("success", function (document) {
'Authorization': 'Bearer ' + self.get('session.session.content.authenticated.token') self.send('onDocumentImported', document.name, document);
}, });
url: importUrl,
method: "post",
paramName: 'attachment',
acceptedFiles: ".doc,.docx,.txt,.md,.markdown",
clickable: true,
maxFilesize: 10,
parallelUploads: 3,
uploadMultiple: false,
addRemoveLinks: false,
autoProcessQueue: true,
init: function () { this.on("error", function (x) {
this.on("success", function (document) { console.log("Conversion failed for ", x.name, " obj ", x); // TODO proper error handling
self.send('onDocumentImported', document.name, document); });
});
this.on("error", function (x) { this.on("queuecomplete", function () {});
console.log("Conversion failed for ", x.name, " obj ", x); // TODO proper error handling
});
this.on("queuecomplete", function () {}); this.on("addedfile", function (file) {
self.send('onDocumentImporting', file.name);
self.audit.record('converted-document');
});
}
});
this.on("addedfile", function (file) { dzone.on("complete", function (file) {
self.send('onDocumentImporting', file.name); dzone.removeFile(file);
self.audit.record('converted-document'); });
});
}
});
dzone.on("complete", function (file) { this.set('drop', dzone);
dzone.removeFile(file); }
});
}, },
willDestroyElement() { willDestroyElement() {
if (is.not.null(this.get('drop'))) {
this.get('drop').destroy();
this.set('drop', null);
}
this.destroyTooltips(); this.destroyTooltips();
}, },