@@ -57,8 +57,35 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
5757 __tagButtons : null ,
5858 __appTypeButtons : null ,
5959
60+ _createChildControlImpl : function ( id ) {
61+ let control ;
62+ switch ( id ) {
63+ case "filters-spacer" :
64+ control = new qx . ui . core . Spacer ( 10 , 10 ) ;
65+ this . _add ( control ) ;
66+ break ;
67+ case "shared-with-layout" :
68+ control = this . __createSharedWithFilterLayout ( ) ;
69+ this . _add ( control ) ;
70+ break ;
71+ case "app-type-layout" :
72+ control = this . __createAppTypeFilterLayout ( ) ;
73+ this . _add ( control ) ;
74+ break ;
75+ case "tags-layout" : {
76+ control = this . __createTagsFilterLayout ( ) ;
77+ const scrollView = new qx . ui . container . Scroll ( ) ;
78+ scrollView . add ( control ) ;
79+ this . _add ( scrollView , {
80+ flex : 1
81+ } ) ;
82+ break ;
83+ }
84+ }
85+ return control || null ;
86+ } ,
87+
6088 __buildLayout : function ( ) {
61- const filtersSpacer = new qx . ui . core . Spacer ( 10 , 10 ) ;
6289 switch ( this . __resourceType ) {
6390 case "study" : {
6491 this . _add ( this . __createWorkspacesAndFoldersTree ( ) ) ;
@@ -72,28 +99,18 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
7299 this . _add ( this . __createFunctions ( ) ) ;
73100 }
74101 this . _add ( this . __createTrashBin ( ) ) ;
75- this . _add ( filtersSpacer ) ;
76- const scrollView = new qx . ui . container . Scroll ( ) ;
77- scrollView . add ( this . __createTagsFilterLayout ( ) ) ;
78- this . _add ( scrollView , {
79- flex : 1
80- } ) ;
102+ this . getChildControl ( "filters-spacer" ) ;
81103 break ;
82104 }
83- case "template" : {
84- this . _add ( filtersSpacer ) ;
85- this . _add ( this . __createSharedWithFilterLayout ( ) ) ;
86- const scrollView = new qx . ui . container . Scroll ( ) ;
87- scrollView . add ( this . __createTagsFilterLayout ( ) ) ;
88- this . _add ( scrollView , {
89- flex : 1
90- } ) ;
105+ case "template" :
106+ this . getChildControl ( "filters-spacer" ) ;
107+ this . getChildControl ( "shared-with-layout" ) ;
108+ this . getChildControl ( "tags-layout" ) ;
91109 break ;
92- }
93110 case "service" :
94- this . _add ( filtersSpacer ) ;
95- this . _add ( this . __createSharedWithFilterLayout ( ) ) ;
96- this . _add ( this . __createAppTypeFilterLayout ( ) ) ;
111+ this . getChildControl ( "filters-spacer" ) ;
112+ this . getChildControl ( "shared-with-layout" ) ;
113+ this . getChildControl ( "app-type-layout" ) ;
97114 break ;
98115 }
99116 } ,
@@ -354,12 +371,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
354371 __createTagsFilterLayout : function ( ) {
355372 const tagsLayout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 2 ) ) ;
356373 osparc . utils . Utils . setIdToWidget ( tagsLayout , this . __resourceType + "-tagsFilter" ) ;
357-
358- this . __populateTags ( tagsLayout , [ ] ) ;
359- osparc . store . Tags . getInstance ( ) . addListener ( "tagsChanged" , ( ) => {
360- this . __populateTags ( tagsLayout , this . __getSelectedTagIds ( ) ) ;
361- } , this ) ;
362-
363374 return tagsLayout ;
364375 } ,
365376
@@ -368,11 +379,17 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
368379 return selectedTagIds ;
369380 } ,
370381
371- __populateTags : function ( tagsLayout , selectedTagIds ) {
372- const maxTags = 5 ;
373- this . __tagButtons = [ ] ;
382+ populateTags : function ( presentTagIds = [ ] ) {
383+ const selectedTagIds = this . __getSelectedTagIds ( ) ;
384+ const tagsLayout = this . getChildControl ( "tags-layout" ) ;
374385 tagsLayout . removeAll ( ) ;
375- osparc . store . Tags . getInstance ( ) . getTags ( ) . forEach ( ( tag , idx ) => {
386+ const maxTags = 10 ;
387+ this . __tagButtons = [ ] ;
388+ presentTagIds . forEach ( tagId => {
389+ const tag = osparc . store . Tags . getInstance ( ) . getTag ( tagId ) ;
390+ if ( ! tag ) {
391+ return ;
392+ }
376393 const button = new qx . ui . form . ToggleButton ( null , "@FontAwesome5Solid/tag/16" ) ;
377394 button . id = tag . getTagId ( ) ;
378395 tag . bind ( "name" , button , "label" ) ;
@@ -391,7 +408,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
391408 this . fireDataEvent ( "changeSelectedTags" , selection ) ;
392409 } , this ) ;
393410
394- button . setVisibility ( idx >= maxTags ? "excluded" : "visible" ) ;
411+ button . setVisibility ( this . __tagButtons . length >= maxTags ? "excluded" : "visible" ) ;
395412
396413 this . __tagButtons . push ( button ) ;
397414 } ) ;
@@ -426,6 +443,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserFilter", {
426443 myAccountWindow . openTags ( ) ;
427444 } ) ;
428445 tagsLayout . add ( editTagsButton ) ;
446+ editTagsButton . exclude ( ) ; // excluded for now, they will be used as categories
429447
430448 if ( this . __resourceType === "study" ) {
431449 tagsLayout . getChildren ( ) . forEach ( item => item . setPaddingLeft ( 10 ) ) ; // align them with the context
0 commit comments