@@ -63,24 +63,12 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
6363 } ,
6464
6565 statics : {
66- createToolbarRadioButton : function ( label , icon , toolTipText = null , pos = null ) {
67- const rButton = new qx . ui . toolbar . RadioButton ( ) . set ( {
68- label,
69- icon,
70- toolTipText,
71- padding : 8 ,
66+ createListItem : function ( label , icon , model ) {
67+ const listItem = new qx . ui . form . ListItem ( label , icon , model ) . set ( {
7268 gap : 8 ,
7369 margin : 0 ,
7470 } ) ;
75- rButton . getContentElement ( ) . setStyles ( {
76- "border-radius" : "0px"
77- } ) ;
78- if ( pos === "left" ) {
79- osparc . utils . Utils . addBorderLeftRadius ( rButton ) ;
80- } else if ( pos === "right" ) {
81- osparc . utils . Utils . addBorderRightRadius ( rButton ) ;
82- }
83- return rButton ;
71+ return listItem ;
8472 } ,
8573 } ,
8674
@@ -109,46 +97,52 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
10997 this . _add ( control ) ;
11098 break ;
11199 }
112- case "context-buttons" :
113- control = new qx . ui . toolbar . ToolBar ( ) . set ( {
114- spacing : 0 ,
115- padding : 0 ,
116- backgroundColor : osparc . dashboard . SearchBarFilter . BG_COLOR ,
117- } ) ;
118- this . _add ( control ) ;
100+ case "context-drop-down" : {
101+ control = new qx . ui . form . SelectBox ( ) ;
102+ const searchBarFilter = this . getChildControl ( "search-bar-filter" ) ;
103+ searchBarFilter . _addAt ( control , 3 ) ; //"search-icon", "active-filters", "text-field", "reset-button"
119104 break ;
120- case "my-projects-button" :
121- control = this . self ( ) . createToolbarRadioButton (
105+ }
106+ case "my-projects-button" : {
107+ control = this . self ( ) . createListItem (
122108 this . tr ( "My Projects" ) ,
123109 "@FontAwesome5Solid/file/14" ,
124- null ,
125- "left" ,
110+ "myProjects"
126111 ) ;
127- this . getChildControl ( "context-buttons" ) . add ( control ) ;
112+ const contextDropDown = this . getChildControl ( "context-drop-down" ) ;
113+ contextDropDown . add ( control ) ;
128114 break ;
129- case "templates-button" :
130- control = this . self ( ) . createToolbarRadioButton (
115+ }
116+ case "templates-button" : {
117+ control = this . self ( ) . createListItem (
131118 this . tr ( "Templates" ) ,
132119 "@FontAwesome5Solid/copy/14" ,
120+ "templates"
133121 ) ;
134- this . getChildControl ( "context-buttons" ) . add ( control ) ;
122+ const contextDropDown = this . getChildControl ( "context-drop-down" ) ;
123+ contextDropDown . add ( control ) ;
135124 break ;
136- case "public-projects-button" :
137- control = this . self ( ) . createToolbarRadioButton (
125+ }
126+ case "public-projects-button" : {
127+ control = this . self ( ) . createListItem (
138128 this . tr ( "Public Projects" ) ,
139129 "@FontAwesome5Solid/globe/14" ,
130+ "publicProjects"
140131 ) ;
141- this . getChildControl ( "context-buttons" ) . add ( control ) ;
132+ const contextDropDown = this . getChildControl ( "context-drop-down" ) ;
133+ contextDropDown . add ( control ) ;
142134 break ;
143- case "functions-button" :
144- control = this . self ( ) . createToolbarRadioButton (
135+ }
136+ case "functions-button" : {
137+ control = this . self ( ) . createListItem (
145138 this . tr ( "Functions" ) ,
146139 "@MaterialIcons/functions/18" ,
147- null ,
148- "right" ,
140+ "functions"
149141 ) ;
150- this . getChildControl ( "context-buttons" ) . add ( control ) ;
142+ const contextDropDown = this . getChildControl ( "context-drop-down" ) ;
143+ contextDropDown . add ( control ) ;
151144 break ;
145+ }
152146 case "filter-buttons" :
153147 control = new qx . ui . toolbar . ToolBar ( ) . set ( {
154148 backgroundColor : osparc . dashboard . SearchBarFilter . BG_COLOR ,
@@ -172,21 +166,31 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
172166 __buildLayout : function ( ) {
173167 const searchBarFilter = this . getChildControl ( "search-bar-filter" ) ;
174168
175- const radioGroup = new qx . ui . form . RadioGroup ( ) ;
176- const contextButtons = [ ] ;
177- const myProjectsButton = this . getChildControl ( "my-projects-button" ) ;
178- myProjectsButton . addListener ( "changeValue" , e => e . getData ( ) ? this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_PROJECTS ) : null , this ) ;
179- contextButtons . push ( myProjectsButton ) ;
180- const templatesButton = this . getChildControl ( "templates-button" ) ;
181- templatesButton . addListener ( "changeValue" , e => e . getData ( ) ? this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_TEMPLATES ) : null , this ) ;
182- contextButtons . push ( templatesButton ) ;
183- const publicProjectsButton = this . getChildControl ( "public-projects-button" ) ;
184- publicProjectsButton . addListener ( "changeValue" , e => e . getData ( ) ? this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_PUBLIC_TEMPLATES ) : null , this ) ;
185- contextButtons . push ( publicProjectsButton ) ;
186- const functionsButton = this . getChildControl ( "functions-button" ) ; // OM only if enabled
187- functionsButton . addListener ( "changeValue" , e => e . getData ( ) ? this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_FUNCTIONS ) : null , this ) ;
188- contextButtons . push ( functionsButton ) ;
189- contextButtons . forEach ( contextButton => radioGroup . add ( contextButton ) ) ;
169+ const contextDropDown = this . getChildControl ( "context-drop-down" ) ;
170+ this . getChildControl ( "my-projects-button" ) ;
171+ this . getChildControl ( "templates-button" ) ;
172+ this . getChildControl ( "public-projects-button" ) ;
173+ this . getChildControl ( "functions-button" ) ;
174+ contextDropDown . addListener ( "changeSelection" , e => {
175+ const selection = e . getData ( ) ;
176+ if ( selection . length ) {
177+ const selectedContext = selection [ 0 ] . getModel ( ) ;
178+ switch ( selectedContext ) {
179+ case "myProjects" :
180+ this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_PROJECTS ) ;
181+ break ;
182+ case "templates" :
183+ this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_TEMPLATES ) ;
184+ break ;
185+ case "publicProjects" :
186+ this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_PUBLIC_TEMPLATES ) ;
187+ break ;
188+ case "functions" :
189+ this . setCurrentContext ( osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_FUNCTIONS ) ;
190+ break ;
191+ }
192+ }
193+ } ) ;
190194
191195 // Set initial state based on the provided initFilterData
192196 const activeFilters = searchBarFilter . getChildControl ( "active-filters" ) ;
@@ -234,33 +238,35 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
234238 if ( value === old ) {
235239 return ;
236240 }
241+ const contextDropDown = this . getChildControl ( "context-drop-down" ) ;
237242 const searchBarFilter = this . getChildControl ( "search-bar-filter" ) ;
238243 const sharedWithButton = this . getChildControl ( "shared-with-button" ) ;
239244 const tagsButton = this . getChildControl ( "tags-button" ) ;
240245 switch ( value ) {
241246 case osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_PROJECTS :
242- this . getChildControl ( "my-projects-button" ) . setValue ( true ) ;
247+ contextDropDown . setSelection ( [ this . getChildControl ( "my-projects-button" ) ] ) ;
243248 searchBarFilter . getChildControl ( "text-field" ) . setPlaceholder ( this . tr ( "Search in My projects" ) ) ;
244249 sharedWithButton . setVisibility ( "visible" ) ;
245250 tagsButton . setVisibility ( "visible" ) ;
246251 break ;
247252 case osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_TEMPLATES :
248- this . getChildControl ( "templates-button" ) . setValue ( true ) ;
253+ contextDropDown . setSelection ( [ this . getChildControl ( "templates-button" ) ] ) ;
249254 searchBarFilter . getChildControl ( "text-field" ) . setPlaceholder ( this . tr ( "Search in Templates" ) ) ;
250255 sharedWithButton . setVisibility ( "excluded" ) ;
251256 tagsButton . setVisibility ( "visible" ) ;
252257 break ;
253258 case osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_PUBLIC_TEMPLATES :
254- this . getChildControl ( "public-projects-button" ) . setValue ( true ) ;
259+ contextDropDown . setSelection ( [ this . getChildControl ( "public-projects-button" ) ] ) ;
255260 searchBarFilter . getChildControl ( "text-field" ) . setPlaceholder ( this . tr ( "Search in Public projects" ) ) ;
256261 sharedWithButton . setVisibility ( "excluded" ) ;
257262 tagsButton . setVisibility ( "visible" ) ;
258263 break ;
259264 case osparc . dashboard . StudyBrowser . CONTEXT . SEARCH_FUNCTIONS :
260- this . getChildControl ( "functions-button" ) . setValue ( true ) ;
265+ contextDropDown . setSelection ( [ this . getChildControl ( "functions-button" ) ] ) ;
261266 searchBarFilter . getChildControl ( "text-field" ) . setPlaceholder ( this . tr ( "Search in Functions" ) ) ;
262267 sharedWithButton . setVisibility ( "excluded" ) ;
263268 tagsButton . setVisibility ( "excluded" ) ;
269+ break ;
264270 }
265271 } ,
266272
0 commit comments