@@ -177,7 +177,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
177177 return ;
178178 }
179179 this . __setFoldersToList ( [ ] ) ;
180- osparc . store . Folders . getInstance ( ) . fetchFolders ( folderId , workspaceId )
180+ osparc . store . Folders . getInstance ( ) . fetchFolders ( folderId , workspaceId , this . getOrderBy ( ) )
181181 . then ( folders => {
182182 this . __setFoldersToList ( folders ) ;
183183 } )
@@ -290,7 +290,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
290290 this . _resourcesList . push ( study ) ;
291291 }
292292 } ) ;
293- this . _reloadNewCards ( ) ;
293+ this . __reloadNewCards ( ) ;
294294
295295 studiesList . forEach ( study => {
296296 const state = study [ "state" ] ;
@@ -317,24 +317,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
317317 __setFoldersToList : function ( folders ) {
318318 this . __foldersList = folders ;
319319 folders . forEach ( folder => folder [ "resourceType" ] = "folder" ) ;
320-
321- const sortByValueBE = this . getOrderBy ( ) . field ;
322- let sortByValue = null ;
323- switch ( sortByValueBE ) {
324- case "name" :
325- sortByValue = "name" ;
326- break ;
327- case "prj_owner" :
328- sortByValue = "owner" ;
329- break ;
330- case "creation_date" :
331- sortByValue = "createdAt" ;
332- break ;
333- case "last_change_date" :
334- sortByValue = "lastModified" ;
335- break ;
336- }
337- this . self ( ) . sortFoldersList ( this . __foldersList , sortByValue ) ;
338320 this . __reloadFolderCards ( ) ;
339321 } ,
340322
@@ -352,6 +334,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
352334 const cards = this . _resourcesContainer . reloadCards ( "studies" ) ;
353335 this . __configureStudyCards ( cards ) ;
354336
337+ // they were removed in the above reloadCards
338+ this . __reloadFolders ( ) ;
339+
355340 this . __addNewStudyButtons ( ) ;
356341
357342 const loadMoreBtn = this . __createLoadMoreButton ( ) ;
@@ -365,7 +350,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
365350 osparc . filter . UIFilterController . dispatch ( "searchBarFilter" ) ;
366351 } ,
367352
368- _reloadNewCards : function ( ) {
353+ __reloadNewCards : function ( ) {
369354 this . _resourcesContainer . setResourcesToList ( this . _resourcesList ) ;
370355 const cards = this . _resourcesContainer . reloadNewCards ( ) ;
371356 this . __configureStudyCards ( cards ) ;
@@ -615,8 +600,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
615600 delete reqParams [ "limit" ] ;
616601 delete reqParams [ "offset" ] ;
617602
603+ const cParams = this . __getRequestParams ( ) ;
604+ const currentParams = { } ;
605+ Object . entries ( cParams ) . forEach ( ( [ snakeKey , value ] ) => {
606+ const key = osparc . utils . Utils . snakeToCamel ( snakeKey ) ;
607+ currentParams [ key ] = value === "null" ? null : value ;
608+ } ) ;
609+
618610 // check the entries in currentParams are the same as the reqParams
619- const currentParams = this . __getRequestParams ( ) ;
620611 let sameContext = true ;
621612 Object . entries ( currentParams ) . forEach ( ( [ key , value ] ) => {
622613 sameContext &= key in reqParams && reqParams [ key ] === value ;
@@ -655,8 +646,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
655646 requestParams . orderBy = JSON . stringify ( this . getOrderBy ( ) ) ;
656647
657648 const filterData = this . _searchBarFilter . getFilterData ( ) ;
649+ // Use the ``search`` functionality only if the user types some text
650+ // tags should only be used to filter the current context (search context ot workspace/folder context)
658651 if ( filterData . text ) {
659- requestParams . text = encodeURIComponent ( filterData . text ) ; // name, description and uuid
652+ requestParams . text = filterData . text ? encodeURIComponent ( filterData . text ) : "" ; // name, description and uuid
653+ requestParams [ "tagIds" ] = filterData . tags . length ? filterData . tags . join ( "," ) : "" ;
660654 return requestParams ;
661655 }
662656
@@ -988,9 +982,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
988982 } ) ;
989983 osparc . utils . Utils . setIdToWidget ( sortByButton , "sortByButton" ) ;
990984 sortByButton . addListener ( "sortByChanged" , e => {
991- this . setOrderBy ( e . getData ( ) )
992- this . __resetStudiesList ( ) ;
993- this . __reloadStudies ( ) ;
985+ this . setOrderBy ( e . getData ( ) ) ;
986+ this . invalidateStudies ( ) ;
987+ this . reloadResources ( ) ;
994988 } , this ) ;
995989 this . _toolbar . add ( sortByButton ) ;
996990 } ,
@@ -1228,13 +1222,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
12281222
12291223 _updateStudyData : function ( studyData ) {
12301224 studyData [ "resourceType" ] = "study" ;
1231- const studies = this . _resourcesList ;
1232- const index = studies . findIndex ( study => study [ "uuid" ] === studyData [ "uuid" ] ) ;
1225+ const index = this . _resourcesList . findIndex ( study => study [ "uuid" ] === studyData [ "uuid" ] ) ;
12331226 if ( index === - 1 ) {
12341227 // add it in first position, most likely it's a new study
1235- studies . unshift ( studyData ) ;
1228+ this . _resourcesList . unshift ( studyData ) ;
12361229 } else {
1237- studies [ index ] = studyData ;
1230+ this . _resourcesList [ index ] = studyData ;
12381231 }
12391232 this . _reloadCards ( ) ;
12401233 } ,
0 commit comments