@@ -30,6 +30,8 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
3030 minWidth : 300 ,
3131 } ) ;
3232
33+ this . __categoryHeaders = [ ] ;
34+
3335 this . __addItems ( ) ;
3436 } ,
3537
@@ -81,6 +83,8 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
8183 } ,
8284
8385 members : {
86+ __categoryHeaders : null ,
87+
8488 _createChildControlImpl : function ( id ) {
8589 let control ;
8690 switch ( id ) {
@@ -152,9 +156,21 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
152156 } ) ;
153157 } ,
154158
159+ __getLastIdxFromCategory : function ( categoryId ) {
160+ for ( let i = this . getChildren ( ) . length - 1 ; i >= 0 ; i -- ) {
161+ const child = this . getChildren ( ) [ i ] ;
162+ if ( child && child [ "categoryId" ] && child [ "categoryId" ] === categoryId ) {
163+ return i ;
164+ }
165+ }
166+ return null ;
167+ } ,
168+
155169 __addCategories : function ( categories ) {
156170 categories . forEach ( category => {
157171 const categoryHeader = this . self ( ) . createHeader ( category [ "title" ] , null , category [ "description" ] ) ;
172+ categoryHeader . categoryId = category [ "id" ] ;
173+ this . __categoryHeaders . push ( categoryHeader ) ;
158174 this . add ( categoryHeader ) ;
159175 } ) ;
160176 } ,
@@ -171,7 +187,15 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
171187 toolTipText : templateData . description ,
172188 } ) ;
173189 }
174- this . add ( menuButton ) ;
190+ let idx = null ;
191+ if ( templateData . category ) {
192+ idx = this . __getLastIdxFromCategory ( templateData . category ) ;
193+ }
194+ if ( idx ) {
195+ this . addAt ( menuButton , idx + 1 ) ;
196+ } else {
197+ this . add ( menuButton ) ;
198+ }
175199 return ;
176200 }
177201
0 commit comments