@@ -14,55 +14,63 @@ class MirrorStrings extends WidgetBase {
14
14
private contextObj : mendix . lib . MxObject ;
15
15
private message : string ;
16
16
private textString : string ;
17
+ private msg : string ;
17
18
18
19
postCreate ( ) {
19
- this . setupEvents ( ) ;
20
+ console . log ( "Your program has executed postCreate" ) ;
20
21
}
21
22
22
23
update ( object : mendix . lib . MxObject , callback ?: ( ) => void ) {
23
24
this . contextObj = object ;
24
- // this.resetSubscriptions();
25
+ this . resetSubscriptions ( ) ;
25
26
this . updateRendering ( ) ;
26
-
27
27
if ( callback ) {
28
28
callback ( ) ;
29
29
}
30
30
}
31
31
32
- uninitialize ( ) : boolean {
32
+ uninitialise ( ) : boolean {
33
33
return true ;
34
34
}
35
35
36
36
private setupEvents ( ) {
37
37
if ( this . mfToExecute !== "" ) {
38
- //this.execMf(this.mfToExecute, this.contextObj.getGuid());
38
+ // this.execMf(this.mfToExecute, this.contextObj.getGuid());
39
39
}
40
40
}
41
41
42
42
private TextInput ( ) {
43
43
domConstruct . create ( "input" , {
44
44
class : "form-control" ,
45
45
type : "text" ,
46
- value : "Place some Text Here "
46
+ value : "Place Some text here "
47
47
} , 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 ) ;
50
54
51
55
domConstruct . create ( "input" , {
52
56
class : "form-control btn-default" ,
53
57
type : "button" ,
54
58
value : "Post"
55
59
} , this . domNode ) . addEventListener ( "click" , ( ) => {
56
60
this . createTag ( ) ;
57
- } )
61
+ } ) ;
62
+ }
63
+
64
+ private reverseString ( str : string ) {
65
+ return str . split ( "" ) . reverse ( ) . join ( "" ) ;
58
66
}
59
67
60
68
private createTag ( ) {
61
69
// let dataatttr = this.dataAttribute
62
70
// let txtstr = this.textString
63
71
mx . data . create ( {
64
72
entity : this . reverseEntity ,
65
- callback : this . saveTag ,
73
+ callback : this . saveTag ,
66
74
// function (obj: mendix.lib.MxObject) {
67
75
// obj.set(dataatttr, txtstr)
68
76
// this.saveTag(obj)
@@ -90,7 +98,8 @@ class MirrorStrings extends WidgetBase {
90
98
91
99
private updateRendering ( ) {
92
100
if ( this . contextObj !== null ) {
93
-
101
+ this . msg = this . contextObj . get ( this . dataAttribute ) as string ;
102
+ this . TextInput ( ) ;
94
103
}
95
104
}
96
105
@@ -113,11 +122,19 @@ class MirrorStrings extends WidgetBase {
113
122
} , this ) ;
114
123
}
115
124
}
116
- }
117
125
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
+ }
118
136
119
- // tslint:disable : only-arrow-functions
120
- dojoDeclare ( "MirrorStrings.widget.MirrorStrings" , [ WidgetBase ] , function ( Source : any ) {
137
+ dojoDeclare ( "widget.MirrorStrings" , [ WidgetBase ] , function ( Source : any ) {
121
138
const result : any = { } ;
122
139
for ( const i in Source . prototype ) {
123
140
if ( i !== "constructor" && Source . prototype . hasOwnProperty ( i ) ) {
0 commit comments