Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 3fed57e

Browse files
committed
Updated Widget for Mendix 6
Updated TreeView for Mendix 6
1 parent cc43ef6 commit 3fed57e

File tree

5 files changed

+78
-81
lines changed

5 files changed

+78
-81
lines changed

src/TreeView/widget/Commons.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dojo.setObject("TreeView.widget.Commons", (function() {
3333

3434

3535
function getEnumMap(classname, attrname) {
36-
var meta = mx.metadata.getMetaEntity(classname);
36+
var meta = mx.meta.getEntity(classname);
3737

3838
if (getAttributeType(classname, attrname) != 'Enum')
3939
throw "Not an enumeration: " + args.join(".");
@@ -73,11 +73,11 @@ dojo.setObject("TreeView.widget.Commons", (function() {
7373
return getAttributeType(parts[1], parts[2])
7474

7575
if (attr.indexOf("/") == -1) {
76-
if (classnameOrObject.getClass)
77-
classnameOrObject = classnameOrObject.getClass();
76+
if (classnameOrObject.getEntity)
77+
classnameOrObject = classnameOrObject.getEntity();
7878

79-
var meta = mx.metadata.getMetaEntity(classnameOrObject);
80-
return meta.getAttributeClass(attr);
79+
var meta = mx.meta.getEntity(classnameOrObject);
80+
return meta.getAttributeType(attr);
8181
}
8282

8383
return false;
@@ -91,7 +91,7 @@ dojo.setObject("TreeView.widget.Commons", (function() {
9191
if (attr.indexOf("/") == -1) {
9292
if (renderValue)
9393
return mx.parser && mx.parser.formatAttribute ? mx.parser.formatAttribute(object, attr) : mxui.html.renderValue(object, attr); //mxui.html.rendervalue moved in 5.~7.
94-
return object.getAttribute(attr);
94+
return object.get(attr);
9595
}
9696
var parts = attr.split("/");
9797
if (parts.length == 3) {
@@ -110,7 +110,7 @@ dojo.setObject("TreeView.widget.Commons", (function() {
110110
else {
111111
//..but, there is a guid...
112112
var tmp = null;
113-
mx.processor.get({ guid : child, noCache : false, callback : function(obj) { //async = false option would be nice!
113+
mx.data.get({ guid : child, noCache : false, callback : function(obj) { //async = false option would be nice!
114114
tmp = obj;
115115
}});
116116
if (tmp != null) //callback was invoked in sync :)
@@ -125,7 +125,7 @@ dojo.setObject("TreeView.widget.Commons", (function() {
125125

126126
//objects can be returned in X different ways, sometime just a guid, sometimes its an object...
127127
if (parts.length == 2) {
128-
var result = object.getAttribute(parts[0]); //incase of of a get object, return the GUIDs (but sometimes getAttribute gives the object...)
128+
var result = object.get(parts[0]); //incase of of a get object, return the Guids (but sometimes getAttribute gives the object...)
129129
if (!result)
130130
return "";
131131
if (result.guid)
@@ -143,8 +143,8 @@ dojo.setObject("TreeView.widget.Commons", (function() {
143143
return null;
144144
if (thing.guid)
145145
return thing.guid;
146-
if (thing.getGUID)
147-
return thing.getGUID();
146+
if (thing.getGuid)
147+
return thing.getGuid();
148148
if (/^\d+$/.test(thing))
149149
return thing;
150150
throw "Does not look like a MxObject: " + thing;
@@ -236,7 +236,7 @@ dojo.setObject("TreeView.widget.Commons", (function() {
236236
if (res === false) //set returns undefined if ok, or false on failure
237237
throw "Commons.store: Unable to update attribute: " + attr;
238238

239-
mx.processor[commit === true ? 'commit' : 'save']({
239+
mx.data[commit === true ? 'commit' : 'save']({
240240
mxobj: object,
241241
error : error,
242242
callback : function() {
@@ -328,7 +328,7 @@ dojo.setObject("TreeView.widget.Commons", (function() {
328328

329329
mx.ui.action(mfname, {
330330
store : {
331-
caller : context.mxform
331+
caller : context
332332
},
333333
params : {
334334
applyto : 'selection',
@@ -402,20 +402,20 @@ dojo.setObject("TreeView.widget.Commons", (function() {
402402
cb(null, null);
403403
//GUid only
404404
else if (typeof(data) != "object" && /^\d+$/.test(data)) {
405-
mx.processor.get({
405+
mx.data.get({
406406
guid: data,
407407
callback : function(mxobj) {
408408
if (mxobj == null)
409409
cb(null, null)
410410
else
411-
cb(mxobj, mxobj.getGUID())
411+
cb(mxobj, mxobj.getGuid())
412412
},
413413
error : this.showError
414414
}, this);
415415
}
416416
//Context is mxobj object
417417
else {
418-
var guid = data.getGUID();
418+
var guid = data.getGuid();
419419
cb(data, guid);
420420
}
421421
}
@@ -513,7 +513,7 @@ dojo.declare("TreeView.widget.DropDown", null, {
513513
this.dropdown.set('label', item.label);
514514

515515
return new dijit.MenuItem({
516-
label : mxui.dom.escapeHTML(item.label),
516+
label : mxui.dom.escapeString(item.label),
517517
value : item.value,
518518
onClick : item.onClick
519519
? dojo.hitch(item, item.onClick, dojo.hitch(this, this.itemClick)) //pass itemClick as callback to the onClick, so it can be invoked
@@ -828,7 +828,7 @@ dojo.declare("TreeView.widget.Colrenderer", null, {
828828
if (value === null || value === undefined)
829829
value = "";
830830

831-
dojo.html.set(domNode, this.columnprefix + mxui.dom.escapeHTML(value).replace(/\n/g,"<br/>") + this.columnpostfix);
831+
dojo.html.set(domNode, this.columnprefix + mxui.dom.escapeString(value).replace(/\n/g,"<br/>") + this.columnpostfix);
832832
dojo.attr(domNode, 'title', value);
833833

834834
this.createDefaultImage(domNode);
@@ -1137,7 +1137,7 @@ dojo.declare("TreeView.widget.RelatedDataset", null, {
11371137
relnewitemcaption : '',
11381138

11391139
widget : null,
1140-
contextGUID : null,
1140+
contextGuid : null,
11411141
hasData : false,
11421142

11431143
existingLabels : null,
@@ -1159,7 +1159,7 @@ dojo.declare("TreeView.widget.RelatedDataset", null, {
11591159
});
11601160

11611161
this.widget.connect(this.widget, "update", dojo.hitch(this, function(data, cb) {
1162-
this.contextGUID = data && data.getGUID ? data.getGUID() : data;
1162+
this.contextGuid = data && data.getGuid ? data.getGuid() : data;
11631163
this.fetchLabels();
11641164
cb && cb();
11651165
}));
@@ -1175,7 +1175,7 @@ dojo.declare("TreeView.widget.RelatedDataset", null, {
11751175

11761176
getValue : function(item, _) {
11771177
if (typeof (item) == "object")
1178-
return item.getAttribute(this.relnameattr);
1178+
return item.get(this.relnameattr);
11791179
else if (/^\d+$/.test(item)){
11801180
var obj = this.existingLabelsById[item]; //assuming guid
11811181
return obj ? this.getValue(obj) : null; //TODO: warn?
@@ -1190,14 +1190,14 @@ dojo.declare("TreeView.widget.RelatedDataset", null, {
11901190
},
11911191

11921192
fetchLabels : function() {
1193-
if (this.contextGUID == null || this._fetchingLabels)
1193+
if (this.contextGuid == null || this._fetchingLabels)
11941194
return;
11951195

11961196
this.hasData = false;
11971197
this._fetchingLabels = true;
11981198
var xpath = "//" + this.relentity + this.relconstraint + (this.relcontextassoc != '' ? "[" + this.relcontextassoc.split("/")[0] + " = '[%CurrentObject%]']" : '');
1199-
xpath = xpath.replace(/\[\%CurrentObject\%\]/gi, this.contextGUID);
1200-
mx.processor.get({
1199+
xpath = xpath.replace(/\[\%CurrentObject\%\]/gi, this.contextGuid);
1200+
mx.data.get({
12011201
xpath : xpath,
12021202
callback : dojo.hitch(this, this.retrieveLabels),
12031203
filter : {
@@ -1213,8 +1213,8 @@ dojo.declare("TreeView.widget.RelatedDataset", null, {
12131213
this.existingLabelsById = {};
12141214

12151215
this.existingOptions = dojo.map(objects, function(obj) {
1216-
var value = obj.getGUID();
1217-
var label = obj.getAttribute(this.relnameattr);
1216+
var value = obj.getGuid();
1217+
var label = obj.get(this.relnameattr);
12181218

12191219
this.existingLabels[label.toLowerCase()] = obj;
12201220
this.existingLabelsById[value] = obj;
@@ -1251,19 +1251,19 @@ dojo.declare("TreeView.widget.RelatedDataset", null, {
12511251
createNewItem : function(callback) {
12521252
var labelname = prompt("Please enter " + this.relnewitemcaption, "");
12531253
if (labelname) {
1254-
mx.processor.create({
1254+
mx.data.create({
12551255
entity : this.relentity,
12561256
error : this.widget.showError,
12571257
callback : dojo.hitch(this, function(label) {
12581258
var cb = callback
12591259
? dojo.hitch(this, callback, {
1260-
value : label.getGUID(),
1260+
value : label.getGuid(),
12611261
label: labelname
12621262
})
12631263
: null;
12641264

12651265
if (this.relcontextassoc)
1266-
TreeView.widget.Commons.store(label, this.relcontextassoc, this.contextGUID);
1266+
TreeView.widget.Commons.store(label, this.relcontextassoc, this.contextGuid);
12671267

12681268
TreeView.widget.Commons.store(label, this.relnameattr, dojo.trim(labelname), null, true, cb);
12691269
})
@@ -1275,7 +1275,7 @@ dojo.declare("TreeView.widget.RelatedDataset", null, {
12751275

12761276
/* Identity api */
12771277
getIdentity : function(item) {
1278-
return item.getGUID();
1278+
return item.getGuid();
12791279
},
12801280

12811281
getIdentityAttributes : function() {
@@ -1440,7 +1440,7 @@ dojo.declare("TreeView.widget.SearchControl", null, {
14401440
updateSearchLabel : function(label) {
14411441
dojo.empty(this.labelContainer);
14421442
if (label != null) {
1443-
var labelname = label.getAttribute(this.dataset.relnameattr);
1443+
var labelname = label.get(this.dataset.relnameattr);
14441444
dojo.place(TreeView.widget.Commons.renderLabel(labelname, true), this.labelContainer);
14451445
}
14461446
},
@@ -1491,7 +1491,7 @@ dojo.declare("TreeView.widget.SearchControl", null, {
14911491
}
14921492

14931493
if (this.searchlabel != null)
1494-
xpath += "[" + this.dataset.getAssoc() + " = '" + this.searchlabel.getGUID() + "']";
1494+
xpath += "[" + this.dataset.getAssoc() + " = '" + this.searchlabel.getGuid() + "']";
14951495

14961496
return xpath;
14971497
},

src/TreeView/widget/GridView.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ dojo.declare("TreeView.widget.Record", null, {
6464
checkbox : null, //checkbox node
6565

6666
constructor : function(data, grid) {
67-
this.guid = data.getGUID();
67+
this.guid = data.getGuid();
6868
this._data = data;
6969
this._colNodes = [];
7070
this._subs = [];
7171

7272
this.grid = grid;
7373

74-
this._subscription = mx.processor.subscribe({
74+
this._subscription = mx.data.subscribe({
7575
guid : this.guid,
7676
callback : dojo.hitch(this, function(thing) {
7777
//Do not update while suspended; all data will be fetch upon resume.
@@ -80,7 +80,7 @@ dojo.declare("TreeView.widget.Record", null, {
8080

8181
if (this.grid.datasourcemf) {
8282
//microflow data? retrieve by id
83-
mx.processor.get({
83+
mx.data.get({
8484
guid: this.guid,
8585
callback : dojo.hitch(this, function(data) {
8686
this.update(data);
@@ -90,7 +90,7 @@ dojo.declare("TreeView.widget.Record", null, {
9090
}
9191
else {
9292
//xpath datasource? retrieve by xpath, the object might no longer be in the grid constraint
93-
mx.processor.get({
93+
mx.data.get({
9494
xpath : grid.buildXpath() + "[id = '"+this.guid+"']",
9595
filter : grid.enableschema ? grid._schema : {},
9696
callback : dojo.hitch(this, function (data) {
@@ -195,7 +195,7 @@ dojo.declare("TreeView.widget.Record", null, {
195195
dojo.destroy(this.domNode);
196196

197197
if (this._subscription)
198-
mx.processor.unsubscribe(this._subscription);
198+
mx.data.unsubscribe(this._subscription);
199199

200200
}
201201

@@ -222,13 +222,11 @@ mxui.widget.declare("TreeView.widget.GridView", {
222222
this.updatePaging(); //update selected items label
223223

224224
if (this.selectionref || this.selectionrefset) {
225-
mx.processor.save({
225+
mx.data.save({
226226
mxobj : this.contextObject,
227227
callback : dojo.hitch(this, this.onSelect, item),
228228
error : this.showError
229229
}, this);
230-
} else {
231-
this.onSelect(item);
232230
}
233231
},
234232

@@ -477,10 +475,10 @@ mxui.widget.declare("TreeView.widget.GridView", {
477475
//if reload on context change is enabled, reload as soon as the context object is altered
478476
if (this.refreshoncontext) {
479477
if (this._contextSubscription)
480-
mx.processor.unsubscribe(this._contextSubscription);
478+
mx.data.unsubscribe(this._contextSubscription);
481479

482480
if (this.contextGUID) {
483-
this._contextSubscription = mx.processor.subscribe({
481+
this._contextSubscription = mx.data.subscribe({
484482
guid: this.contextGUID,
485483
callback : dojo.hitch(this, function() {
486484
if (!this._iscallingdatasource)
@@ -522,7 +520,7 @@ mxui.widget.declare("TreeView.widget.GridView", {
522520

523521
var self = this;
524522

525-
mx.processor.save({
523+
mx.data.save({
526524
mxobj : contextObject,
527525
callback : function(){
528526
self._iscallingdatasource = true;
@@ -578,7 +576,7 @@ mxui.widget.declare("TreeView.widget.GridView", {
578576
args.filter.limit = this.pagesize;
579577

580578
//perform the get
581-
mx.processor.get(args);
579+
mx.data.get(args);
582580
},
583581

584582
buildXpath : function () {
@@ -629,9 +627,8 @@ mxui.widget.declare("TreeView.widget.GridView", {
629627
else {
630628
cb && cb.call(this); //MWE: cb can influence selection, call callback before reapply?
631629
}
632-
633-
if (this.rememberSelection)
634-
this.reapplySelection();
630+
631+
this.reapplySelection();
635632
},
636633

637634
updatePaging : function() {

0 commit comments

Comments
 (0)