@@ -62,11 +62,28 @@ qx.Class.define("qxapp.component.form.renderer.PropForm", {
6262 }
6363 } ,
6464
65+ statics : {
66+ getRetrievingAtom : function ( ) {
67+ return new qx . ui . basic . Atom ( "" , "qxapp/loading.gif" ) ;
68+ } ,
69+
70+ getRetrievedAtom : function ( success ) {
71+ const icon = success ? "@FontAwesome5Solid/check/12" : "@FontAwesome5Solid/times/12" ;
72+ return new qx . ui . basic . Atom ( "" , icon ) ;
73+ }
74+ } ,
75+
6576 // eslint-disable-next-line qx-rules/no-refs-in-members
6677 members : {
6778 _gridPos : {
6879 label : 0 ,
69- entryField : 1
80+ entryField : 1 ,
81+ retrieveStatus : 2
82+ } ,
83+ _retrieveStatus : {
84+ failed : 0 ,
85+ retrieving : 1 ,
86+ succeed : 2
7087 } ,
7188 addItems : function ( items , names , title , itemOptions , headerOptions ) {
7289 // add the header
@@ -90,7 +107,10 @@ qx.Class.define("qxapp.component.form.renderer.PropForm", {
90107 column : this . _gridPos . label
91108 } ) ;
92109 label . setBuddy ( item ) ;
93- this . _add ( new qxapp . component . form . FieldWHint ( null , item . description , item ) , {
110+
111+ const field = new qxapp . component . form . FieldWHint ( null , item . description , item ) ;
112+ field . key = item . key ;
113+ this . _add ( field , {
94114 row : this . _row ,
95115 column : this . _gridPos . entryField
96116 } ) ;
@@ -149,51 +169,176 @@ qx.Class.define("qxapp.component.form.renderer.PropForm", {
149169 return filteredData ;
150170 } ,
151171
152- linkAdded : function ( portId ) {
153- let children = this . _getChildren ( ) ;
172+ __getLayoutChild ( portId , column ) {
173+ let row = null ;
174+ const children = this . _getChildren ( ) ;
154175 for ( let i = 0 ; i < children . length ; i ++ ) {
155- let child = children [ i ] ;
156- if ( child . getField && child . getField ( ) . key === portId ) {
176+ const child = children [ i ] ;
177+ const layoutProps = child . getLayoutProperties ( ) ;
178+ if ( layoutProps . column === this . _gridPos . label &&
179+ child . getBuddy ( ) . key === portId ) {
180+ row = layoutProps . row ;
181+ break ;
182+ }
183+ }
184+ if ( row !== null ) {
185+ for ( let i = 0 ; i < children . length ; i ++ ) {
186+ const child = children [ i ] ;
157187 const layoutProps = child . getLayoutProperties ( ) ;
158- this . _remove ( child ) ;
188+ if ( layoutProps . column === column &&
189+ layoutProps . row === row ) {
190+ return {
191+ child,
192+ idx : i
193+ } ;
194+ }
195+ }
196+ }
197+ return null ;
198+ } ,
159199
160- const hBox = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 5 ) ) ;
161- hBox . add ( this . _form . getControlLink ( portId ) , {
162- flex : 1
163- } ) ;
200+ __getEntryFieldChild ( portId ) {
201+ return this . __getLayoutChild ( portId , this . _gridPos . entryField ) ;
202+ } ,
203+
204+ __getRetrieveStatusChild ( portId ) {
205+ return this . __getLayoutChild ( portId , this . _gridPos . retrieveStatus ) ;
206+ } ,
207+
208+ linkAdded : function ( portId ) {
209+ let data = this . __getEntryFieldChild ( portId ) ;
210+ if ( data ) {
211+ let child = data . child ;
212+ let idx = data . idx ;
213+ const layoutProps = child . getLayoutProperties ( ) ;
214+ this . _remove ( child ) ;
215+
216+ const hBox = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 5 ) ) ;
217+ hBox . add ( this . _form . getControlLink ( portId ) , {
218+ flex : 1
219+ } ) ;
164220
165- const unlinkBtn = new qx . ui . form . Button ( this . tr ( "Unlink" ) , "@FontAwesome5Solid/unlink/14" ) ;
166- unlinkBtn . addListener ( "execute" , function ( ) {
167- this . fireDataEvent ( "removeLink" , portId ) ;
168- } , this ) ;
169- hBox . add ( unlinkBtn ) ;
221+ const unlinkBtn = new qx . ui . form . Button ( this . tr ( "Unlink" ) , "@FontAwesome5Solid/unlink/14" ) ;
222+ unlinkBtn . addListener ( "execute" , function ( ) {
223+ this . fireDataEvent ( "removeLink" , portId ) ;
224+ } , this ) ;
225+ hBox . add ( unlinkBtn ) ;
226+
227+ hBox . key = portId ;
228+ this . _addAt ( hBox , idx , {
229+ row : layoutProps . row ,
230+ column : this . _gridPos . entryField
231+ } ) ;
170232
171- hBox . key = portId ;
172- this . _addAt ( hBox , i , {
233+ this . fireDataEvent ( "dataFieldModified" , portId ) ;
234+ }
235+ } ,
236+
237+ linkRemoved : function ( portId ) {
238+ let data = this . __getEntryFieldChild ( portId ) ;
239+ if ( data ) {
240+ let child = data . child ;
241+ let idx = data . idx ;
242+ const layoutProps = child . getLayoutProperties ( ) ;
243+ if ( layoutProps . column === this . _gridPos . entryField ) {
244+ this . _remove ( child ) ;
245+ const field = new qxapp . component . form . FieldWHint ( null , this . _form . getControl ( portId ) . description , this . _form . getControl ( portId ) ) ;
246+ this . _addAt ( field , idx , {
173247 row : layoutProps . row ,
174- column : this . _gridPos . entryField
248+ column : layoutProps . column
175249 } ) ;
176250
177251 this . fireDataEvent ( "dataFieldModified" , portId ) ;
178252 }
179253 }
180254 } ,
181255
182- linkRemoved : function ( portId ) {
256+ retrievingPortData : function ( portId ) {
257+ const status = this . _retrieveStatus . retrieving ;
258+ if ( portId ) {
259+ let data = this . __getEntryFieldChild ( portId ) ;
260+ if ( data ) {
261+ let child = data . child ;
262+ let idx = data . idx ;
263+ const layoutProps = child . getLayoutProperties ( ) ;
264+ this . __setRetrievingStatus ( status , portId , idx + 1 , layoutProps . row ) ;
265+ }
266+ } else {
267+ for ( let i = this . _getChildren ( ) . length ; i -- ; ) {
268+ let child = this . _getChildren ( ) [ i ] ;
269+ const layoutProps = child . getLayoutProperties ( ) ;
270+ if ( layoutProps . column === this . _gridPos . entryField ) {
271+ const ctrl = this . _form . getControl ( child . key ) ;
272+ if ( ctrl && ctrl . link ) {
273+ this . __setRetrievingStatus ( status , child . key , i , layoutProps . row ) ;
274+ }
275+ }
276+ }
277+ }
278+ } ,
279+
280+ retrievedPortData : function ( portId , succeed ) {
281+ const status = succeed ? this . _retrieveStatus . succeed : this . _retrieveStatus . failed ;
282+ if ( portId ) {
283+ let data = this . __getEntryFieldChild ( portId ) ;
284+ if ( data ) {
285+ let child = data . child ;
286+ let idx = data . idx ;
287+ const layoutProps = child . getLayoutProperties ( ) ;
288+ // this._remove(child);
289+ this . __setRetrievingStatus ( status , portId , idx + 1 , layoutProps . row ) ;
290+ }
291+ } else {
292+ let children = this . _getChildren ( ) ;
293+ for ( let i = 0 ; i < children . length ; i ++ ) {
294+ let child = children [ i ] ;
295+ const layoutProps = child . getLayoutProperties ( ) ;
296+ if ( layoutProps . column === this . _gridPos . retrieveStatus ) {
297+ // this._remove(child);
298+ this . __setRetrievingStatus ( status , portId , i , layoutProps . row ) ;
299+ }
300+ }
301+ }
302+ } ,
303+
304+ __setRetrievingStatus : function ( status , portId , idx , row ) {
305+ let icon ;
306+ switch ( status ) {
307+ case this . _retrieveStatus . failed :
308+ icon = qxapp . component . form . renderer . PropForm . getRetrievedAtom ( false ) ;
309+ break ;
310+ case this . _retrieveStatus . retrieving :
311+ icon = qxapp . component . form . renderer . PropForm . getRetrievingAtom ( ) ;
312+ break ;
313+ case this . _retrieveStatus . succeed :
314+ icon = qxapp . component . form . renderer . PropForm . getRetrievedAtom ( true ) ;
315+ break ;
316+ }
317+ icon . key = portId ;
318+
319+ // remove first if any
183320 let children = this . _getChildren ( ) ;
184321 for ( let i = 0 ; i < children . length ; i ++ ) {
185322 let child = children [ i ] ;
186- if ( "key" in child && child . key === portId ) {
187- const layoutProps = child . getLayoutProperties ( ) ;
323+ const layoutProps = child . getLayoutProperties ( ) ;
324+ if ( layoutProps . row === row &&
325+ layoutProps . column === this . _gridPos . retrieveStatus ) {
188326 this . _remove ( child ) ;
189- this . _addAt ( new qxapp . component . form . FieldWHint ( null , this . _form . getControl ( portId ) . description , this . _form . getControl ( portId ) ) , i , {
190- row : layoutProps . row ,
191- column : this . _gridPos . entryField
192- } ) ;
193-
194- this . fireDataEvent ( "dataFieldModified" , portId ) ;
195327 }
196328 }
329+
330+ this . _addAt ( icon , idx , {
331+ row : row ,
332+ column : this . _gridPos . retrieveStatus
333+ } ) ;
334+ } ,
335+
336+ __isInputData : function ( portId ) {
337+ const port = this . getNode ( ) . getInput ( portId ) ;
338+ if ( port ) {
339+ return port . type . includes ( "data" ) ;
340+ }
341+ return false ;
197342 } ,
198343
199344 __arePortsCompatible : function ( node1Id , port1Id , node2Id , port2Id ) {
0 commit comments