@@ -161,6 +161,7 @@ qx.Class.define("osparc.dashboard.DragDropHelpers", {
161
161
const folderOrigin = event . getData ( "osparc-moveFolder" ) [ "folderOrigin" ] ;
162
162
const folderToFolderData = {
163
163
folderId : folderOrigin . getFolderId ( ) ,
164
+ workspaceId : folderOrigin . getWorkspaceId ( ) ,
164
165
destWorkspaceId,
165
166
destFolderId,
166
167
} ;
@@ -169,11 +170,76 @@ qx.Class.define("osparc.dashboard.DragDropHelpers", {
169
170
} ,
170
171
} ,
171
172
173
+ trashStudy : {
174
+ dragOver : function ( event ) {
175
+ let compatible = false ;
176
+ const studyDataOrigin = event . getData ( "osparc-moveStudy" ) [ "studyDataOrigin" ] ;
177
+ const workspaceIdOrigin = studyDataOrigin [ "workspaceId" ] ;
178
+ const workspaceOrigin = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceIdOrigin ) ;
179
+ // Compatibility checks:
180
+ // - My Workspace -> Trash (0)
181
+ // - Delete on Study
182
+ // - Shared Workspace -> Trash (1)
183
+ // - Delete on Shared Workspace
184
+ if ( workspaceIdOrigin === null ) { // (0)
185
+ compatible = osparc . data . model . Study . canIDelete ( studyDataOrigin [ "accessRights" ] ) ;
186
+ } else if ( workspaceIdOrigin !== null ) { // (1)
187
+ compatible = workspaceOrigin . getMyAccessRights ( ) [ "delete" ] ;
188
+ }
189
+
190
+ if ( ! compatible ) {
191
+ // do not allow
192
+ event . preventDefault ( ) ;
193
+ }
194
+
195
+ const dragWidget = osparc . dashboard . DragWidget . getInstance ( ) ;
196
+ dragWidget . setDropAllowed ( compatible ) ;
197
+ } ,
198
+
199
+ drop : function ( event ) {
200
+ return event . getData ( "osparc-moveStudy" ) [ "studyDataOrigin" ] ;
201
+ } ,
202
+ } ,
203
+
204
+ trashFolder : {
205
+ dragOver : function ( event ) {
206
+ let compatible = false ;
207
+ const folderOrigin = event . getData ( "osparc-moveFolder" ) [ "folderOrigin" ] ;
208
+ const workspaceIdOrigin = folderOrigin . getWorkspaceId ( ) ;
209
+ const workspaceOrigin = osparc . store . Workspaces . getInstance ( ) . getWorkspace ( workspaceIdOrigin ) ;
210
+ // Compatibility checks:
211
+ // - My Workspace -> Trash (0)
212
+ // - Yes
213
+ // - Shared Workspace -> Trash (1)
214
+ // - Delete on Shared Workspace
215
+ if ( workspaceIdOrigin === null ) { // (0)
216
+ compatible = true ;
217
+ } else if ( workspaceIdOrigin !== null ) { // (1)
218
+ compatible = workspaceOrigin . getMyAccessRights ( ) [ "delete" ] ;
219
+ }
220
+
221
+ if ( ! compatible ) {
222
+ // do not allow
223
+ event . preventDefault ( ) ;
224
+ }
225
+
226
+ const dragWidget = osparc . dashboard . DragWidget . getInstance ( ) ;
227
+ dragWidget . setDropAllowed ( compatible ) ;
228
+ } ,
229
+
230
+ drop : function ( event ) {
231
+ const folderOrigin = event . getData ( "osparc-moveFolder" ) [ "folderOrigin" ] ;
232
+ return folderOrigin . getFolderId ( ) ;
233
+ } ,
234
+ } ,
235
+
172
236
dragLeave : function ( item ) {
173
237
const dragWidget = osparc . dashboard . DragWidget . getInstance ( ) ;
174
238
dragWidget . setDropAllowed ( false ) ;
175
239
176
- item . getChildControl ( "icon" ) . resetTextColor ( ) ;
240
+ if ( item ) {
241
+ item . getChildControl ( "icon" ) . resetTextColor ( ) ;
242
+ }
177
243
} ,
178
244
179
245
dragEnd : function ( draggedItem ) {
0 commit comments