@@ -40,7 +40,7 @@ define([
4040
4141 // DOM elements
4242 divContent : null ,
43- divLoader : null ,
43+ divLoader : null ,
4444
4545 // Internal variables. Non-primitives created in the prototype are shared between all widget instances.
4646 _handles : null ,
@@ -49,7 +49,7 @@ define([
4949 _pageInitiated : false ,
5050 _form : null ,
5151 active : true ,
52- prevForm : null ,
52+ prevForm : null ,
5353 // dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
5454 constructor : function ( ) {
5555 //logger.debug(this.id + ".constructor");
@@ -59,26 +59,26 @@ define([
5959 // dijit._WidgetBase.postCreate is called after constructing the widget. Implement to do extra setup work.
6060 postCreate : function ( ) {
6161 logger . debug ( this . id + ".postCreate" ) ;
62-
63-
62+
63+
6464 this . _updateRendering ( ) ;
6565 this . _setupEvents ( ) ;
6666 } ,
6767
6868 // mxui.widget._WidgetBase.update is called when context is changed or initialized. Implement to re-render and / or fetch data.
6969 update : function ( obj , callback ) {
70- if ( this . _contextObj !== obj ) {
70+ if ( this . _contextObj !== obj ) {
7171 console . log ( this . id + ".update on new object" ) ;
7272 this . _loadingStarted = false ;
7373 this . _pageInitiated = false ;
74-
74+
7575 this . _contextObj = obj ;
7676 this . _resetSubscriptions ( ) ;
7777 this . _updateRendering ( callback ) ; // We're passing the callback to updateRendering to be called after DOM-manipulation
7878 } else {
7979 // The callback, coming from update, needs to be executed, to let the page know it finished rendering
8080 this . _executeCallback ( callback , "update" ) ;
81- }
81+ }
8282 } ,
8383
8484 // mxui.widget._WidgetBase.enable is called when the widget should enable editing. Implement to enable editing if widget is input widget.
@@ -96,13 +96,13 @@ define([
9696 console . log ( this . id + ".resize" ) ;
9797 // TODO: How to handle tabs and conditional visibility
9898 if ( this . domNode . offsetParent !== null && this . visibilityCheck ) {
99- if ( this . refreshAction == "Attribute" && this . refreshtAttr && this . _contextObj ) {
99+ if ( this . refreshAction == "Attribute" && this . refreshtAttr && this . _contextObj ) {
100100 if ( this . _contextObj . get ( this . refreshtAttr ) )
101101 this . _loadAndShowcontent ( ) ;
102102 else
103103 console . log ( this . id + ".resize Skip because " + this . refreshtAttr + " is false" ) ;
104104 } else {
105- this . _loadAndShowcontent ( ) ;
105+ this . _loadAndShowcontent ( ) ;
106106 }
107107 }
108108 } ,
@@ -112,8 +112,8 @@ define([
112112 logger . debug ( this . id + ".uninitialize" ) ;
113113 // Clean up listeners, helper objects, etc. There is no need to remove listeners added with this.connect / this.subscribe / this.own.
114114 this . active = false ;
115-
116- if ( this . _form != null ) {
115+
116+ if ( this . _form != null ) {
117117 this . _form . destroy ( ) ;
118118 }
119119 } ,
@@ -128,25 +128,39 @@ define([
128128
129129 // Attach events to HTML dom elements
130130 _setupEvents : function ( ) {
131- //logger.debug(this.id + "._setupEvents");
132- if ( this . fadeContent ) {
131+ // Set fading of content
132+ if ( this . fadeContent ) {
133133 dojoClass . add ( this . divContent , "loaderfade" ) ;
134134 }
135+
136+ // Set refreshing each time
137+ if ( this . refreshTime > 0 ) {
138+ setInterval ( dojoLang . hitch ( this , function ( ) {
139+ if ( this . _loadingStarted == false ) {
140+ if ( this . pageMF ) {
141+ this . _pageInitiated = false ;
142+ }
143+ this . _updateRendering ( ) ;
144+ } else {
145+ console . log ( this . id + ".Refresh skip because of loading started." ) ;
146+ }
147+ } ) , this . refreshTime * 1000 ) ;
148+ }
135149 } ,
136150
137151 // Rerender the interface.
138152 _updateRendering : function ( callback ) {
139153 logger . debug ( this . id + "._updateRendering" ) ;
140154
141155 if ( this . _contextObj ) {
142- if ( this . loadingText ) {
143- var text = "<div class=\"text-center\"><h3 class=\"loaderheader\">" + this . loadingText + "</h3></div>" ;
156+ if ( this . loadingText && this . divLoader . innerHTML . indexOf ( this . loadingText ) === - 1 ) {
157+ var text = "<div class=\"text-center\"><h3 class=\"loaderheader\">" + this . loadingText + "</h3></div>" ;
144158 this . divLoader . innerHTML = text + this . divLoader . innerHTML ;
145159 }
146-
160+
147161 dojoStyle . set ( this . divContent , "display" , "none" ) ;
148162 dojoStyle . set ( this . divLoader , "display" , "block" ) ;
149-
163+
150164 if ( this . domNode . offsetParent !== null || ! this . visibilityCheck ) {
151165 this . _loadAndShowcontent ( ) ;
152166 }
@@ -158,7 +172,7 @@ define([
158172
159173 _loadAndShowcontent : function ( ) {
160174 logger . debug ( this . id + "._loadAndShowcontent" ) ;
161- if ( this . _loadingStarted == false ) {
175+ if ( this . _loadingStarted == false ) {
162176 this . _loadingStarted = true ;
163177 if ( this . _contextObj && this . loadingMF ) {
164178 this . _execMf ( this . loadingMF , this . _contextObj . getGuid ( ) , this . _processMicroflowCallback , this . _processMicroflowFailure ) ;
@@ -171,26 +185,26 @@ define([
171185 _processMicroflowCallback : function ( objs ) {
172186 logger . debug ( this . id + '._processMicroflowCallback' ) ;
173187 if ( this . active ) {
174- if ( this . asyncCall )
188+ if ( this . asyncCall )
175189 this . _setPage ( this . _contextObj ) ;
176190 else
177191 this . _setPage ( objs [ 0 ] ) ;
178192 } else {
179- console . info ( this . id + "._processMicroflowCallback Skip loading because widget is destroyed." ) ;
193+ console . info ( this . id + "._processMicroflowCallback Skip loading because widget is destroyed." ) ;
180194 }
181195 } ,
182- _processMicroflowFailure : function ( ) {
183- if ( this . errorText ) {
184- if ( this . _pageInitiated )
196+ _processMicroflowFailure : function ( ) {
197+ if ( this . errorText ) {
198+ if ( this . _pageInitiated )
185199 this . _form . close ( ) ;
186200 this . _pageInitiated = false ;
187- this . divContent . innerHTML = "<div class=\"text-center\"><h3 class=\"loaderheader\">" + this . errorText + "</h3></div>" ;
201+ this . divContent . innerHTML = "<div class=\"text-center\"><h3 class=\"loaderheader\">" + this . errorText + "</h3></div>" ;
188202
189203 this . _showPage ( ) ;
190204 }
191205 } ,
192-
193- _openFormByFormProp : function ( pageContext ) {
206+
207+ _openFormByFormProp : function ( pageContext ) {
194208 var props = {
195209 location : "node" ,
196210 domNode : this . divContent ,
@@ -199,14 +213,14 @@ define([
199213 console . log ( error . description ) ;
200214 }
201215 } ;
202-
203- if ( pageContext )
216+
217+ if ( pageContext )
204218 props . context = pageContext ;
205219 this . _form = mx . ui . openForm ( this . pageContent , props ) ;
206220 } ,
207-
208- _openFormByMF : function ( pageObj , pageContext ) {
209- this . _execMf ( this . pageMF , pageObj . getGuid ( ) , function ( response ) {
221+
222+ _openFormByMF : function ( pageObj , pageContext ) {
223+ this . _execMf ( this . pageMF , pageObj . getGuid ( ) , function ( response ) {
210224 this . _form = mx . ui . openForm ( response , {
211225 context : pageContext ,
212226 location : "node" ,
@@ -216,55 +230,57 @@ define([
216230 console . log ( error . description ) ;
217231 }
218232 } ) ;
219- } , function ( ) { alert ( "Error bij aanroepen custom form MF" ) ; } ) ;
233+ } , function ( ) {
234+ alert ( "Error bij aanroepen custom form MF" ) ;
235+ } ) ;
220236 } ,
221237
222238 _setPage : function ( pageObj ) {
223239 logger . debug ( this . id + '._setPage' ) ;
224240
225- if ( this . _pageInitiated ) {
241+ if ( this . _pageInitiated ) {
226242 if ( this . _loadingStarted ) {
227243 this . _showPage ( ) ;
228244 } else {
229245 console . log ( this . id + "_setPage skip because already set." ) ;
230246 }
231247 } else {
232248 this . _pageInitiated = true ;
233- this . divContent . innerHTML = "" ;
249+ this . divContent . innerHTML = "" ;
234250 console . log ( this . id + "_setPage" ) ;
235251 if ( pageObj ) {
236252 var pageContext = new mendix . lib . MxContext ( ) ;
237253 pageContext . setTrackObject ( pageObj ) ;
238-
239- if ( this . pageMF != null && this . pageMF != '' )
254+
255+ if ( this . pageMF != null && this . pageMF != '' )
240256 this . _openFormByMF ( pageObj , pageContext ) ;
241- else
257+ else
242258 this . _openFormByFormProp ( pageContext ) ;
243-
259+
244260 } else {
245- if ( this . pageMF != null && this . pageMF != '' )
261+ if ( this . pageMF != null && this . pageMF != '' )
246262 alert ( "Page microflow is not supported without context" ) ;
247- else
263+ else
248264 this . _openFormByFormProp ( ) ;
249-
265+
250266 }
251267 }
252268 } ,
253269
254270 _showPage : function ( mxform ) {
255271 logger . debug ( this . id + "._showPage on form" ) ;
256-
257- if ( this . prevForm != null && mxform != null ) {
272+
273+ if ( this . prevForm != null && mxform != null ) {
258274 this . prevForm . destroy ( ) ;
259275 }
260276 this . prevForm = mxform ;
261-
277+
262278 dojoStyle . set ( this . divContent , "display" , "block" ) ;
263279 dojoStyle . set ( this . divLoader , "display" , "none" ) ;
264-
280+
265281 this . _loadingStarted = false ;
266282 } ,
267-
283+
268284 // Reset subscriptions.
269285 _resetSubscriptions : function ( ) {
270286 logger . debug ( this . id + "._resetSubscriptions" ) ;
@@ -277,37 +293,39 @@ define([
277293 this . subscribe ( {
278294 guid : this . _contextObj . getGuid ( ) ,
279295 callback : dojoLang . hitch ( this , function ( guid ) {
280- if ( this . _loadingStarted == false ) {
281- if ( this . pageMF ) {
296+ if ( this . _loadingStarted == false ) {
297+ if ( this . pageMF ) {
282298 this . _pageInitiated = false ;
283299 }
284- if ( this . refreshAction == "Attribute" && this . refreshtAttr && this . _contextObj . get ( this . refreshtAttr ) ) {
300+ if ( this . refreshAction == "Attribute" && this . refreshtAttr && this . _contextObj . get ( this . refreshtAttr ) ) {
285301 console . log ( this . id + ".Refresh triggered on attribute change." ) ;
286302 this . _updateRendering ( ) ;
287- } else if ( this . refreshAction == "Object" ) {
303+ } else if ( this . refreshAction == "Object" ) {
288304 console . log ( this . id + ".Refresh triggered on object change." ) ;
289305 this . _updateRendering ( ) ;
290- }
306+ }
291307 } else {
292308 console . log ( this . id + ".Refresh skip because of loading started." ) ;
293309 }
294310 } )
295311 } ) ;
296312 }
297313 } ,
298-
314+
299315 _execMf : function ( mf , guid , cb , cbfailure ) {
300316 logger . debug ( this . id + "._execMf" + ( mf ? ": " + mf : "" ) ) ;
301317 if ( mf && guid ) {
302- mx . ui . action ( mf , {
303- async : this . asyncCall ,
318+ mx . data . action ( {
304319 params : {
305320 applyto : "selection" ,
321+ actionname : mf ,
306322 guids : [ guid ]
307323 } ,
324+ async : this . asyncCall ,
325+ origin : this . mxform ,
308326 callback : ( cb && typeof cb === "function" ? dojoLang . hitch ( this , cb ) : null ) ,
309327 error : ( cbfailure && typeof cbfailure === "function" ? dojoLang . hitch ( this , cbfailure ) : null )
310- } , this ) ;
328+ } ) ;
311329 }
312330 } ,
313331
@@ -320,4 +338,4 @@ define([
320338 } ) ;
321339} ) ;
322340
323- require ( [ "DataviewLoader/widget/DataviewLoader" ] ) ;
341+ require ( [ "DataviewLoader/widget/DataviewLoader" ] ) ;
0 commit comments