diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index 397f2682acb..084eff89572 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -576,7 +576,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const data = e.getData(); const destWorkspaceId = data["workspaceId"]; const destFolderId = data["folderId"]; - this._folderToFolderRequested(folderId, currentWorkspaceId, destWorkspaceId, destFolderId); + this.__folderToFolderRequested(folderId, currentWorkspaceId, destWorkspaceId, destFolderId); }); moveFolderTo.addListener("cancel", () => win.close()); }, @@ -591,7 +591,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }); }, - _folderToFolderRequested: function(folderId, workspaceId, destWorkspaceId, destFolderId) { + __folderToFolderRequested: function(folderId, workspaceId, destWorkspaceId, destFolderId) { if (destWorkspaceId === workspaceId) { this.__doMoveFolder(folderId, destWorkspaceId, destFolderId); } else { @@ -1183,7 +1183,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { destWorkspaceId, destFolderId, } = e.getData(); - this._moveStudyToFolderReqested(studyData, destWorkspaceId, destFolderId); + this.__studyToFolderRequested(studyData, destWorkspaceId, destFolderId); }); workspacesAndFoldersTree.addListener("folderToFolderRequested", e => { const { @@ -1192,17 +1192,38 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { destWorkspaceId, destFolderId, } = e.getData(); - this._folderToFolderRequested(folderId, workspaceId, destWorkspaceId, destFolderId); + this.__folderToFolderRequested(folderId, workspaceId, destWorkspaceId, destFolderId); }); this._resourceFilter.addListener("trashStudyRequested", e => { - this.__trashStudyRequested(e.getData()); + const studyData = e.getData(); + this.__trashStudyRequested(studyData); }); this._resourceFilter.addListener("trashFolderRequested", e => { - this._trashFolderRequested(e.getData()); + const folderId = e.getData(); + this._trashFolderRequested(folderId); }); }, + _studyToFolderRequested: function(data) { + const { + studyData, + destWorkspaceId, + destFolderId, + } = data; + this.__studyToFolderRequested(studyData, destWorkspaceId, destFolderId); + }, + + _folderToFolderRequested: function(data) { + const { + folderId, + workspaceId, + destWorkspaceId, + destFolderId, + } = data; + this.__folderToFolderRequested(folderId, workspaceId, destWorkspaceId, destFolderId); + }, + __addSortByButton: function() { const sortByButton = new osparc.dashboard.SortedByMenuButton(); sortByButton.set({ @@ -1686,7 +1707,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { }); }, - _moveStudyToFolderReqested: function(studyData, destWorkspaceId, destFolderId) { + __studyToFolderRequested: function(studyData, destWorkspaceId, destFolderId) { if (studyData["workspaceId"] === destWorkspaceId) { this.__doMoveStudy(studyData, destWorkspaceId, destFolderId); } else { @@ -1713,7 +1734,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { const data = e.getData(); const destWorkspaceId = data["workspaceId"]; const destFolderId = data["folderId"]; - this._moveStudyToFolderReqested(studyData, destWorkspaceId, destFolderId); + this.__studyToFolderRequested(studyData, destWorkspaceId, destFolderId); }, this); moveStudyTo.addListener("cancel", () => win.close()); }, this); diff --git a/services/static-webserver/client/source/class/osparc/file/FilesTree.js b/services/static-webserver/client/source/class/osparc/file/FilesTree.js index e2736c0fadd..a682bbca1c2 100644 --- a/services/static-webserver/client/source/class/osparc/file/FilesTree.js +++ b/services/static-webserver/client/source/class/osparc/file/FilesTree.js @@ -181,7 +181,7 @@ qx.Class.define("osparc.file.FilesTree", { newChildren[0].children[0].children.length) { // node const nodeData = newChildren[0].children[0].children[0]; const nodeTreeName = nodeData.label; - this.__resetTree(nodeTreeName); + this.__resetTree(nodeTreeName, nodeId); const rootNodeModel = this.getModel(); if (nodeData.children.length) { const nodeItemsOnly = nodeData.children; @@ -253,12 +253,12 @@ qx.Class.define("osparc.file.FilesTree", { } }, - __resetTree: function(treeName) { - // FIXME: It is not resetting the model + __resetTree: function(treeName, itemId) { + itemId = itemId || treeName.replace(/\s/g, ""); // default to tree name without white spaces this.resetModel(); const rootData = { label: treeName, - itemId: treeName.replace(/\s/g, ""), // remove all white spaces + itemId, location: null, path: null, pathLabel: [treeName], diff --git a/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js b/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js index d9349713218..d85836d5ed7 100644 --- a/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js +++ b/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js @@ -119,15 +119,14 @@ qx.Class.define("osparc.file.TreeFolderView", { let found = false; while (!found && path.length) { found = foldersTree.findItemId(path.join("/")); - if (found) { - foldersTree.openNodeAndParents(found); - foldersTree.setSelection(new qx.data.Array([found])); - foldersTree.fireEvent("selectionChanged"); - } // look for next parent path.pop(); } - if (!found) { + if (found) { + foldersTree.openNodeAndParents(found); + foldersTree.setSelection(new qx.data.Array([found])); + foldersTree.fireEvent("selectionChanged"); + } else { folderViewer.resetFolder(); } } diff --git a/services/static-webserver/client/source/class/osparc/widget/NodeDataManager.js b/services/static-webserver/client/source/class/osparc/widget/NodeDataManager.js index 2785f658c6c..397477d1d94 100644 --- a/services/static-webserver/client/source/class/osparc/widget/NodeDataManager.js +++ b/services/static-webserver/client/source/class/osparc/widget/NodeDataManager.js @@ -125,6 +125,10 @@ qx.Class.define("osparc.widget.NodeDataManager", { foldersTree.resetCache(); const openSameFolder = () => { + if (!this.getStudyId()) { + // drop first, which is the study id + path.shift(); + } // drop last, which is the file path.pop(); treeFolderView.openPath(path); diff --git a/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js b/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js index bf42bde89f7..37279ed42c1 100644 --- a/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js +++ b/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js @@ -129,7 +129,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { __selectedItemId: null, __startHint: null, __toolHint: null, - __dropHereNodeUI: null, + __dropHereUI: null, __selectionRectInitPos: null, __selectionRectRepr: null, __panning: null, @@ -1685,7 +1685,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { this.setDroppable(true); const stopDragging = e => { this.__isDraggingLink = null; - this.__updateWidgets(false); + this.__updateDropHere(false); }; const startDragging = e => { this.addListenerOnce("dragleave", stopDragging, this); @@ -1786,7 +1786,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { const posX = e.offsetX + 2; const posY = e.offsetY + 2; - this.__updateWidgets(dragging, posX, posY); + this.__updateDropHere(dragging, posX, posY); }, __draggingLink: function(e, dragging) { @@ -1802,14 +1802,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { } const pos = this.__pointerEventToWorkbenchPos(e); - this.__updateWidgets(dragging, pos.x, pos.y); + this.__updateDropHere(dragging, pos.x, pos.y); }, - __updateWidgets: function(dragging, posX, posY) { + __updateDropHere: function(show, posX, posY) { const boxWidth = 120; const boxHeight = 60; - if (this.__dropHereNodeUI === null) { - const dropHereNodeUI = this.__dropHereNodeUI = new qx.ui.basic.Label(this.tr("Drop here")).set({ + if (this.__dropHereUI === null) { + const dropHereNodeUI = this.__dropHereUI = new qx.ui.basic.Label(this.tr("Drop here")).set({ font: "workbench-start-hint", textColor: "workbench-start-hint" }); @@ -1817,19 +1817,21 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { this.__workbenchLayout.add(dropHereNodeUI); dropHereNodeUI.rect = this.__svgLayer.drawDashedRect(boxWidth, boxHeight); } - const dropMe = this.__dropHereNodeUI; - if (dragging) { - dropMe.show(); - const dropMeBounds = dropMe.getBounds() || dropMe.getSizeHint(); - dropMe.setLayoutProperties({ + let dropHere = this.__dropHereUI; + if (show) { + dropHere.show(); + const dropMeBounds = dropHere.getBounds() || dropHere.getSizeHint(); + dropHere.setLayoutProperties({ left: posX - parseInt(dropMeBounds.width/2) - parseInt(boxWidth/2), top: posY - parseInt(dropMeBounds.height/2)- parseInt(boxHeight/2) }); - if ("rect" in dropMe) { - osparc.wrapper.Svg.updateItemPos(dropMe.rect, posX - boxWidth, posY - boxHeight); + if ("rect" in dropHere) { + osparc.wrapper.Svg.updateItemPos(dropHere.rect, posX - boxWidth, posY - boxHeight); } } else { - this.__removeDropHint(); + dropHere.exclude(); + osparc.wrapper.Svg.removeItem(dropHere.rect); + dropHere = null; } }, @@ -2017,14 +2019,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { this.__draggingLink(e, false); if (this.__isDraggingLink && "dragData" in this.__isDraggingLink) { + const data = this.__isDraggingLink["dragData"]; + this.__isDraggingLink = null; const pos = this.__pointerEventToWorkbenchPos(e, false); const service = qx.data.marshal.Json.createModel(osparc.service.Utils.getFilePicker()); const nodeUI = await this.__addNode(service, pos); if (nodeUI) { const node = nodeUI.getNode(); - const data = this.__isDraggingLink["dragData"]; osparc.file.FilePicker.setOutputValueFromStore(node, data.getLocation(), data.getDatasetId(), data.getFileId(), data.getLabel()); - this.__isDraggingLink = null; } } }, @@ -2047,11 +2049,5 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { }); } }, - - __removeDropHint: function() { - this.__dropHereNodeUI.setVisibility("excluded"); - osparc.wrapper.Svg.removeItem(this.__dropHereNodeUI.rect); - this.__dropHereNodeUI = null; - } } });