Skip to content

Commit edbfae0

Browse files
author
Jelte Lagendijk
committed
Fix #2 remove applyContext & fix update Rendering
1 parent 8a8bb7c commit edbfae0

7 files changed

Lines changed: 34 additions & 76 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "DynamicImage",
3-
"version": "4.1.1",
3+
"version": "4.2.0",
44
"description": "",
55
"license": "",
66
"author": "",
@@ -25,7 +25,7 @@
2525
"generatorVersion": "1.3.3",
2626
"paths": {
2727
"testProjectFolder": "./test/",
28-
"testProjectFileName": "Test.mpr"
28+
"testProjectFileName": "DynamicImageWidget.mpr"
2929
},
3030
"scripts": {
3131
"test": "grunt test"

src/DynamicImage/widget/DynamicImage.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,13 @@ define([
3030
this._resetSubscriptions();
3131
this._updateRendering(callback);
3232
} else {
33-
callback();
34-
}
35-
},
36-
37-
applyContext: function (context, callback) {
38-
logger.debug(this.id + ".applyContext");
39-
if (context && !!context.getTrackId()) {
40-
var obj = context.getTrackObject();
41-
if (obj !== null) {
42-
this._contextObj = obj;
43-
this._updateRendering(callback);
44-
} else {
45-
mx.data.get({
46-
guid : context.getTrackId(),
47-
callback : function(obj) {
48-
this._contextObj = obj;
49-
this._updateRendering(callback);
50-
}
51-
}, this);
52-
}
33+
mx.data.get({
34+
guid : this.mxcontext.getTrackId(),
35+
callback : function(obj) {
36+
this._contextObj = obj;
37+
this._updateRendering(callback);
38+
}
39+
}, this);
5340
}
5441
},
5542

@@ -153,24 +140,26 @@ define([
153140
},
154141

155142
_execClick : function(index) {
143+
logger.debug(this.id + "._execClick");
156144
if (this._contextObj !== null && this.imageNode) {
157-
if (this.clickmicroflow !== "")
158-
{
145+
if (this.clickmicroflow !== "") {
159146
mx.data.action({
160147
params : {
161148
applyto : "selection",
162149
actionname : this.clickmicroflow,
163150
guids : [this._contextObj.getGuid()]
164151
},
152+
store: {
153+
caller: this.mxform
154+
},
165155
callback : function(obj) {
166156
},
167157
error : function(error) {
168158
console.error(this.id + "error: XAS error executing microflow");
169159
}
170160
});
171161
}
172-
if (this.linkattr !== "")
173-
{
162+
if (this.linkattr !== "") {
174163
var url = this._contextObj.get(this.linkattr);
175164
if (url !== "" && url !== undefined && url !== null) {
176165
window.open(url, this.linktarget);

src/DynamicImage/widget/MobileDynamicImage.js

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,13 @@ define([
3333
this._resetSubscriptions();
3434
this._updateRendering(callback);
3535
} else {
36-
callback();
37-
}
38-
},
39-
40-
applyContext: function (context, callback) {
41-
logger.debug(this.id + ".applyContext");
42-
if (context && !!context.getTrackId()) {
43-
var obj = context.getTrackObject();
44-
if (obj !== null) {
45-
this._contextObj = obj;
46-
this._updateRendering(callback);
47-
} else {
48-
mx.data.get({
49-
guid : context.getTrackId(),
50-
callback : function(obj) {
51-
this._contextObj = obj;
52-
this._updateRendering(callback);
53-
}
54-
}, this);
55-
}
36+
mx.data.get({
37+
guid : this.mxcontext.getTrackId(),
38+
callback : function(obj) {
39+
this._contextObj = obj;
40+
this._updateRendering(callback);
41+
}
42+
}, this);
5643
}
5744
},
5845

@@ -157,23 +144,24 @@ define([
157144

158145
_execClick : function(index) {
159146
if (this._contextObj !== null && this.imageNode) {
160-
if (this.clickmicroflow !== "")
161-
{
147+
if (this.clickmicroflow !== "") {
162148
mx.data.action({
163149
params : {
164150
applyto : "selection",
165151
actionname : this.clickmicroflow,
166152
guids : [this._contextObj.getGuid()]
167153
},
154+
store: {
155+
caller: this.mxform
156+
},
168157
callback : function(obj) {
169158
},
170159
error : function(error) {
171160
console.error(this.id + "error: XAS error executing microflow");
172161
}
173162
});
174163
}
175-
if (this.linkattr !== "")
176-
{
164+
if (this.linkattr !== "") {
177165
var url = this._contextObj.get(this.linkattr);
178166
if (url !== "" && url !== undefined && url !== null) {
179167
window.open(url, this.linktarget);

src/DynamicImage/widget/MobileStaticImage.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,21 @@ define([
3030
this._updateRendering(callback);
3131
},
3232

33-
applyContext: function (context, callback) {
34-
logger.debug(this.id + ".applyContext");
35-
this._contextContext = context;
36-
if (context && !!context.getTrackId()) {
37-
var obj = context.getTrackObject();
38-
if (obj !== null) {
39-
this._contextObj = obj;
40-
this._updateRendering(callback);
41-
} else {
42-
mx.data.get({
43-
guid : context.getTrackId(),
44-
callback : function(obj) {
45-
this._contextObj = obj;
46-
this._updateRendering(callback);
47-
}
48-
}, this);
49-
}
50-
}
51-
},
52-
5333
// Rerender the interface.
5434
_updateRendering: function (callback) {
35+
logger.debug(this.id + "._updateRendering");
5536
if (this.imageurl !== "") {
5637
this.imageNode.src = this.imageurl;
5738
} else {
5839
this.imageNode.src = this.defaultImage;
5940
}
6041

61-
if (callback)
62-
callback();
42+
mendix.lang.nullExec(callback);
6343
},
6444

6545
// Reset subscriptions.
6646
_resetSubscriptions: function () {
47+
logger.debug(this.id + "._resetSubscriptions");
6748
var _objectHandle = null;
6849

6950
// Release handles on previous object, if any.

src/DynamicImage/widget/StaticImage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ define([
2020

2121
postCreate: function () {
2222
logger.debug(this.id + ".postCreate");
23-
this._updateRendering();
2423
},
2524

2625
update: function (obj, callback) {
@@ -32,18 +31,19 @@ define([
3231

3332
// Rerender the interface.
3433
_updateRendering: function (callback) {
34+
logger.debug(this.id + "._updateRendering");
3535
if (this.imageurl !== "") {
3636
this.imageNode.src = this.imageurl;
3737
} else {
3838
this.imageNode.src = this.defaultImage;
3939
}
4040

41-
if (callback)
42-
callback();
41+
mendix.lang.nullExec(callback);
4342
},
4443

4544
// Reset subscriptions.
4645
_resetSubscriptions: function () {
46+
logger.debug(this.id + "._resetSubscriptions");
4747
var _objectHandle = null;
4848

4949
// Release handles on previous object, if any.

src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="DynamicImage" version="4.1.1" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="DynamicImage" version="4.2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="DynamicImage/DynamicImage.xml"/>
66
<widgetFile path="DynamicImage/StaticImage.xml"/>

test/widgets/DynamicImage.mpk

-267 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)