Skip to content

Commit 12abcaa

Browse files
committed
refactoring: more binding
1 parent ad451ea commit 12abcaa

File tree

4 files changed

+34
-38
lines changed

4 files changed

+34
-38
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ContextBreadcrumbs.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,20 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", {
2626
}));
2727
},
2828

29-
events: {
30-
"changeContext": "qx.event.type.Data",
31-
},
32-
3329
properties: {
3430
currentWorkspaceId: {
3531
check: "Number",
3632
nullable: true,
3733
init: null,
34+
event: "changeCurrentWorkspaceId",
3835
apply: "__rebuild"
3936
},
4037

4138
currentFolderId: {
4239
check: "Number",
4340
nullable: true,
4441
init: null,
42+
event: "changeCurrentFolderId",
4543
apply: "__rebuild"
4644
}
4745
},
@@ -82,15 +80,12 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", {
8280
return this.__createFolderButton(currentFolder);
8381
},
8482

85-
__changeContext: function(workspaceId, folderId) {
83+
__changeFolder: function(folderId) {
84+
const workspaceId = this.getCurrentWorkspaceId();
8685
this.set({
8786
currentWorkspaceId: workspaceId,
8887
currentFolderId: folderId,
8988
});
90-
this.fireDataEvent("changeContext", {
91-
workspaceId,
92-
folderId,
93-
});
9489
},
9590

9691
__createRootButton: function() {
@@ -111,25 +106,28 @@ qx.Class.define("osparc.dashboard.ContextBreadcrumbs", {
111106
}
112107
rootButton.addListener("execute", () => {
113108
const folderId = null;
114-
this.__changeContext(workspaceId, folderId);
109+
this.__changeFolder(folderId);
115110
});
116111
return rootButton;
117112
},
118113

119114
__createFolderButton: function(folder) {
120115
let folderButton = null;
121116
if (folder) {
122-
folderButton = new qx.ui.form.Button(folder.getName(), "@FontAwesome5Solid/folder/14").set({
117+
folderButton = new qx.ui.form.Button(folder.getName()).set({
123118
maxWidth: 200
124119
});
125120
folder.bind("name", folderButton, "label");
126121
folderButton.addListener("execute", () => {
127-
const workspaceId = this.getCurrentWorkspaceId();
128122
const folderId = folder ? folder.getFolderId() : null;
129-
this.__changeContext(workspaceId, folderId);
123+
this.__changeFolder(folderId);
130124
}, this);
131125
} else {
132126
folderButton = this.__createRootButton();
127+
// Do not show root folder
128+
folderButton.set({
129+
visibility: "excluded"
130+
});
133131
}
134132
folderButton.set({
135133
backgroundColor: "transparent",

services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
274274
resourcesContainer.addListener("workspaceUpdated", e => this._workspaceUpdated(e.getData()));
275275
resourcesContainer.addListener("deleteWorkspaceRequested", e => this._deleteWorkspaceRequested(e.getData()));
276276

277-
const containerHeader = this._resourcesContainer.getContainerHeader();
278-
containerHeader.addListener("changeContext", e => {
279-
const {
280-
workspaceId,
281-
folderId,
282-
} = e.getData();
283-
this._resourceFilter.contextChanged(workspaceId, folderId);
284-
}, this);
285-
286277
this._addToLayout(resourcesContainer);
287278
},
288279

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -877,27 +877,24 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
877877
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
878878
const workspaceHeader = new osparc.dashboard.WorkspaceHeader();
879879
this.bind("currentWorkspaceId", workspaceHeader, "currentWorkspaceId");
880+
this.bind("currentFolderId", workspaceHeader, "currentFolderId");
881+
[
882+
"changeCurrentWorkspaceId",
883+
"changeCurrentFolderId",
884+
].forEach(ev => {
885+
workspaceHeader.addListener(ev, () => {
886+
const workspaceId = workspaceHeader.getCurrentWorkspaceId();
887+
const folderId = workspaceHeader.getCurrentFolderId();
888+
this._changeContext(workspaceId, folderId);
889+
this._resourceFilter.contextChanged(workspaceId, folderId);
890+
}, this);
891+
});
892+
880893
this._addToLayout(workspaceHeader);
881894
}
882895

883896
this._createResourcesLayout();
884897

885-
const containerHeader = this._resourcesContainer.getContainerHeader();
886-
if (containerHeader) {
887-
this.bind("currentWorkspaceId", containerHeader, "currentWorkspaceId");
888-
this.bind("currentFolderId", containerHeader, "currentFolderId");
889-
containerHeader.addListener("changeContext", e => {
890-
const {
891-
workspaceId,
892-
folderId,
893-
} = e.getData();
894-
this.set({
895-
currentWorkspaceId: workspaceId,
896-
currentFolderId: folderId,
897-
})
898-
this._changeContext(workspaceId, folderId);
899-
});
900-
}
901898
const list = this._resourcesContainer.getFlatList();
902899
if (list) {
903900
osparc.utils.Utils.setIdToWidget(list, "studiesList");

services/static-webserver/client/source/class/osparc/dashboard/WorkspaceHeader.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ qx.Class.define("osparc.dashboard.WorkspaceHeader", {
5252
apply: "__buildLayout"
5353
},
5454

55+
currentFolderId: {
56+
check: "Number",
57+
nullable: true,
58+
init: null,
59+
event: "changeCurrentFolderId",
60+
},
61+
5562
accessRights: {
5663
check: "Object",
5764
nullable: false,
@@ -101,6 +108,9 @@ qx.Class.define("osparc.dashboard.WorkspaceHeader", {
101108
case "breadcrumbs":
102109
control = new osparc.dashboard.ContextBreadcrumbs();
103110
this.bind("currentWorkspaceId", control, "currentWorkspaceId");
111+
this.bind("currentFolderId", control, "currentFolderId");
112+
control.bind("currentWorkspaceId", this, "currentWorkspaceId");
113+
control.bind("currentFolderId", this, "currentFolderId");
104114
this._add(control);
105115
break;
106116
case "edit-button":

0 commit comments

Comments
 (0)