Skip to content

Commit 62990cb

Browse files
committed
Added no context widget
1 parent f11e0c5 commit 62990cb

File tree

8 files changed

+27
-82
lines changed

8 files changed

+27
-82
lines changed

src/CustomStringNoContext/CustomStringNoContext.xml renamed to src/CustomString/CustomStringNoContext.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<widget id="CustomStringNoContext.widget.CustomStringNoContext" needsEntityContext="false" xmlns="http://www.mendix.com/widget/1.0/">
2+
<widget id="CustomString.widget.CustomStringNoContext" needsEntityContext="false" xmlns="http://www.mendix.com/widget/1.0/">
33
<name>CustomString (No Context)</name>
44
<description></description>
55

src/CustomString/widget/CustomString.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ define([
5353
update: function(obj, callback) {
5454
this._contextObj = obj;
5555

56-
this._resetSubscriptions();
57-
this._updateRendering();
58-
56+
if(this._contextObj)
57+
{
58+
this._resetSubscriptions();
59+
this._updateRendering();
60+
}
5961
callback();
6062
},
6163

@@ -93,9 +95,7 @@ define([
9395
guids : [this._contextObj.getGuid()]
9496

9597
},
96-
callback : dojoLang.hitch(this,function(returnedString) {
97-
this.customString.innerHTML = this.checkString(returnedString, this.renderHTML);
98-
}),
98+
callback : dojoLang.hitch(this, this._processSourceMFCallback),
9999
error : dojoLang.hitch(this, function(error) {
100100
alert(error.description);
101101
}),
@@ -105,10 +105,14 @@ define([
105105
});
106106
},
107107

108+
_processSourceMFCallback: function(returnedString) {
109+
this.customString.innerHTML = this.checkString(returnedString, this.renderHTML);
110+
},
111+
108112
checkString : function (string, htmlBool) {
109-
if(string.indexOf("<script") > -1 || !htmlBool)
110-
string = mxui.dom.escapeHTML(string);
111-
return string;
113+
if(string.indexOf("<script") > -1 || !htmlBool)
114+
string = mxui.dom.escapeHTML(string);
115+
return string;
112116
},
113117

114118
// Reset subscriptions.
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,13 @@
1-
/*
2-
CustomString
3-
========================
4-
5-
@file : CustomString.js
6-
@version : 2.0.0
7-
@author : Roeland Salij
8-
@date : Thursday, December 03, 2015
9-
@copyright : Mendix 2015
10-
@license : Apache 2
11-
12-
Documentation
13-
========================
14-
Describe your widget here.
15-
*/
161

172
// Required module list. Remove unnecessary modules, you can always get them back from the boilerplate.
18-
define([
19-
"dojo/_base/declare",
20-
"mxui/widget/_WidgetBase",
21-
"dijit/_TemplatedMixin",
22-
"dojo/_base/array",
23-
"dojo/_base/lang",
24-
"dojo/text!CustomStringNoContext/widget/template/CustomStringNoContext.html"
25-
], function(declare, _WidgetBase, _TemplatedMixin, dojoArray, dojoLang, widgetTemplate) {
26-
"use strict";
27-
3+
require([
4+
'dojo/_base/declare',
5+
'dojo/_base/lang',
6+
'CustomString/widget/CustomString'
7+
], function (declare, dojoLang,_customStringNoContextWidget) {
8+
289
// Declare widget's prototype.
29-
return declare("CustomStringNoContext.widget.CustomStringNoContext", [ _WidgetBase, _TemplatedMixin ], {
30-
// _TemplatedMixin will create our dom node using this HTML template.
31-
templateString: widgetTemplate,
32-
33-
// Parameters configured in the Modeler.
34-
sourceMF: "",
35-
renderHTML: "",
36-
37-
// Internal variables. Non-primitives created in the prototype are shared between all widget instances.
38-
_handles: null,
39-
_alertDiv: null,
40-
41-
// dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
42-
constructor: function() {
43-
this._handles = [];
44-
},
10+
return declare("CustomString.widget.CustomStringNoContext", [ _customStringNoContextWidget ], {
4511

4612
// dijit._WidgetBase.postCreate is called after constructing the widget. Implement to do extra setup work.
4713
postCreate: function() {
@@ -56,14 +22,14 @@ define([
5622
if(this.mfToExecute){
5723
this.connect(this.customString, "click", this._executeMicroflow)};
5824
},
25+
26+
5927
_render : function () {
6028
mx.data.action({
6129
params : {
6230
actionname : this.sourceMF
6331
},
64-
callback : dojoLang.hitch(this,function(returnedString) {
65-
this.customString.innerHTML = this.checkString(returnedString, this.renderHTML);
66-
}),
32+
callback : dojoLang.hitch(this, this._processSourceMFCallback),
6733
error : dojoLang.hitch(this, function(error) {
6834
alert(error.description);
6935
}),
@@ -94,14 +60,9 @@ define([
9460
},
9561

9662

97-
checkString : function (string, htmlBool) {
98-
if(string.indexOf("<script") > -1 || !htmlBool)
99-
string = mxui.dom.escapeHTML(string);
100-
return string;
101-
}
10263
});
10364
});
10465

105-
require(["CustomStringNoContext/widget/CustomStringNoContext"], function() {
66+
require(["CustomString/widget/CustomStringNoContext"], function() {
10667
"use strict";
10768
});

src/CustomStringNoContext/widget/template/CustomStringNoContext.html

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/CustomStringNoContext/widget/ui/CustomString.css

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/package.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="CustomString" version="2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="CustomString" version="2.1" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="CustomString/CustomString.xml" />
6-
<widgetFile path="CustomStringNoContext/CustomStringNoContext.xml" />
6+
<widgetFile path="CustomString/CustomStringNoContext.xml" />
77
</widgetFiles>
88
<files>
99
<file path="CustomString/widget/" />
10-
<file path="CustomStringNoContext/widget/" />
1110
</files>
1211
</clientModule>
1312
</package>

test/CustomStringTest.mpr

2 KB
Binary file not shown.

test/widgets/CustomString.mpk

-1.79 KB
Binary file not shown.

0 commit comments

Comments
 (0)