Skip to content

Commit 7bc8ec1

Browse files
committed
Adding resetSubscriptions, ReverseString
1 parent 669b8cb commit 7bc8ec1

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dist/
22
node_modules/
33
test/
4-
./history
4+
.history

src/widget/MirrorStrings.ts renamed to src/MirrorStrings.ts

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,63 @@ class MirrorStrings extends WidgetBase {
1414
private contextObj: mendix.lib.MxObject;
1515
private message: string;
1616
private textString: string;
17+
private msg: string;
1718

1819
postCreate() {
19-
this.setupEvents();
20+
console.log("Your program has executed postCreate");
2021
}
2122

2223
update(object: mendix.lib.MxObject, callback?: () => void) {
2324
this.contextObj = object;
24-
//this.resetSubscriptions();
25+
this.resetSubscriptions();
2526
this.updateRendering();
26-
2727
if (callback) {
2828
callback();
2929
}
3030
}
3131

32-
uninitialize(): boolean {
32+
uninitialise(): boolean {
3333
return true;
3434
}
3535

3636
private setupEvents() {
3737
if (this.mfToExecute !== "") {
38-
//this.execMf(this.mfToExecute, this.contextObj.getGuid());
38+
// this.execMf(this.mfToExecute, this.contextObj.getGuid());
3939
}
4040
}
4141

4242
private TextInput() {
4343
domConstruct.create("input", {
4444
class: "form-control",
4545
type: "text",
46-
value: "Place some Text Here"
46+
value: "Place Some text here"
4747
}, this.domNode).addEventListener("mouseleave", () => {
48-
this.setupEvents();
49-
})
48+
// this.setupEvents();
49+
});
50+
51+
domConstruct.create("span", {
52+
value: this.reverseString("sam")
53+
}, this.domNode);
5054

5155
domConstruct.create("input", {
5256
class: "form-control btn-default",
5357
type: "button",
5458
value: "Post"
5559
}, this.domNode).addEventListener("click", () => {
5660
this.createTag();
57-
})
61+
});
62+
}
63+
64+
private reverseString(str: string) {
65+
return str.split("").reverse().join("");
5866
}
5967

6068
private createTag() {
6169
// let dataatttr = this.dataAttribute
6270
// let txtstr = this.textString
6371
mx.data.create({
6472
entity: this.reverseEntity,
65-
callback: this.saveTag,
73+
callback: this.saveTag,
6674
// function (obj: mendix.lib.MxObject) {
6775
// obj.set(dataatttr, txtstr)
6876
// this.saveTag(obj)
@@ -90,7 +98,8 @@ class MirrorStrings extends WidgetBase {
9098

9199
private updateRendering() {
92100
if (this.contextObj !== null) {
93-
101+
this.msg = this.contextObj.get(this.dataAttribute) as string;
102+
this.TextInput();
94103
}
95104
}
96105

@@ -113,11 +122,19 @@ class MirrorStrings extends WidgetBase {
113122
}, this);
114123
}
115124
}
116-
}
117125

126+
private resetSubscriptions() {
127+
this.unsubscribeAll();
128+
if (this.contextObj) {
129+
this.subscribe({
130+
callback: () => this.updateRendering(),
131+
guid: this.contextObj.getGuid()
132+
});
133+
}
134+
}
135+
}
118136

119-
// tslint:disable : only-arrow-functions
120-
dojoDeclare("MirrorStrings.widget.MirrorStrings", [WidgetBase], function (Source: any) {
137+
dojoDeclare("widget.MirrorStrings", [WidgetBase], function (Source: any) {
121138
const result: any = {};
122139
for (const i in Source.prototype) {
123140
if (i !== "constructor" && Source.prototype.hasOwnProperty(i)) {

src/widget/MirrorStrings.xml renamed to src/MirrorStrings.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="MirrorStrings.widget.MirrorStrings" needsEntityContext="true" xmlns="http://www.mendix.com/widget/1.0/">
2+
<widget id="widget.MirrorStrings" needsEntityContext="true" xmlns="http://www.mendix.com/widget/1.0/">
33
<name>MirrorStrings</name>
44
<description>The description of this widget.</description>
55
<icon />
File renamed without changes.

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var CopyWebpackPlugin = require("copy-webpack-plugin");
33
const ExtractTextPlugin = require("extract-text-webpack-plugin");
44

55
module.exports = {
6-
entry: "./src/widget/MirrorStrings.ts",
6+
entry: "./src/MirrorStrings.ts",
77
output: {
88
path: __dirname + "/dist/tmp",
99
filename: "src/widget/MirrorStrings.js",

0 commit comments

Comments
 (0)