mirror of
https://github.com/documize/community.git
synced 2025-07-28 01:29:43 +02:00
fixed doc import and add space bugs
This commit is contained in:
parent
cbcb7a380f
commit
34199ae8e6
1 changed files with 45 additions and 39 deletions
|
@ -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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
if (this.get('folderService').get('canEditCurrentFolder')) {
|
||||||
|
let self = this;
|
||||||
|
let folderId = this.get('folder.id');
|
||||||
|
let url = this.get('appMeta.endpoint');
|
||||||
|
let importUrl = `${url}/import/folder/${folderId}`;
|
||||||
|
|
||||||
didInsertElement() {
|
let dzone = new Dropzone("#import-document-button > i", {
|
||||||
let self = this;
|
headers: {
|
||||||
let folderId = this.get('folder.id');
|
'Authorization': 'Bearer ' + self.get('session.session.content.authenticated.token')
|
||||||
let url = this.get('appMeta.endpoint');
|
},
|
||||||
let importUrl = `${url}/import/folder/${folderId}`;
|
url: importUrl,
|
||||||
|
method: "post",
|
||||||
|
paramName: 'attachment',
|
||||||
|
acceptedFiles: ".doc,.docx,.txt,.md,.markdown",
|
||||||
|
clickable: true,
|
||||||
|
maxFilesize: 10,
|
||||||
|
parallelUploads: 3,
|
||||||
|
uploadMultiple: false,
|
||||||
|
addRemoveLinks: false,
|
||||||
|
autoProcessQueue: true,
|
||||||
|
|
||||||
Dropzone.options.uploadDocuments = false;
|
init: function () {
|
||||||
|
this.on("success", function (document) {
|
||||||
|
self.send('onDocumentImported', document.name, document);
|
||||||
|
});
|
||||||
|
|
||||||
let dzone = new Dropzone("#import-document-button > i", {
|
this.on("error", function (x) {
|
||||||
headers: {
|
console.log("Conversion failed for ", x.name, " obj ", x); // TODO proper error handling
|
||||||
'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,
|
|
||||||
|
|
||||||
init: function () {
|
this.on("queuecomplete", function () {});
|
||||||
this.on("success", function (document) {
|
|
||||||
self.send('onDocumentImported', document.name, document);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.on("error", function (x) {
|
this.on("addedfile", function (file) {
|
||||||
console.log("Conversion failed for ", x.name, " obj ", x); // TODO proper error handling
|
self.send('onDocumentImporting', file.name);
|
||||||
});
|
self.audit.record('converted-document');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.on("queuecomplete", function () {});
|
dzone.on("complete", function (file) {
|
||||||
|
dzone.removeFile(file);
|
||||||
|
});
|
||||||
|
|
||||||
this.on("addedfile", function (file) {
|
this.set('drop', dzone);
|
||||||
self.send('onDocumentImporting', file.name);
|
}
|
||||||
self.audit.record('converted-document');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dzone.on("complete", function (file) {
|
|
||||||
dzone.removeFile(file);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
|
if (is.not.null(this.get('drop'))) {
|
||||||
|
this.get('drop').destroy();
|
||||||
|
this.set('drop', null);
|
||||||
|
}
|
||||||
|
|
||||||
this.destroyTooltips();
|
this.destroyTooltips();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue