@@ -864,6 +864,9 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
864864 const studiesMoveButton = this . __createMoveStudiesButton ( false ) ;
865865 this . _toolbar . add ( studiesMoveButton ) ;
866866
867+ const studiesTrashButton = this . __createTrashButton ( false ) ;
868+ this . _toolbar . add ( studiesTrashButton ) ;
869+
867870 const studiesDeleteButton = this . __createDeleteButton ( false ) ;
868871 this . _toolbar . add ( studiesDeleteButton ) ;
869872
@@ -1107,6 +1110,19 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
11071110 return moveStudiesButton ;
11081111 } ,
11091112
1113+ __createTrashButton : function ( ) {
1114+ const trashButton = new qx . ui . form . Button ( this . tr ( "Trash" ) , "@FontAwesome5Solid/trash/14" ) . set ( {
1115+ appearance : "danger-button" ,
1116+ visibility : "excluded"
1117+ } ) ;
1118+ osparc . utils . Utils . setIdToWidget ( trashButton , "deleteStudiesBtn" ) ;
1119+ trashButton . addListener ( "execute" , ( ) => {
1120+ const selection = this . _resourcesContainer . getSelection ( ) ;
1121+ this . __trashStudies ( selection . map ( button => this . __getStudyData ( button . getUuid ( ) , false ) ) , false ) ;
1122+ } , this ) ;
1123+ return trashButton ;
1124+ } ,
1125+
11101126 __createDeleteButton : function ( ) {
11111127 const deleteButton = new qx . ui . form . Button ( this . tr ( "Delete" ) , "@FontAwesome5Solid/trash/14" ) . set ( {
11121128 appearance : "danger-button" ,
@@ -1693,6 +1709,34 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
16931709 req . send ( body ) ;
16941710 } ,
16951711
1712+ __trashStudy : function ( studyData ) {
1713+ const myGid = osparc . auth . Data . getInstance ( ) . getGroupId ( ) ;
1714+ const collabGids = Object . keys ( studyData [ "accessRights" ] ) ;
1715+ const amICollaborator = collabGids . indexOf ( myGid ) > - 1 ;
1716+
1717+ let operationPromise = null ;
1718+ if ( collabGids . length > 1 && amICollaborator ) {
1719+ const arCopy = osparc . utils . Utils . deepCloneObject ( studyData [ "accessRights" ] ) ;
1720+ // remove collaborator
1721+ delete arCopy [ myGid ] ;
1722+ operationPromise = osparc . info . StudyUtils . patchStudyData ( studyData , "accessRights" , arCopy ) ;
1723+ } else {
1724+ // trash study
1725+ operationPromise = osparc . store . Store . getInstance ( ) . trashStudy ( studyData . uuid ) ;
1726+ }
1727+ operationPromise
1728+ . then ( ( ) => this . __removeFromStudyList ( studyData . uuid ) )
1729+ . catch ( err => {
1730+ console . error ( err ) ;
1731+ osparc . FlashMessenger . getInstance ( ) . logAs ( err , "ERROR" ) ;
1732+ } )
1733+ . finally ( ( ) => this . resetSelection ( ) ) ;
1734+ } ,
1735+
1736+ __trashStudies : function ( studiesData ) {
1737+ studiesData . forEach ( studyData => this . __trashStudy ( studyData ) ) ;
1738+ } ,
1739+
16961740 __doDeleteStudy : function ( studyData ) {
16971741 const myGid = osparc . auth . Data . getInstance ( ) . getGroupId ( ) ;
16981742 const collabGids = Object . keys ( studyData [ "accessRights" ] ) ;
0 commit comments