Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions src/TreeView/widget/Commons.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
define([
"dojo/_base/declare",
"dojo/data/util/simpleFetch",
], function(declare) {
], function (declare) {
"use strict";

var Commons = declare("TreeView.widget.Commons", null, {
//MX5 hack
fixObjProps : function(widget, props) {
fixObjProps: function (widget, props) {
logger.debug("TreeView.widget.Commons.fixObjProps");

var args = {};
Expand All @@ -29,7 +29,7 @@ define([
}
},

getEnumMap : function(classname, attrname) {
getEnumMap: function (classname, attrname) {
logger.debug("TreeView.widget.Commons.getEnumMap");

var meta = mx.meta.getEntity(classname);
Expand All @@ -48,23 +48,23 @@ define([
* @param {[type]} data [datamap object to be attached to the domnode]
* @return {[type]} node [description]
*/
renderLabel : function(name, close, data) {
renderLabel: function (name, close, data) {
logger.debug("TreeView.widget.Commons.renderLabel");

var n = mxui.dom.create(
"span",
{"class": "gv_label"},
{ "class": "gv_label" },
mxui.dom.create(
"span",
{"class": "gv_label_name"},
{ "class": "gv_label_name" },
name ? name : ""
)
);

if (close) {
dojo.place(mxui.dom.create(
"span",
{"class": "gv_label_close"},
{ "class": "gv_label_close" },
"x"
), n);
}
Expand All @@ -73,7 +73,7 @@ define([
return n;
},

getAttributeType : function(classnameOrObject, attr) {
getAttributeType: function (classnameOrObject, attr) {
logger.debug("TreeView.widget.Commons.getAttributeType");

var parts = attr.split("/");
Expand All @@ -93,7 +93,7 @@ define([
return false;
},

getObjectAttr : function(object, attr, renderValue) {
getObjectAttr: function (object, attr, renderValue) {
logger.debug("TreeView.widget.Commons.getObjectAttr");

if (!object || !attr) {
Expand Down Expand Up @@ -156,7 +156,7 @@ define([
throw "GridCommons.getObjectAttr: Failed to retrieve attribute '" + attr + "'";
},

objectToGuid : function(thing) {
objectToGuid: function (thing) {
logger.debug("TreeView.widget.Commons.objectToGuid");

if (!thing) {
Expand All @@ -181,7 +181,7 @@ define([
* @param {Function} callback [callback function]
* @return {[type]} [description]
*/
store : function(object, attr, value, mode, commit, callback) {
store: function (object, attr, value, mode, commit, callback) {
logger.debug("TreeView.widget.Commons.store");

var res = false;
Expand All @@ -192,7 +192,7 @@ define([
var cb = function () {
left -= 1;
if (left < 1) {
mendix.lang.nullExec(callback);
callback && callback();
}
};

Expand Down Expand Up @@ -231,10 +231,10 @@ define([
}

switch (mode) {
case "add" :
case "add":
res = object.addReferences(attr, guids);
break;
case "rem" :
case "rem":
res = object.removeReferences(attr, guids);
break;
default:
Expand Down Expand Up @@ -263,7 +263,7 @@ define([
mxobj: object,
error: this.error,
callback: function () {
mendix.lang.nullExec(callback);
callback && callback();
}
});
}
Expand All @@ -277,7 +277,7 @@ define([
* @param {[type]} event [description]
* @param {[type]} map of className -> function(node, event) -> boolean. (If false, further event are stopped)
*/
liveConnect : function(widget, node, event, map) {
liveConnect: function (widget, node, event, map) {
logger.debug("TreeView.widget.Commons.liveConnect");

if (!node) {
Expand Down Expand Up @@ -314,11 +314,11 @@ define([
* @param {[type]} message [description]
* @param {Function} callback [description]
*/
confirm : function(message, callback, yescaption, nocaption) {
confirm: function (message, callback, yescaption, nocaption) {
logger.debug("TreeView.widget.Commons.confirm");

if (!message) {
mendix.lang.nullExec(callback);
callback && callback();
return;
}

Expand All @@ -330,7 +330,7 @@ define([
});
},

mf : function(mfname, data, callback, context, mfNeedsList, progressMessage) {
mf: function (mfname, data, callback, context, mfNeedsList, progressMessage) {
logger.debug("TreeView.widget.Commons.mf");

//firing on multiple items? wait for all items to finish
Expand Down Expand Up @@ -379,7 +379,7 @@ define([
}
},

configError : function(widget, msg) {
configError: function (widget, msg) {
logger.debug("TreeView.widget.Commons.configError");

msg = "Configuration error in " + widget.id + ": " + msg;
Expand All @@ -390,7 +390,7 @@ define([
throw msg;
},

error : function(e) {
error: function (e) {
logger.debug("TreeView.widget.Commons.error");

console.error(e);
Expand All @@ -400,7 +400,7 @@ define([
/**
* splits the given properties up to objects in target per index. First property indicates targetobjects name
*/
splitPropsTo : function(widget, propnames, target) {
splitPropsTo: function (widget, propnames, target) {
logger.debug("TreeView.widget.Commons.splitPropsTo");

var props = propnames.split(",");
Expand Down Expand Up @@ -436,13 +436,13 @@ define([
* @param {[function(object, guid)]} cb to be invoked when resolved [description]
* @return {[type]} [description]
*/
normalizeContext : function(data, cb) {
normalizeContext: function (data, cb) {
logger.debug("TreeView.widget.Commons.normalizeContext");

//Nothing
if (data == null) {
cb(null, null);
} else if (typeof(data) != "object" && /^\d+$/.test(data)) { //GUid only
} else if (typeof (data) != "object" && /^\d+$/.test(data)) { //GUid only
mx.data.get({
guid: data,
callback: function (mxobj) {
Expand Down
29 changes: 15 additions & 14 deletions src/TreeView/widget/Commons/RelatedDataset.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define([
"dojo/_base/declare",
"TreeView/widget/Commons"
], function(declare, Commons) {
], function (declare, Commons) {
"use strict"

return declare("TreeView.widget.Commons.RelatedDataset", null, {
Expand Down Expand Up @@ -40,7 +40,7 @@ define([
this.widget.connect(this.widget, "update", dojo.hitch(this, function (data, cb) {
this.contextGuid = data && data.getGuid ? data.getGuid() : data;
this.fetchLabels();
mendix.lang.nullExec(cb);
cb && cb();
}));
},

Expand All @@ -53,7 +53,7 @@ define([
},

getValue: function (item, _) {
if (typeof (item) == "object"){
if (typeof (item) == "object") {
return item.get(this.relnameattr);
} else if (/^\d+$/.test(item)) {
var obj = this.existingLabelsById[item]; //assuming guid
Expand All @@ -69,7 +69,7 @@ define([
},

fetchLabels: function () {
if (this.contextGuid == null || this._fetchingLabels){
if (this.contextGuid == null || this._fetchingLabels) {
return;
}
this.hasData = false;
Expand Down Expand Up @@ -98,12 +98,12 @@ define([
this.existingLabels[label.toLowerCase()] = obj;
this.existingLabelsById[value] = obj;

return {value: value, label: label};
return { value: value, label: label };
}, this);

this._fetchingLabels = false;

if (this.relnewitemcaption){
if (this.relnewitemcaption) {
this.existingOptions.splice(0, 0, {
value: "new",
label: this.relnewitemcaption,
Expand Down Expand Up @@ -136,9 +136,9 @@ define([
callback: dojo.hitch(this, function (label) {
var cb = callback
? dojo.hitch(this, callback, {
value: label.getGuid(),
label: labelname
})
value: label.getGuid(),
label: labelname
})
: null;

if (this.relcontextassoc)
Expand All @@ -163,7 +163,7 @@ define([

fetchItemByIdentity: function (args) {
//TODO: check and error handling
if (!this.existingLabelsById){
if (!this.existingLabelsById) {
args.onItem.call(args.scope, null);
} else {
args.onItem.call(args.scope, this.existingLabelsById[args.identity]);
Expand All @@ -173,10 +173,11 @@ define([
/* Simplefetch api */
_fetchItems: function (query, resultcallback) {
var results = [];
if (this.existingLabels != null){
for (var key in this.existingLabels){
if (key.indexOf(query.query.name.toLowerCase()) === 0){
results.push(this.existingLabels[key]);}
if (this.existingLabels != null) {
for (var key in this.existingLabels) {
if (key.indexOf(query.query.name.toLowerCase()) === 0) {
results.push(this.existingLabels[key]);
}
}
}
resultcallback(results, query);
Expand Down
Loading