Skip to content

Commit 08d1682

Browse files
committed
refactor
1 parent a0ee59d commit 08d1682

File tree

4 files changed

+144
-143
lines changed

4 files changed

+144
-143
lines changed

services/static-webserver/client/source/class/osparc/info/ServiceLarge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ qx.Class.define("osparc.info.ServiceLarge", {
148148
// Rest of information
149149
const infoElements = this.__infoElements();
150150
const isStudy = false;
151-
const infoLayout = osparc.info.StudyUtils.infoElementsToLayout(infoElements, isStudy);
151+
const infoLayout = osparc.info.Utils.infoElementsToLayout(infoElements, isStudy);
152152
vBox.add(infoLayout);
153153

154154
// Resources info if not billable

services/static-webserver/client/source/class/osparc/info/StudyLarge.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ qx.Class.define("osparc.info.StudyLarge", {
103103
}
104104

105105
const infoElements = this.__infoElements();
106-
const infoLayout = osparc.info.StudyUtils.infoElementsToLayout(infoElements);
106+
const isStudy = true;
107+
const infoLayout = osparc.info.Utils.infoElementsToLayout(infoElements, isStudy);
107108
vBox.add(infoLayout);
108109

109110
// Copy Id button

services/static-webserver/client/source/class/osparc/info/StudyUtils.js

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -242,147 +242,6 @@ qx.Class.define("osparc.info.StudyUtils", {
242242
return tagsContainer;
243243
},
244244

245-
infoElementsToLayout: function(infoElements, isStudy = true) {
246-
const container = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
247-
248-
const decorateAction = action => {
249-
action.button.set({
250-
alignY: "middle",
251-
});
252-
action.button.addListener("execute", () => {
253-
const cb = action.callback;
254-
if (typeof cb === "string") {
255-
action.ctx.fireEvent(cb);
256-
} else {
257-
cb.call(action.ctx);
258-
}
259-
}, this);
260-
};
261-
262-
if ("TITLE" in infoElements) {
263-
const extraInfo = infoElements["TITLE"];
264-
const titleLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
265-
266-
if (extraInfo.action && extraInfo.action.button) {
267-
decorateAction(extraInfo.action);
268-
titleLayout.add(extraInfo.action.button);
269-
}
270-
271-
if (extraInfo.view) {
272-
titleLayout.add(extraInfo.view, {
273-
flex: 1,
274-
});
275-
}
276-
277-
container.add(titleLayout);
278-
}
279-
280-
281-
const centerLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
282-
283-
if ("THUMBNAIL" in infoElements) {
284-
const extraInfo = infoElements["THUMBNAIL"];
285-
const thumbnailLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(8));
286-
287-
if (extraInfo.action && extraInfo.action.button) {
288-
decorateAction(extraInfo.action);
289-
thumbnailLayout.add(extraInfo.action.button);
290-
}
291-
292-
if (extraInfo.view) {
293-
thumbnailLayout.add(extraInfo.view, {
294-
flex: 1,
295-
});
296-
}
297-
298-
centerLayout.add(thumbnailLayout);
299-
}
300-
301-
const gridKeys = isStudy ? [
302-
"AUTHOR",
303-
"ACCESS_RIGHTS",
304-
"CREATED",
305-
"MODIFIED",
306-
"TAGS",
307-
"LOCATION",
308-
] : [
309-
"SERVICE_ID",
310-
"KEY",
311-
"INTEGRATION_VERSION",
312-
"VERSION",
313-
"DATE",
314-
"CONTACT",
315-
"AUTHORS",
316-
"ACCESS_RIGHTS",
317-
"DESCRIPTION_ONLY",
318-
];
319-
320-
const grid = new qx.ui.layout.Grid(6, 6);
321-
grid.setColumnAlign(0, "right", "middle"); // titles
322-
const gridLayout = new qx.ui.container.Composite(grid);
323-
324-
let row = 0;
325-
gridKeys.forEach(key => {
326-
if (key in infoElements) {
327-
const infoElement = infoElements[key];
328-
329-
let col = 0;
330-
if (infoElement.label) {
331-
const title = new qx.ui.basic.Label(infoElement.label).set({
332-
alignX: "right",
333-
});
334-
gridLayout.add(title, {
335-
row,
336-
column: col + 0,
337-
});
338-
}
339-
col++;
340-
341-
if (infoElement.action && infoElement.action.button) {
342-
decorateAction(infoElement.action);
343-
gridLayout.add(infoElement.action.button, {
344-
row,
345-
column: col + 1,
346-
});
347-
}
348-
col++;
349-
350-
if (infoElement.view) {
351-
gridLayout.add(infoElement.view, {
352-
row,
353-
column: col + 2,
354-
});
355-
}
356-
col++;
357-
row++;
358-
}
359-
});
360-
centerLayout.add(gridLayout, {
361-
flex: 1,
362-
});
363-
container.add(centerLayout);
364-
365-
if ("DESCRIPTION" in infoElements) {
366-
const infoElement = infoElements["DESCRIPTION"];
367-
const descriptionLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
368-
369-
if (infoElement.action && infoElement.action.button) {
370-
decorateAction(infoElement.action);
371-
descriptionLayout.add(infoElement.action.button);
372-
}
373-
374-
if (infoElement.view) {
375-
descriptionLayout.add(infoElement.view, {
376-
flex: 1,
377-
});
378-
}
379-
380-
container.add(descriptionLayout);
381-
}
382-
383-
return container;
384-
},
385-
386245
/**
387246
* @param studyData {Object} Serialized Study Object
388247
*/

services/static-webserver/client/source/class/osparc/info/Utils.js

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,147 @@ qx.Class.define("osparc.info.Utils", {
4242
return image;
4343
},
4444

45+
infoElementsToLayout: function(infoElements, isStudy = true) {
46+
const container = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
47+
48+
const decorateAction = action => {
49+
action.button.set({
50+
alignY: "middle",
51+
});
52+
action.button.addListener("execute", () => {
53+
const cb = action.callback;
54+
if (typeof cb === "string") {
55+
action.ctx.fireEvent(cb);
56+
} else {
57+
cb.call(action.ctx);
58+
}
59+
}, this);
60+
};
61+
62+
if ("TITLE" in infoElements) {
63+
const extraInfo = infoElements["TITLE"];
64+
const titleLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
65+
66+
if (extraInfo.action && extraInfo.action.button) {
67+
decorateAction(extraInfo.action);
68+
titleLayout.add(extraInfo.action.button);
69+
}
70+
71+
if (extraInfo.view) {
72+
titleLayout.add(extraInfo.view, {
73+
flex: 1,
74+
});
75+
}
76+
77+
container.add(titleLayout);
78+
}
79+
80+
81+
const centerLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
82+
83+
if ("THUMBNAIL" in infoElements) {
84+
const extraInfo = infoElements["THUMBNAIL"];
85+
const thumbnailLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(8));
86+
87+
if (extraInfo.action && extraInfo.action.button) {
88+
decorateAction(extraInfo.action);
89+
thumbnailLayout.add(extraInfo.action.button);
90+
}
91+
92+
if (extraInfo.view) {
93+
thumbnailLayout.add(extraInfo.view, {
94+
flex: 1,
95+
});
96+
}
97+
98+
centerLayout.add(thumbnailLayout);
99+
}
100+
101+
const gridKeys = isStudy ? [
102+
"AUTHOR",
103+
"ACCESS_RIGHTS",
104+
"CREATED",
105+
"MODIFIED",
106+
"TAGS",
107+
"LOCATION",
108+
] : [
109+
"SERVICE_ID",
110+
"KEY",
111+
"INTEGRATION_VERSION",
112+
"VERSION",
113+
"DATE",
114+
"CONTACT",
115+
"AUTHORS",
116+
"ACCESS_RIGHTS",
117+
"DESCRIPTION_ONLY",
118+
];
119+
120+
const grid = new qx.ui.layout.Grid(6, 6);
121+
grid.setColumnAlign(0, "right", "middle"); // titles
122+
const gridLayout = new qx.ui.container.Composite(grid);
123+
124+
let row = 0;
125+
gridKeys.forEach(key => {
126+
if (key in infoElements) {
127+
const infoElement = infoElements[key];
128+
129+
let col = 0;
130+
if (infoElement.label) {
131+
const title = new qx.ui.basic.Label(infoElement.label).set({
132+
alignX: "right",
133+
});
134+
gridLayout.add(title, {
135+
row,
136+
column: col + 0,
137+
});
138+
}
139+
col++;
140+
141+
if (infoElement.action && infoElement.action.button) {
142+
decorateAction(infoElement.action);
143+
gridLayout.add(infoElement.action.button, {
144+
row,
145+
column: col + 1,
146+
});
147+
}
148+
col++;
149+
150+
if (infoElement.view) {
151+
gridLayout.add(infoElement.view, {
152+
row,
153+
column: col + 2,
154+
});
155+
}
156+
col++;
157+
row++;
158+
}
159+
});
160+
centerLayout.add(gridLayout, {
161+
flex: 1,
162+
});
163+
container.add(centerLayout);
164+
165+
if ("DESCRIPTION" in infoElements) {
166+
const infoElement = infoElements["DESCRIPTION"];
167+
const descriptionLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
168+
169+
if (infoElement.action && infoElement.action.button) {
170+
decorateAction(infoElement.action);
171+
descriptionLayout.add(infoElement.action.button);
172+
}
173+
174+
if (infoElement.view) {
175+
descriptionLayout.add(infoElement.view, {
176+
flex: 1,
177+
});
178+
}
179+
180+
container.add(descriptionLayout);
181+
}
182+
183+
return container;
184+
},
185+
45186
extraInfosToGrid: function(extraInfos) {
46187
const grid = new qx.ui.layout.Grid(8, 5);
47188
grid.setColumnAlign(0, "right", "middle");

0 commit comments

Comments
 (0)