@@ -44,11 +44,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
4444 members : {
4545 __resourceData : null ,
4646 __showOrganizations : null ,
47-
48- __collabButtonsContainer : null ,
49- __searchingCollaborators : null ,
5047 __searchDelayer : null ,
51- __shareButton : null ,
5248 __selectedCollaborators : null ,
5349 __potentialCollaborators : null ,
5450
@@ -79,12 +75,39 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
7975 this . add ( control ) ;
8076 break ;
8177 }
78+ case "potential-collaborators-list" : {
79+ control = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( ) ) ;
80+ const scrollContainer = new qx . ui . container . Scroll ( ) ;
81+ scrollContainer . add ( control ) ;
82+ this . add ( scrollContainer , {
83+ flex : 1
84+ } ) ;
85+ break ;
86+ }
87+ case "searching-collaborators" :
88+ control = new osparc . filter . SearchingCollaborators ( ) ;
89+ control . exclude ( ) ;
90+ this . getChildControl ( "potential-collaborators-list" ) . add ( control ) ;
91+ break ;
92+ case "buttons-layout" :
93+ control = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( ) . set ( {
94+ alignX : "right"
95+ } ) ) ;
96+ this . add ( control ) ;
97+ break ;
98+ case "share-button" :
99+ control = new osparc . ui . form . FetchButton ( this . tr ( "Share" ) ) . set ( {
100+ appearance : "form-button" ,
101+ enabled : false ,
102+ } ) ;
103+ this . getChildControl ( "buttons-layout" ) . add ( control ) ;
104+ break ;
82105 }
83106 return control || this . base ( arguments , id ) ;
84107 } ,
85108
86109 getActionButton : function ( ) {
87- return this . __shareButton ;
110+ return this . getChildControl ( "share-button" ) ;
88111 } ,
89112
90113 __renderLayout : function ( ) {
@@ -105,39 +128,23 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
105128 }
106129 } ) ;
107130
108- const collabButtonsContainer = this . __collabButtonsContainer = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( ) ) ;
109- const scrollContainer = new qx . ui . container . Scroll ( ) ;
110- scrollContainer . add ( collabButtonsContainer ) ;
111- this . add ( scrollContainer , {
112- flex : 1
113- } ) ;
114-
115- const searchingCollaborators = this . __searchingCollaborators = new osparc . filter . SearchingCollaborators ( ) ;
116- searchingCollaborators . exclude ( ) ;
117- this . __collabButtonsContainer . add ( searchingCollaborators ) ;
131+ this . getChildControl ( "potential-collaborators-list" ) ;
132+ this . getChildControl ( "searching-collaborators" ) ;
118133
119- const buttons = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( ) . set ( {
120- alignX : "right"
121- } ) ) ;
122- const shareButton = this . __shareButton = new osparc . ui . form . FetchButton ( this . tr ( "Share" ) ) . set ( {
123- appearance : "form-button" ,
124- enabled : false ,
125- } ) ;
134+ const shareButton = this . getChildControl ( "share-button" ) ;
126135 shareButton . addListener ( "execute" , ( ) => this . __shareClicked ( ) , this ) ;
127- buttons . add ( shareButton ) ;
128- this . add ( buttons ) ;
129136 } ,
130137
131138 __searchUsers : function ( ) {
132- this . __searchingCollaborators . show ( ) ;
139+ this . getChildControl ( "searching-collaborators" ) . show ( ) ;
133140 const text = this . getChildControl ( "text-filter" ) . getChildControl ( "textfield" ) . getValue ( ) ;
134141 osparc . store . Users . getInstance ( ) . searchUsers ( text )
135142 . then ( users => {
136143 users . forEach ( user => user [ "collabType" ] = 2 ) ;
137144 this . __addPotentialCollaborators ( users ) ;
138145 } )
139146 . catch ( err => osparc . FlashMessenger . logError ( err ) )
140- . finally ( ( ) => this . __searchingCollaborators . exclude ( ) ) ;
147+ . finally ( ( ) => this . getChildControl ( "searching-collaborators" ) . exclude ( ) ) ;
141148 } ,
142149
143150 __showProductEveryone : function ( ) {
@@ -177,7 +184,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
177184 this . __selectedCollaborators . splice ( idx , 1 ) ;
178185 }
179186 }
180- this . __shareButton . setEnabled ( Boolean ( this . __selectedCollaborators . length ) ) ;
187+ this . getChildControl ( "share-button" ) . setEnabled ( Boolean ( this . __selectedCollaborators . length ) ) ;
181188 } , this ) ;
182189 collaboratorButton . subscribeToFilterGroup ( "collaboratorsManager" ) ;
183190 return collaboratorButton ;
@@ -221,23 +228,24 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
221228 return ;
222229 }
223230 // do not list those that were already listed
224- if ( this . __collabButtonsContainer . getChildren ( ) . find ( c => "groupId" in c && c [ "groupId" ] === potentialCollaborator . getGroupId ( ) ) ) {
231+ if ( this . getChildControl ( "potential-collaborators-list" ) . getChildren ( ) . find ( c => "groupId" in c && c [ "groupId" ] === potentialCollaborator . getGroupId ( ) ) ) {
225232 return ;
226233 }
227234 if ( this . __showOrganizations === false && potentialCollaborator [ "collabType" ] !== 2 ) {
228235 return ;
229236 }
230- this . __collabButtonsContainer . add ( this . __collaboratorButton ( potentialCollaborator ) ) ;
237+ this . getChildControl ( "potential-collaborators-list" ) . add ( this . __collaboratorButton ( potentialCollaborator ) ) ;
231238 } ) ;
232239
233240 // move it to last position
234- this . __collabButtonsContainer . remove ( this . __searchingCollaborators ) ;
235- this . __collabButtonsContainer . add ( this . __searchingCollaborators ) ;
241+ const searching = this . getChildControl ( "searching-collaborators" ) ;
242+ this . getChildControl ( "potential-collaborators-list" ) . remove ( searching ) ;
243+ this . getChildControl ( "potential-collaborators-list" ) . add ( searching ) ;
236244 } ,
237245
238246 __shareClicked : function ( ) {
239- this . __collabButtonsContainer . setEnabled ( false ) ;
240- this . __shareButton . setFetching ( true ) ;
247+ this . getChildControl ( "potential-collaborators-list" ) . setEnabled ( false ) ;
248+ this . getChildControl ( "share-button" ) . setFetching ( true ) ;
241249
242250 if ( this . __selectedCollaborators . length ) {
243251 this . fireDataEvent ( "addCollaborators" , this . __selectedCollaborators ) ;
0 commit comments