Skip to content

Commit 208de24

Browse files
authored
🐛 [Frontend] bugfix: open folder after deleting file (#6997)
1 parent 4659473 commit 208de24

File tree

4 files changed

+32
-33
lines changed

4 files changed

+32
-33
lines changed

services/static-webserver/client/source/class/osparc/file/FilesTree.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ qx.Class.define("osparc.file.FilesTree", {
181181
newChildren[0].children[0].children.length) { // node
182182
const nodeData = newChildren[0].children[0].children[0];
183183
const nodeTreeName = nodeData.label;
184-
this.__resetTree(nodeTreeName);
184+
this.__resetTree(nodeTreeName, nodeId);
185185
const rootNodeModel = this.getModel();
186186
if (nodeData.children.length) {
187187
const nodeItemsOnly = nodeData.children;
@@ -253,12 +253,12 @@ qx.Class.define("osparc.file.FilesTree", {
253253
}
254254
},
255255

256-
__resetTree: function(treeName) {
257-
// FIXME: It is not resetting the model
256+
__resetTree: function(treeName, itemId) {
257+
itemId = itemId || treeName.replace(/\s/g, ""); // default to tree name without white spaces
258258
this.resetModel();
259259
const rootData = {
260260
label: treeName,
261-
itemId: treeName.replace(/\s/g, ""), // remove all white spaces
261+
itemId,
262262
location: null,
263263
path: null,
264264
pathLabel: [treeName],

services/static-webserver/client/source/class/osparc/file/TreeFolderView.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,14 @@ qx.Class.define("osparc.file.TreeFolderView", {
119119
let found = false;
120120
while (!found && path.length) {
121121
found = foldersTree.findItemId(path.join("/"));
122-
if (found) {
123-
foldersTree.openNodeAndParents(found);
124-
foldersTree.setSelection(new qx.data.Array([found]));
125-
foldersTree.fireEvent("selectionChanged");
126-
}
127122
// look for next parent
128123
path.pop();
129124
}
130-
if (!found) {
125+
if (found) {
126+
foldersTree.openNodeAndParents(found);
127+
foldersTree.setSelection(new qx.data.Array([found]));
128+
foldersTree.fireEvent("selectionChanged");
129+
} else {
131130
folderViewer.resetFolder();
132131
}
133132
}

services/static-webserver/client/source/class/osparc/widget/NodeDataManager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ qx.Class.define("osparc.widget.NodeDataManager", {
125125
foldersTree.resetCache();
126126

127127
const openSameFolder = () => {
128+
if (!this.getStudyId()) {
129+
// drop first, which is the study id
130+
path.shift();
131+
}
128132
// drop last, which is the file
129133
path.pop();
130134
treeFolderView.openPath(path);

services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
129129
__selectedItemId: null,
130130
__startHint: null,
131131
__toolHint: null,
132-
__dropHereNodeUI: null,
132+
__dropHereUI: null,
133133
__selectionRectInitPos: null,
134134
__selectionRectRepr: null,
135135
__panning: null,
@@ -1685,7 +1685,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
16851685
this.setDroppable(true);
16861686
const stopDragging = e => {
16871687
this.__isDraggingLink = null;
1688-
this.__updateWidgets(false);
1688+
this.__updateDropHere(false);
16891689
};
16901690
const startDragging = e => {
16911691
this.addListenerOnce("dragleave", stopDragging, this);
@@ -1786,7 +1786,7 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
17861786

17871787
const posX = e.offsetX + 2;
17881788
const posY = e.offsetY + 2;
1789-
this.__updateWidgets(dragging, posX, posY);
1789+
this.__updateDropHere(dragging, posX, posY);
17901790
},
17911791

17921792
__draggingLink: function(e, dragging) {
@@ -1802,34 +1802,36 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
18021802
}
18031803

18041804
const pos = this.__pointerEventToWorkbenchPos(e);
1805-
this.__updateWidgets(dragging, pos.x, pos.y);
1805+
this.__updateDropHere(dragging, pos.x, pos.y);
18061806
},
18071807

1808-
__updateWidgets: function(dragging, posX, posY) {
1808+
__updateDropHere: function(show, posX, posY) {
18091809
const boxWidth = 120;
18101810
const boxHeight = 60;
1811-
if (this.__dropHereNodeUI === null) {
1812-
const dropHereNodeUI = this.__dropHereNodeUI = new qx.ui.basic.Label(this.tr("Drop here")).set({
1811+
if (this.__dropHereUI === null) {
1812+
const dropHereNodeUI = this.__dropHereUI = new qx.ui.basic.Label(this.tr("Drop here")).set({
18131813
font: "workbench-start-hint",
18141814
textColor: "workbench-start-hint"
18151815
});
18161816
dropHereNodeUI.exclude();
18171817
this.__workbenchLayout.add(dropHereNodeUI);
18181818
dropHereNodeUI.rect = this.__svgLayer.drawDashedRect(boxWidth, boxHeight);
18191819
}
1820-
const dropMe = this.__dropHereNodeUI;
1821-
if (dragging) {
1822-
dropMe.show();
1823-
const dropMeBounds = dropMe.getBounds() || dropMe.getSizeHint();
1824-
dropMe.setLayoutProperties({
1820+
let dropHere = this.__dropHereUI;
1821+
if (show) {
1822+
dropHere.show();
1823+
const dropMeBounds = dropHere.getBounds() || dropHere.getSizeHint();
1824+
dropHere.setLayoutProperties({
18251825
left: posX - parseInt(dropMeBounds.width/2) - parseInt(boxWidth/2),
18261826
top: posY - parseInt(dropMeBounds.height/2)- parseInt(boxHeight/2)
18271827
});
1828-
if ("rect" in dropMe) {
1829-
osparc.wrapper.Svg.updateItemPos(dropMe.rect, posX - boxWidth, posY - boxHeight);
1828+
if ("rect" in dropHere) {
1829+
osparc.wrapper.Svg.updateItemPos(dropHere.rect, posX - boxWidth, posY - boxHeight);
18301830
}
18311831
} else {
1832-
this.__removeDropHint();
1832+
dropHere.exclude();
1833+
osparc.wrapper.Svg.removeItem(dropHere.rect);
1834+
dropHere = null;
18331835
}
18341836
},
18351837

@@ -2017,14 +2019,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
20172019
this.__draggingLink(e, false);
20182020

20192021
if (this.__isDraggingLink && "dragData" in this.__isDraggingLink) {
2022+
const data = this.__isDraggingLink["dragData"];
2023+
this.__isDraggingLink = null;
20202024
const pos = this.__pointerEventToWorkbenchPos(e, false);
20212025
const service = qx.data.marshal.Json.createModel(osparc.service.Utils.getFilePicker());
20222026
const nodeUI = await this.__addNode(service, pos);
20232027
if (nodeUI) {
20242028
const node = nodeUI.getNode();
2025-
const data = this.__isDraggingLink["dragData"];
20262029
osparc.file.FilePicker.setOutputValueFromStore(node, data.getLocation(), data.getDatasetId(), data.getFileId(), data.getLabel());
2027-
this.__isDraggingLink = null;
20282030
}
20292031
}
20302032
},
@@ -2047,11 +2049,5 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
20472049
});
20482050
}
20492051
},
2050-
2051-
__removeDropHint: function() {
2052-
this.__dropHereNodeUI.setVisibility("excluded");
2053-
osparc.wrapper.Svg.removeItem(this.__dropHereNodeUI.rect);
2054-
this.__dropHereNodeUI = null;
2055-
}
20562052
}
20572053
});

0 commit comments

Comments
 (0)