@@ -35,9 +35,6 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
3535
3636 this . __buildLayout ( ) ;
3737
38- // defaults to "My Projects"
39- this . __searchMyProjectsSelected ( ) ;
40-
4138 qx . core . Init . getApplication ( ) . getRoot ( ) . add ( this ) ;
4239
4340 this . __attachHideHandlers ( ) ;
@@ -79,9 +76,6 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
7976 case "search-bar-filter" : {
8077 control = new osparc . dashboard . SearchBarFilter ( this . __resourceType ) ;
8178 const textField = control . getChildControl ( "text-field" ) ;
82- if ( "text" in this . __initFilterData ) {
83- textField . setValue ( this . __initFilterData [ "text" ] ) ;
84- }
8579 textField . addListener ( "appear" , ( ) => {
8680 textField . focus ( ) ;
8781 textField . activate ( ) ;
@@ -147,28 +141,13 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
147141 showFilterMenu : false ,
148142 } ) ;
149143
150- const textField = this . getChildControl ( ( "search-bar-filter" ) ) . getChildControl ( "text-field" ) ;
151- textField . addListener ( "keypress" , e => {
152- if ( e . getKeyIdentifier ( ) === "Enter" ) {
153- this . __sourceSearchBarFilter . getChildControl ( "text-field" ) . setValue ( textField . getValue ( ) ) ;
154- this . exclude ( ) ;
155- }
156- } , this ) ;
157- textField . addListener ( "changeValue" , ( ) => {
158- this . __sourceSearchBarFilter . getChildControl ( "text-field" ) . setValue ( textField . getValue ( ) ) ;
159- this . exclude ( ) ;
160- } , this ) ;
161-
162144 const resetButton = this . getChildControl ( "search-bar-filter" ) . getChildControl ( "reset-button" ) ;
163145 resetButton . set ( {
164146 paddingRight : 2 , // 10-8
165147 opacity : 0.7 ,
166148 backgroundColor : "transparent" ,
167149 } ) ;
168150 osparc . utils . Utils . hideBorder ( resetButton ) ;
169- resetButton . addListener ( "tap" , ( ) => {
170- this . exclude ( ) ;
171- } ) ;
172151
173152 const radioGroup = new qx . ui . form . RadioGroup ( ) ;
174153 const myProjectsButton = this . getChildControl ( "my-projects-button" ) ;
@@ -178,6 +157,43 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
178157 myProjectsButton . addListener ( "changeValue" , this . __searchMyProjectsSelected , this ) ;
179158 templatesButton . addListener ( "changeValue" , this . __searchTemplatesSelected , this ) ;
180159 publicProjectsButton . addListener ( "changeValue" , this . __searchPublicProjectsSelected , this ) ;
160+
161+ // Set initial state based on the provided initFilterData
162+ const activeFilters = this . getChildControl ( "search-bar-filter" ) . getChildControl ( "active-filters" ) ;
163+ const textField = this . getChildControl ( "search-bar-filter" ) . getChildControl ( "text-field" ) ;
164+ if ( "sharedWith" in this . __initFilterData ) {
165+ const chip = osparc . dashboard . SearchBarFilter . createChip ( "sharedWith" , this . __initFilterData [ "sharedWith" ] , this . tr ( "Shared with" ) ) ;
166+ activeFilters . add ( chip ) ;
167+ }
168+ if ( "tags" in this . __initFilterData ) {
169+ const tags = osparc . store . Tags . getInstance ( ) . getTags ( ) ;
170+ this . __initFilterData [ "tags" ] . forEach ( tagId => {
171+ const tagFound = tags . find ( tag => tag . getTagId ( ) === tagId ) ;
172+ if ( tagFound ) {
173+ const chip = osparc . dashboard . SearchBarFilter . createChip ( "tag" , tagId , tagFound . getName ( ) ) ;
174+ activeFilters . add ( chip ) ;
175+ }
176+ } ) ;
177+ }
178+ if ( "text" in this . __initFilterData ) {
179+ textField . setValue ( this . __initFilterData [ "text" ] ) ;
180+ }
181+
182+ // Add listeners
183+ textField . addListener ( "keypress" , e => {
184+ if ( e . getKeyIdentifier ( ) === "Enter" ) {
185+ this . __sourceSearchBarFilter . getChildControl ( "text-field" ) . setValue ( textField . getValue ( ) ) ;
186+ this . exclude ( ) ;
187+ }
188+ } , this ) ;
189+ textField . addListener ( "changeValue" , ( ) => {
190+ this . __sourceSearchBarFilter . getChildControl ( "text-field" ) . setValue ( textField . getValue ( ) ) ;
191+ this . exclude ( ) ;
192+ } , this ) ;
193+
194+ resetButton . addListener ( "tap" , ( ) => {
195+ this . exclude ( ) ;
196+ } ) ;
181197 } ,
182198
183199 __searchMyProjectsSelected : function ( ) {
@@ -249,7 +265,7 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
249265 this . __tagsMenu ,
250266 ] ;
251267 for ( let i = 0 ; i < excludeElements . length ; i ++ ) {
252- if ( osparc . utils . Utils . isMouseOnElement ( excludeElements [ i ] , e ) ) {
268+ if ( excludeElements [ i ] && osparc . utils . Utils . isMouseOnElement ( excludeElements [ i ] , e ) ) {
253269 return ;
254270 }
255271 }
0 commit comments