Skip to content

Commit

Permalink
V4.0.5
Browse files Browse the repository at this point in the history
Fix for 14.1: disabled logging
  • Loading branch information
ChrisdeG committed May 11, 2018
1 parent 35bf583 commit 1e0bca6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 35 deletions.
Binary file modified dist/DropZone.mpk
Binary file not shown.
66 changes: 32 additions & 34 deletions src/DropZone/widget/DropZone.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DropZone
========================
@file : Dropzone.js
@version : 4.0.4
@version : 4.0.5
@author : Andries Smit & Chris de Gelder
@date : 06-09-2017
@license : Apache V2
Expand All @@ -16,6 +16,7 @@
Mendix 7.12 version.
- 8-3-2018 mxui.dom. functions replaced with domConstruct.create
- 8-3-2018 Merge csrftoken (Thanks Jelte)
- 11-5-2018 disabled logger messages, bug in 14.1
To be done:
- fix, upload button image
Expand Down Expand Up @@ -55,8 +56,7 @@ define([
* @returns {undefined}
*/
constructor: function () {
logger.debug(this.id + ".constructor");
logger.debug('dropzone', Constructdropzone);
//logger.debug(this.id + ".constructor");
this.dropzone = null;
this._contextObj = null;
},
Expand All @@ -65,9 +65,8 @@ define([
* @returns {undefined}
*/
postCreate: function () {
logger.debug(this.id + ".postCreate");
//logger.debug(this.id + ".postCreate");
this.initDropZone();
logger.debug('this', this);
},
/**
* mxui.widget._WidgetBase.update is called when context is changed or initialized. Implement to re-render and / or fetch data.
Expand All @@ -76,7 +75,7 @@ define([
* @returns {undefined}
*/
update: function (obj, callback) {
logger.debug(this.id + ".update");
//logger.debug(this.id + ".update");
this._contextObj = obj;
if (callback) {
callback();
Expand All @@ -88,7 +87,7 @@ define([
* @returns {undefined}
*/
initDropZone: function () {
logger.debug(this.id + ".initDropZone");
//logger.debug(this.id + ".initDropZone");
domConstruct.empty(this.domNode);
if (!this.autoUpload) {
this.uploadButton = domConstruct.create('button', {
Expand All @@ -98,7 +97,7 @@ define([
});
this.uploadButton.innerHTML = this.buttoncaption;
on(this.uploadButton, "click", dojoLang.hitch(this, this.onclickEvent));
logger.debug("button", this.uploadButton, this.buttonCaption);
//logger.debug("button", this.uploadButton, this.buttonCaption);
this.domNode.appendChild(this.uploadButton);
}
var height = this.panelheight + " px";
Expand Down Expand Up @@ -131,6 +130,7 @@ define([
this.dropzone.on("error", dojoLang.hitch(this, this.onError));
this.dropzone.on("removedfile", dojoLang.hitch(this, this.onRemoveFile));
this.dropzone.on("sending", dojoLang.hitch(this, this.addFormData));
//logger.debug(this.id + ".initDropZone done");
},
/**
* add Mendix 7 'data' part to formdata
Expand All @@ -141,16 +141,16 @@ define([
*/
addFormData: function(data, xhr, formData) {
// Mendix 7 expects a data part.
var s = '{"changes":{},"objects":[]}';
formData.append("data", s);
/*var s = '{"changes":{},"objects":[]}';*/
formData.append("data", JSON.stringify( { changes: {}, objects: [] }));
},
/**
* set the Mendix upload URL based on the GUID
* @param {file[]} files
* @returns {String} url - mendix server URL to post the file to.s
*/
getMendixURL: function (files) {
logger.debug(this.id + ".getMendixURL");
//logger.debug(this.id + ".getMendixURL");
return "/file?guid=" + files[0].obj.getGuid() + "&maxFileSize=" + this.maxFileSize + "&height=75&width=100";
},
/**
Expand All @@ -160,7 +160,7 @@ define([
* @returns {undefined}
*/
onError: function (file, message) {
logger.error(this.id + ".onError", message);
//logger.error(this.id + ".onError", message);
this.removeFile(file);
},
/**
Expand All @@ -174,9 +174,8 @@ define([
// dont remove the files when the widget is being destroyed by the uninitialize function.
return;
}
logger.debug(this.id + ".onRemoveFile");
//logger.debug(this.id + ".onRemoveFile");
var obj = file.obj;
console.log('delete', file.deleteAfterUpload);
// if autoremoveafter upload is enabled the removefile is called but should not remove the file from the Mendix application
if (!file.deleteAfterUpload) {
if (obj && this.onRemove) {
Expand All @@ -191,7 +190,7 @@ define([
file.obj = null;
}),
error: function (e) {
logger.error("onRemoveFile", e);
//logger.error("onRemoveFile", e);
}
});
} else {
Expand All @@ -206,12 +205,12 @@ define([
* @returns {undefined}
*/
onComplete: function (file, message) {
logger.debug(this.id + ".onComplete");
//logger.debug(this.id + ".onComplete");
if (file.obj) {
mx.data.commit({
mxobj: file.obj,
callback: dojoLang.hitch(this, function () {
logger.debug("onComplete");
//logger.debug("onComplete");
this.callOnChange(file.obj);
if (this.removeAfterUpload) {
file.deleteAfterUpload = true;
Expand Down Expand Up @@ -243,7 +242,7 @@ define([
* @returns {undefined}
*/
acceptMendix: function (file, callback) {
logger.debug(this.id + ".accept");
//logger.debug(this.id + ".accept");
var rejectcaption = this.rejectcaption || "rejected";
if (file.obj && this.onAccept) {
mx.data.action({
Expand All @@ -261,7 +260,7 @@ define([
}
}),
error: function (e) {
logger.error("addedFile", e);
//logger.error("addedFile", e);
}
});
} else {
Expand All @@ -276,12 +275,12 @@ define([
* @returns {undefined}
*/
createMendixFile: function (file, callback) {
logger.debug(this.id + ".createMendixFile", file.name);
//logger.debug(this.id + ".createMendixFile", file.name);

mx.data.create({
entity: this.imageentity,
callback: dojoLang.hitch(this, function (obj) {
logger.debug('create', obj);
//logger.debug('create', obj);
var ref = this.contextassociation.split("/");
if (obj.has(ref[0]) && this._contextObj) {
obj.set(ref[0], this._contextObj.getGuid());
Expand All @@ -291,24 +290,24 @@ define([
obj.set(this.typeattr, file.type);
}
file.obj = obj;
logger.debug('save document');
//logger.debug('save document');
mx.data.saveDocument(
file.obj.getGuid(),
file.obj.name,
{ width: 100, height: 75 },
file,
function(obj) {
logger.debug('save succes', obj);
//logger.debug('save succes', obj);
// call callback when done
callback();
}, function(e) {
logger.debug('save error', e);
//logger.debug('save error', e);
callback();
});

}),
error: function () {
logger.error("failed createMendixFile");
//logger.error("failed createMendixFile");
callback();
}
});
Expand All @@ -319,7 +318,7 @@ define([
* @returns {undefined}
*/
removeFile: function (file) {
logger.debug(this.id + ".removeFile");
//logger.debug(this.id + ".removeFile");
if (file.obj) {
mx.data.remove({
guid: file.obj.getGuid(),
Expand All @@ -330,7 +329,7 @@ define([
file.obj = null;
},
error: function (err) {
logger.debug("Error occurred attempting to remove object " + err);
//logger.debug("Error occurred attempting to remove object " + err);
}
});
}
Expand All @@ -340,18 +339,17 @@ define([
* @returns {undefined}
*/
onclickEvent: function () {
logger.debug(this.id + ".onclickEvent");
//logger.debug(this.id + ".onclickEvent");
this.dropzone.processQueue();
logger.debug('dz', this.dropzone.getQueuedFiles());
//cdg test this.processQueue();
////logger.debug('dz', this.dropzone.getQueuedFiles());
},
/**
* Call onchange Miroflow if any.
* @param {mendix/lib/MxObject} obj
* @returns {undefined}
*/
callOnChange: function (obj) {
logger.debug(this.id + ".callOnChange");
//logger.debug(this.id + ".callOnChange");
if (obj && this.onChangemf) {
mx.data.action({
params: {
Expand All @@ -361,10 +359,10 @@ define([
},
origin: this.mxform,
callback: dojoLang.hitch(this, function () {
logger.debug("callOnChange");
//logger.debug("callOnChange");
}),
error: function (e) {
logger.error("callOnChange", e);
//logger.error("callOnChange", e);
}
});
}
Expand All @@ -375,7 +373,7 @@ define([
* @returns {undefined}
*/
uninitialize: function () {
logger.debug(this.id + ".uninitialize");
//logger.debug(this.id + ".uninitialize");
if (this.dropzone) {
this.dropzone.destroy();
}
Expand Down
2 changes: 1 addition & 1 deletion src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="DropZone" version="4.0.4" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="DropZone" version="4.0.5" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="DropZone/DropZone.xml"/>
</widgetFiles>
Expand Down
Binary file modified test/DropzoneDev.mpr
Binary file not shown.
Binary file modified test/widgets/DropZone.mpk
Binary file not shown.

0 comments on commit 1e0bca6

Please sign in to comment.