Skip to content

Commit 096c18f

Browse files
committed
refactor
1 parent 2e148c2 commit 096c18f

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,27 @@ qx.Class.define("osparc.dashboard.GroupedCardContainer", {
125125
return control || this.base(arguments, id);
126126
},
127127

128+
__modeChanged: function(container) {
129+
const spacing = this.getMode() === "grid" ? osparc.dashboard.GridButtonBase.SPACING : osparc.dashboard.ListButtonBase.SPACING;
130+
container.getLayout().set({
131+
spacingX: spacing,
132+
spacingY: spacing
133+
});
134+
if (this.getMode() === "list") {
135+
this.set({
136+
expanded: true,
137+
});
138+
}
139+
},
140+
128141
__createContentContainer: function() {
129142
let contentContainer = null;
130143
const expanded = this.isExpanded();
131144
const showAllBtn = this.__expandButton;
132145
if (expanded) {
133146
contentContainer = new osparc.dashboard.CardContainer();
134-
135-
const setContainerSpacing = () => {
136-
const spacing = this.getMode() === "grid" ? osparc.dashboard.GridButtonBase.SPACING : osparc.dashboard.ListButtonBase.SPACING;
137-
contentContainer.getLayout().set({
138-
spacingX: spacing,
139-
spacingY: spacing
140-
});
141-
};
142-
setContainerSpacing();
143-
this.addListener("changeMode", () => setContainerSpacing());
147+
this.__modeChanged(contentContainer);
148+
this.addListener("changeMode", () => this.__modeChanged(contentContainer));
144149
[
145150
"changeSelection",
146151
"changeVisibility"

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,18 @@ qx.Class.define("osparc.dashboard.ResourceContainerManager", {
311311
}
312312
},
313313

314+
__modeChanged: function(container) {
315+
const spacing = this.getMode() === "grid" ? osparc.dashboard.GridButtonBase.SPACING : osparc.dashboard.ListButtonBase.SPACING;
316+
container.getLayout().set({
317+
spacingX: spacing,
318+
spacingY: spacing
319+
});
320+
},
321+
314322
__createFlatList: function() {
315323
const flatList = new osparc.dashboard.CardContainer();
316-
const setContainerSpacing = () => {
317-
const spacing = this.getMode() === "grid" ? osparc.dashboard.GridButtonBase.SPACING : osparc.dashboard.ListButtonBase.SPACING;
318-
flatList.getLayout().set({
319-
spacingX: spacing,
320-
spacingY: spacing
321-
});
322-
};
323-
setContainerSpacing();
324-
this.addListener("changeMode", () => setContainerSpacing());
324+
this.__modeChanged(flatList);
325+
this.addListener("changeMode", () => this.__modeChanged(flatList));
325326
[
326327
"changeSelection",
327328
"changeVisibility"

0 commit comments

Comments
 (0)