Skip to content

Commit dc59120

Browse files
committed
Added support for nanoflows
1 parent bb20590 commit dc59120

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/formatstring/formatstring.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,17 @@
7878
</property>
7979
<!-- BEHAVIOR -->
8080
<property key="onclickmf" type="microflow" required="false">
81-
<caption>On click</caption>
81+
<caption>On click microflow</caption>
8282
<category>Behavior</category>
8383
<description>Microflow to be invoked on click.</description>
8484
<returnType type="Void"/>
8585
</property>
86+
<property key="onclicknf" type="nanoflow" required="false">
87+
<caption>On click nanoflow</caption>
88+
<category>Behavior</category>
89+
<description>Nanoflow to be invoked on click.</description>
90+
<returnType type="Void"/>
91+
</property>
8692
<property key="stopClickPropagation" type="boolean" defaultValue="true">
8793
<caption>Stop propagation</caption>
8894
<category>Behavior</category>

src/formatstring/widget/formatstring.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ define([
1919
_timeData: null,
2020
_replaceAttr: null,
2121
attrList: null,
22+
onclicknf: {}, // Nanoflows are not strings, so need to make sure its always an object
2223

2324
postCreate: function() {
2425
logger.debug(this.id + ".postCreate");
2526

2627
this._timeData = languagePack;
2728

28-
if (this.onclickmf) {
29+
if (this.onclickmf || this.onclicknf.nanoflow) {
2930
this._setupEvents();
3031
}
3132

@@ -43,7 +44,7 @@ define([
4344
_setupEvents: function() {
4445
logger.debug(this.id + "._setupEvents");
4546
on(this.domNode, "click", lang.hitch(this, function(e) {
46-
this.execmf();
47+
this.execOnclick();
4748
if (this.stopClickPropagation) {
4849
e.stopPropagation();
4950
}
@@ -266,8 +267,8 @@ define([
266267
}
267268
},
268269

269-
execmf: function() {
270-
logger.debug(this.id + ".execmf");
270+
execOnclick: function() {
271+
logger.debug(this.id + ".execOnclick");
271272
if (!this._contextObj) {
272273
return;
273274
}
@@ -294,6 +295,16 @@ define([
294295

295296
mx.data.action(mfObject, this);
296297
}
298+
if (this.onclicknf.nanoflow) {
299+
mx.data.callNanoflow({
300+
nanoflow: this.onclicknf,
301+
origin: this.mxform,
302+
context: this.mxcontext,
303+
error: function(error) {
304+
logger.error(this.id + ": An error ocurred while executing nanflow: ", error);
305+
}
306+
});
307+
}
297308
},
298309

299310
_resetSubscriptions: function() {

test/FormatString.mpr

1.77 MB
Binary file not shown.

test/widgets/FormatString.mpk

135 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)