Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Frontend] bugfix: open folder after deleting file #6997

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -1802,34 +1802,36 @@ 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"
});
dropHereNodeUI.exclude();
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;
}
},

Expand Down Expand Up @@ -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;
}
}
},
Expand All @@ -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;
}
}
});
Loading