Skip to content

Commit ca8718d

Browse files
authored
🎨 [Frontend] Grouped list view (#7845)
1 parent 3917210 commit ca8718d

File tree

3 files changed

+65
-27
lines changed

3 files changed

+65
-27
lines changed

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,19 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", {
6666
nullable: false,
6767
event: "changeExpanded",
6868
apply: "__applyExpanded"
69-
}
69+
},
70+
71+
mode: {
72+
check: ["grid", "list"],
73+
init: "grid",
74+
nullable: false,
75+
event: "changeMode"
76+
},
77+
},
78+
79+
events: {
80+
"changeSelection": "qx.event.type.Data",
81+
"changeVisibility": "qx.event.type.Data"
7082
},
7183

7284
members: {
@@ -113,12 +125,30 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", {
113125
return control || this.base(arguments, id);
114126
},
115127

128+
__modeChanged: function(container) {
129+
osparc.dashboard.ResourceContainerManager.updateSpacing(this.getMode(), container);
130+
if (this.getMode() === "list") {
131+
this.set({
132+
expanded: true,
133+
});
134+
}
135+
},
136+
116137
__createContentContainer: function() {
117138
let contentContainer = null;
118139
const expanded = this.isExpanded();
119140
const showAllBtn = this.__expandButton;
120141
if (expanded) {
121142
contentContainer = new osparc.dashboard.CardContainer();
143+
this.__modeChanged(contentContainer);
144+
this.addListener("changeMode", () => this.__modeChanged(contentContainer));
145+
[
146+
"changeSelection",
147+
"changeVisibility"
148+
].forEach(signalName => {
149+
contentContainer.addListener(signalName, e => this.fireDataEvent(signalName, e.getData()), this);
150+
});
151+
122152
showAllBtn.show();
123153
} else {
124154
const spacing = osparc.dashboard.GridButtonBase.SPACING;
@@ -136,7 +166,8 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", {
136166
});
137167
}
138168
contentContainer.set({
139-
padding: 5,
169+
paddingTop: 5,
170+
paddingBottom: 5,
140171
allowGrowX: false
141172
});
142173
this._addAt(contentContainer, 1, {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
325325
},
326326

327327
_groupByChanged: function(groupBy) {
328-
// if cards are grouped they need to be in grid mode
329-
this._resourcesContainer.setMode("grid");
330-
this.__viewModeLayout.setVisibility(groupBy ? "excluded" : "visible");
331328
this._resourcesContainer.setGroupBy(groupBy);
332329
this._reloadCards();
333330
},

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

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,15 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
110110
}
111111
}
112112
return false;
113-
}
113+
},
114+
115+
updateSpacing: function(mode, container) {
116+
const spacing = mode === "grid" ? osparc.dashboard.GridButtonBase.SPACING : osparc.dashboard.ListButtonBase.SPACING;
117+
container.getLayout().set({
118+
spacingX: spacing,
119+
spacingY: spacing
120+
});
121+
},
114122
},
115123

116124
members: {
@@ -171,18 +179,6 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
171179
return this.__nonGroupedContainer;
172180
},
173181

174-
__createGroupContainer: function(groupId, headerLabel, headerColor = "text") {
175-
const groupContainer = new osparc.dashboard.GroupedCardContainer().set({
176-
groupId: groupId.toString(),
177-
headerLabel,
178-
headerIcon: "",
179-
headerColor,
180-
visibility: "excluded"
181-
});
182-
this.__groupedContainersList.push(groupContainer);
183-
return groupContainer;
184-
},
185-
186182
areMoreResourcesRequired: function(loadingResourcesBtn) {
187183
if (this.__nonGroupedContainer) {
188184
return this.__nonGroupedContainer.areMoreResourcesRequired(loadingResourcesBtn);
@@ -325,15 +321,8 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
325321

326322
__createFlatList: function() {
327323
const flatList = new osparc.dashboard.CardContainer();
328-
const setContainerSpacing = () => {
329-
const spacing = this.getMode() === "grid" ? osparc.dashboard.GridButtonBase.SPACING : osparc.dashboard.ListButtonBase.SPACING;
330-
flatList.getLayout().set({
331-
spacingX: spacing,
332-
spacingY: spacing
333-
});
334-
};
335-
setContainerSpacing();
336-
this.addListener("changeMode", () => setContainerSpacing());
324+
osparc.dashboard.ResourceContainerManager.updateSpacing(this.getMode(), flatList);
325+
this.addListener("changeMode", () => osparc.dashboard.ResourceContainerManager.updateSpacing(this.getMode(), flatList));
337326
[
338327
"changeSelection",
339328
"changeVisibility"
@@ -343,6 +332,27 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
343332
return flatList;
344333
},
345334

335+
__createGroupContainer: function(groupId, headerLabel, headerColor = "text") {
336+
const groupContainer = new osparc.dashboard.GroupedCardContainer().set({
337+
groupId: groupId.toString(),
338+
headerLabel,
339+
headerIcon: "",
340+
headerColor,
341+
visibility: "excluded"
342+
});
343+
344+
this.bind("mode", groupContainer, "mode");
345+
[
346+
"changeSelection",
347+
"changeVisibility"
348+
].forEach(signalName => {
349+
groupContainer.addListener(signalName, e => this.fireDataEvent(signalName, e.getData()), this);
350+
});
351+
352+
this.__groupedContainersList.push(groupContainer);
353+
return groupContainer;
354+
},
355+
346356
reloadCards: function(resourceType) {
347357
this.__rebuildLayout(resourceType);
348358

0 commit comments

Comments
 (0)