@@ -20,7 +20,7 @@ qx.Class.define("osparc.dashboard.DragDropHelpers", {
2020
2121 statics : {
2222 moveStudy : {
23- dragStart : function ( event , studyDataOrigin , studyItem ) {
23+ dragStart : function ( event , studyItem , studyDataOrigin ) {
2424 event . addAction ( "move" ) ;
2525 event . addType ( "osparc-moveStudy" ) ;
2626 event . addData ( "osparc-moveStudy" , {
@@ -93,7 +93,7 @@ qx.Class.define("osparc.dashboard.DragDropHelpers", {
9393 } ,
9494
9595 moveFolder : {
96- dragStart : function ( event , folderOrigin , folderItem ) {
96+ dragStart : function ( event , folderItem , folderOrigin ) {
9797 event . addAction ( "move" ) ;
9898 event . addType ( "osparc-moveFolder" ) ;
9999 event . addData ( "osparc-moveFolder" , {
@@ -112,26 +112,35 @@ qx.Class.define("osparc.dashboard.DragDropHelpers", {
112112 folderItem . setOpacity ( 0.2 ) ;
113113 } ,
114114
115- dragOver : function ( event , folderItem , folderDest ) {
115+ dragOver : function ( event , folderItem , workspaceDestId ) {
116116 let compatible = false ;
117- // Compatibility checks:
118- // - It's not the same folder
119- // - My workspace
120- // - None
121- // - Shared workspace
122- // - write access on workspace
123117 const folderOrigin = event . getData ( "osparc-moveFolder" ) [ "folderOrigin" ] ;
124- compatible = folderDest !== folderOrigin ;
125- const workspaceId = folderOrigin . getWorkspaceId ( ) ;
126- if ( compatible ) {
127- if ( workspaceId ) {
128- const workspace = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceId ) ;
129- if ( workspace ) {
130- compatible = workspace . getMyAccessRights ( ) [ "write" ] ;
131- }
132- } else {
133- compatible = true ;
134- }
118+ const workspaceIdOrigin = folderOrigin . getWorkspaceId ( ) ;
119+ const workspaceOrigin = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceIdOrigin ) ;
120+ const workspaceDest = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceDestId ) ;
121+ // Compatibility checks:
122+ // - Drag over "Shared Workspaces" (0)
123+ // - No
124+ // - My Workspace -> My Workspace (1)
125+ // - Yes
126+ // - My Workspace -> Shared Workspace (2)
127+ // - ~~Delete on Study~~
128+ // - Write on dest Workspace
129+ // - Shared Workspace -> My Workspace (3)
130+ // - Delete on origin Workspace
131+ // - Shared Workspace -> Shared Workspace (4)
132+ // - Delete on origin Workspace
133+ // - Write on dest Workspace
134+ if ( workspaceDestId === - 1 ) { // (0)
135+ compatible = false ;
136+ } else if ( workspaceIdOrigin === null && workspaceDestId === null ) { // (1)
137+ compatible = true ;
138+ } else if ( workspaceIdOrigin === null && workspaceDest ) { // (2)
139+ compatible = workspaceDest . getMyAccessRights ( ) [ "write" ] ;
140+ } else if ( workspaceOrigin && workspaceDestId === null ) { // (3)
141+ compatible = workspaceOrigin . getMyAccessRights ( ) [ "delete" ] ;
142+ } else if ( workspaceOrigin && workspaceDest ) { // (4)
143+ compatible = workspaceOrigin . getMyAccessRights ( ) [ "delete" ] && workspaceDest . getMyAccessRights ( ) [ "write" ] ;
135144 }
136145
137146 if ( compatible ) {
0 commit comments