@@ -171,17 +171,30 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
171
171
if (
172
172
! osparc . auth . Manager . getInstance ( ) . isLoggedIn ( ) ||
173
173
! osparc . utils . DisabledPlugins . isFoldersEnabled ( ) ||
174
- this . getCurrentContext ( ) !== "studiesAndFolders " ||
174
+ this . getCurrentContext ( ) === "workspaces " ||
175
175
this . __loadingFolders
176
176
) {
177
177
return ;
178
178
}
179
179
180
- const workspaceId = this . getCurrentWorkspaceId ( ) ;
181
- const folderId = this . getCurrentFolderId ( ) ;
182
180
this . __loadingFolders = true ;
181
+ let request = null ;
182
+ switch ( this . getCurrentContext ( ) ) {
183
+ case "search" : {
184
+ const filterData = this . _searchBarFilter . getFilterData ( ) ;
185
+ const text = filterData . text ? encodeURIComponent ( filterData . text ) : "" ; // name, description and uuid
186
+ request = osparc . store . Folders . getInstance ( ) . searchFolders ( text , this . getOrderBy ( ) ) ;
187
+ break ;
188
+ }
189
+ case "studiesAndFolders" : {
190
+ const workspaceId = this . getCurrentWorkspaceId ( ) ;
191
+ const folderId = this . getCurrentFolderId ( ) ;
192
+ request = osparc . store . Folders . getInstance ( ) . fetchFolders ( folderId , workspaceId , this . getOrderBy ( ) ) ;
193
+ break ;
194
+ }
195
+ }
183
196
this . __setFoldersToList ( [ ] ) ;
184
- osparc . store . Folders . getInstance ( ) . fetchFolders ( folderId , workspaceId , this . getOrderBy ( ) )
197
+ request
185
198
. then ( folders => {
186
199
this . __setFoldersToList ( folders ) ;
187
200
} )
@@ -384,7 +397,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
384
397
} ,
385
398
386
399
_workspaceSelected : function ( workspaceId ) {
387
- this . __changeContext ( "studiesAndFolders" , workspaceId , null ) ;
400
+ this . _changeContext ( "studiesAndFolders" , workspaceId , null ) ;
388
401
} ,
389
402
390
403
_workspaceUpdated : function ( ) {
@@ -444,7 +457,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
444
457
} ,
445
458
446
459
_folderSelected : function ( folderId ) {
447
- this . __changeContext ( "studiesAndFolders" , this . getCurrentWorkspaceId ( ) , folderId ) ;
460
+ this . _changeContext ( "studiesAndFolders" , this . getCurrentWorkspaceId ( ) , folderId ) ;
448
461
} ,
449
462
450
463
_folderUpdated : function ( ) {
@@ -653,17 +666,23 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
653
666
const requestParams = { } ;
654
667
requestParams . orderBy = JSON . stringify ( this . getOrderBy ( ) ) ;
655
668
656
- const filterData = this . _searchBarFilter . getFilterData ( ) ;
657
- // Use the ``search`` functionality only if the user types some text
658
- // tags should only be used to filter the current context (search context ot workspace/folder context)
659
- if ( filterData . text ) {
660
- requestParams . text = filterData . text ? encodeURIComponent ( filterData . text ) : "" ; // name, description and uuid
661
- requestParams [ "tagIds" ] = filterData . tags . length ? filterData . tags . join ( "," ) : "" ;
662
- return requestParams ;
669
+ switch ( this . getCurrentContext ( ) ) {
670
+ case "studiesAndFolders" :
671
+ requestParams . workspaceId = this . getCurrentWorkspaceId ( ) ;
672
+ requestParams . folderId = this . getCurrentFolderId ( ) ;
673
+ break ;
674
+ case "search" : {
675
+ // Use the ``search`` functionality only if the user types some text
676
+ // tags should only be used to filter the current context (search context ot workspace/folder context)
677
+ const filterData = this . _searchBarFilter . getFilterData ( ) ;
678
+ if ( filterData . text ) {
679
+ requestParams . text = filterData . text ? encodeURIComponent ( filterData . text ) : "" ; // name, description and uuid
680
+ requestParams [ "tagIds" ] = filterData . tags . length ? filterData . tags . join ( "," ) : "" ;
681
+ }
682
+ break ;
683
+ }
663
684
}
664
685
665
- requestParams . workspaceId = this . getCurrentWorkspaceId ( ) ;
666
- requestParams . folderId = this . getCurrentFolderId ( ) ;
667
686
return requestParams ;
668
687
} ,
669
688
@@ -688,10 +707,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
688
707
resolveWResponse : true
689
708
} ;
690
709
691
- if ( "text" in requestParams ) {
692
- return osparc . data . Resources . fetch ( "studies" , "getPageSearch" , params , options ) ;
710
+ let request = null ;
711
+ switch ( this . getCurrentContext ( ) ) {
712
+ case "search" :
713
+ request = osparc . data . Resources . fetch ( "studies" , "getPageSearch" , params , options ) ;
714
+ break ;
715
+ case "studiesAndFolders" :
716
+ request = osparc . data . Resources . fetch ( "studies" , "getPage" , params , options ) ;
717
+ break ;
693
718
}
694
- return osparc . data . Resources . fetch ( "studies" , "getPage" , params , options ) ;
719
+ return request ;
695
720
} ,
696
721
697
722
invalidateStudies : function ( ) {
@@ -886,10 +911,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
886
911
} ) ;
887
912
888
913
this . _resourcesContainer . addListener ( "changeSelection" , e => {
914
+ const currentContext = this . getCurrentContext ( ) ;
889
915
const selection = e . getData ( ) ;
890
916
891
917
studiesMoveButton . set ( {
892
- visibility : selection . length ? "visible" : "excluded" ,
918
+ visibility : selection . length && currentContext === "studiesAndFolders" ? "visible" : "excluded" ,
893
919
label : selection . length > 1 ? this . tr ( "Move selected" ) + " (" + selection . length + ")" : this . tr ( "Move" )
894
920
} ) ;
895
921
@@ -910,35 +936,35 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
910
936
header . addListener ( "locationChanged" , ( ) => {
911
937
const workspaceId = header . getCurrentWorkspaceId ( ) ;
912
938
const folderId = header . getCurrentFolderId ( ) ;
913
- this . __changeContext ( "studiesAndFolders" , workspaceId , folderId ) ;
939
+ this . _changeContext ( "studiesAndFolders" , workspaceId , folderId ) ;
914
940
} , this ) ;
915
941
916
942
const workspacesAndFoldersTree = this . _resourceFilter . getWorkspacesAndFoldersTree ( ) ;
917
943
workspacesAndFoldersTree . addListener ( "locationChanged" , e => {
918
944
const context = e . getData ( ) ;
919
945
const workspaceId = context [ "workspaceId" ] ;
920
946
if ( workspaceId === - 1 ) {
921
- this . __changeContext ( "workspaces" ) ;
947
+ this . _changeContext ( "workspaces" ) ;
922
948
} else {
923
949
const folderId = context [ "folderId" ] ;
924
- this . __changeContext ( "studiesAndFolders" , workspaceId , folderId ) ;
950
+ this . _changeContext ( "studiesAndFolders" , workspaceId , folderId ) ;
925
951
}
926
952
} , this ) ;
927
953
928
954
this . _searchBarFilter . addListener ( "filterChanged" , e => {
929
955
const filterData = e . getData ( ) ;
930
956
if ( filterData . text ) {
931
- this . __changeContext ( "search" ) ;
957
+ this . _changeContext ( "search" ) ;
932
958
} else {
933
959
const workspaceId = this . getCurrentWorkspaceId ( ) ;
934
960
const folderId = this . getCurrentFolderId ( ) ;
935
- this . __changeContext ( "studiesAndFolders" , workspaceId , folderId ) ;
961
+ this . _changeContext ( "studiesAndFolders" , workspaceId , folderId ) ;
936
962
}
937
963
} ) ;
938
964
}
939
965
} ,
940
966
941
- __changeContext : function ( context , workspaceId = null , folderId = null ) {
967
+ _changeContext : function ( context , workspaceId = null , folderId = null ) {
942
968
if ( osparc . utils . DisabledPlugins . isFoldersEnabled ( ) ) {
943
969
if (
944
970
context !== "search" && // reload studies for a new search
@@ -950,6 +976,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
950
976
return ;
951
977
}
952
978
979
+ osparc . store . Store . getInstance ( ) . setStudyBrowserContext ( context ) ;
953
980
this . set ( {
954
981
currentContext : context ,
955
982
currentWorkspaceId : workspaceId ,
@@ -962,7 +989,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
962
989
this . _resourcesContainer . setResourcesToList ( [ ] ) ;
963
990
964
991
if ( context === "search" ) {
965
- this . __setFoldersToList ( [ ] ) ;
992
+ this . __reloadFolders ( ) ;
966
993
this . __reloadStudies ( ) ;
967
994
} else if ( context === "workspaces" ) {
968
995
this . _searchBarFilter . resetFilters ( ) ;
@@ -1342,7 +1369,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
1342
1369
__getOpenLocationMenuButton : function ( studyData ) {
1343
1370
const openLocationButton = new qx . ui . menu . Button ( this . tr ( "Open location" ) , "@FontAwesome5Solid/external-link-alt/12" ) ;
1344
1371
openLocationButton . addListener ( "execute" , ( ) => {
1345
- this . __changeContext ( "studiesAndFolders" , studyData [ "workspaceId" ] , studyData [ "folderId" ] ) ;
1372
+ this . _changeContext ( "studiesAndFolders" , studyData [ "workspaceId" ] , studyData [ "folderId" ] ) ;
1346
1373
} , this ) ;
1347
1374
return openLocationButton ;
1348
1375
} ,
0 commit comments