Skip to content

Commit bdbd7ec

Browse files
committed
[skip ci] renaming
1 parent 7f87ab3 commit bdbd7ec

File tree

1 file changed

+44
-39
lines changed
  • services/static-webserver/client/source/class/osparc/dashboard

1 file changed

+44
-39
lines changed

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

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
168168
if (plusButtonConfig["categories"]) {
169169
this.__addCategories(plusButtonConfig["categories"]);
170170
}
171-
plusButtonConfig["resources"].forEach(newStudyData => {
172-
if (newStudyData["showDisabled"]) {
173-
this.__addDisabledButton(newStudyData);
174-
} else if (newStudyData["resourceType"] === "study") {
175-
this.__addEmptyStudyButton(newStudyData);
176-
} else if (newStudyData["resourceType"] === "template") {
177-
this.__addFromTemplateButton(newStudyData, templates);
178-
} else if (newStudyData["resourceType"] === "service") {
179-
this.__addFromServiceButton(newStudyData);
171+
plusButtonConfig["resources"].forEach(buttonConfig => {
172+
if (buttonConfig["showDisabled"]) {
173+
this.__addDisabledButton(buttonConfig);
174+
} else if (buttonConfig["resourceType"] === "study") {
175+
this.__addEmptyStudyButton(buttonConfig);
176+
} else if (buttonConfig["resourceType"] === "template") {
177+
this.__addFromTemplateButton(buttonConfig, templates);
178+
} else if (buttonConfig["resourceType"] === "service") {
179+
this.__addFromServiceButton(buttonConfig);
180180
}
181181
});
182182
});
@@ -241,55 +241,55 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
241241
}
242242
},
243243

244-
__addDisabledButton: function(newStudyData) {
245-
const menuButton = this.self().createMenuButton(null, newStudyData["title"], newStudyData["reason"]);
246-
osparc.utils.Utils.setIdToWidget(menuButton, newStudyData["idToWidget"]);
244+
__addDisabledButton: function(buttonConfig) {
245+
const menuButton = this.self().createMenuButton(null, buttonConfig["title"], buttonConfig["reason"]);
246+
osparc.utils.Utils.setIdToWidget(menuButton, buttonConfig["idToWidget"]);
247247
menuButton.setEnabled(false);
248248

249-
this.__addIcon(menuButton, newStudyData);
250-
this.__addFromResourceButton(menuButton, newStudyData["category"]);
249+
this.__addIcon(menuButton, buttonConfig);
250+
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
251251
},
252252

253-
__addEmptyStudyButton: function(newStudyData) {
254-
const menuButton = this.self().createMenuButton(null, newStudyData["title"]);
255-
osparc.utils.Utils.setIdToWidget(menuButton, newStudyData["idToWidget"]);
253+
__addEmptyStudyButton: function(buttonConfig) {
254+
const menuButton = this.self().createMenuButton(null, buttonConfig["title"]);
255+
osparc.utils.Utils.setIdToWidget(menuButton, buttonConfig["idToWidget"]);
256256

257257
menuButton.addListener("tap", () => {
258258
this.fireDataEvent("newEmptyStudyClicked", {
259-
newStudyLabel: newStudyData["newStudyLabel"],
259+
newStudyLabel: buttonConfig["newStudyLabel"],
260260
});
261261
});
262262

263-
this.__addIcon(menuButton, newStudyData);
264-
this.__addFromResourceButton(menuButton, newStudyData["category"]);
263+
this.__addIcon(menuButton, buttonConfig);
264+
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
265265
},
266266

267-
__addFromTemplateButton: function(newStudyData, templates) {
268-
const menuButton = this.self().createMenuButton(null, newStudyData["title"]);
269-
osparc.utils.Utils.setIdToWidget(menuButton, newStudyData["idToWidget"]);
267+
__addFromTemplateButton: function(buttonConfig, templates) {
268+
const menuButton = this.self().createMenuButton(null, buttonConfig["title"]);
269+
osparc.utils.Utils.setIdToWidget(menuButton, buttonConfig["idToWidget"]);
270270
// disable it until found in templates store
271271
menuButton.setEnabled(false);
272272

273-
let templateMetadata = templates.find(t => t.name === newStudyData["expectedTemplateLabel"]);
273+
let templateMetadata = templates.find(t => t.name === buttonConfig["expectedTemplateLabel"]);
274274
if (templateMetadata) {
275275
menuButton.setEnabled(true);
276276
menuButton.addListener("tap", () => {
277277
this.fireDataEvent("newStudyFromTemplateClicked", {
278278
templateData: templateMetadata,
279-
newStudyLabel: newStudyData["newStudyLabel"],
279+
newStudyLabel: buttonConfig["newStudyLabel"],
280280
});
281281
});
282-
this.__addIcon(menuButton, newStudyData, templateMetadata);
283-
this.__addFromResourceButton(menuButton, newStudyData["category"]);
282+
this.__addIcon(menuButton, buttonConfig, templateMetadata);
283+
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
284284
}
285285
},
286286

287-
__addFromServiceButton: function(newStudyData) {
287+
__addFromServiceButton: function(buttonConfig) {
288288
const addListenerToButton = (menuButton, latestMetadata) => {
289289
menuButton.addListener("tap", () => {
290290
this.fireDataEvent("newStudyFromServiceClicked", {
291291
serviceMetadata: latestMetadata,
292-
newStudyLabel: newStudyData["newStudyLabel"],
292+
newStudyLabel: buttonConfig["newStudyLabel"],
293293
});
294294
});
295295

@@ -299,30 +299,35 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
299299
e.stopPropagation();
300300
latestMetadata["resourceType"] = "service";
301301
const resourceDetails = new osparc.dashboard.ResourceDetails(latestMetadata);
302-
osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails);
302+
const win = osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails);
303+
resourceDetails.addListener("openService", ev => {
304+
win.close();
305+
const openServiceData = ev.getData();
306+
this._createStudyFromService(openServiceData["key"], openServiceData["version"]);
307+
});
303308
}
304309
const infoButton = new osparc.ui.basic.IconButton(osparc.ui.hint.InfoHint.INFO_ICON + "/16", cb);
305310
// where the shortcut is supposed to go
306311
// eslint-disable-next-line no-underscore-dangle
307312
menuButton._add(infoButton, {column: 2});
308313
};
309314

310-
if ("expectedKey" in newStudyData) {
311-
const menuButton = this.self().createMenuButton(null, newStudyData["title"]);
312-
osparc.utils.Utils.setIdToWidget(menuButton, newStudyData["idToWidget"]);
315+
if ("expectedKey" in buttonConfig) {
316+
const menuButton = this.self().createMenuButton(null, buttonConfig["title"]);
317+
osparc.utils.Utils.setIdToWidget(menuButton, buttonConfig["idToWidget"]);
313318
// disable it until found in services store
314319
menuButton.setEnabled(false);
315320

316-
const key = newStudyData["expectedKey"];
321+
const key = buttonConfig["expectedKey"];
317322
const latestMetadata = osparc.store.Services.getLatest(key);
318323
if (!latestMetadata) {
319324
return;
320325
}
321326
menuButton.setEnabled(true);
322-
this.__addIcon(menuButton, newStudyData, latestMetadata);
323-
this.__addFromResourceButton(menuButton, newStudyData["category"]);
327+
this.__addIcon(menuButton, buttonConfig, latestMetadata);
328+
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
324329
addListenerToButton(menuButton, latestMetadata);
325-
} else if ("myMostUsed" in newStudyData) {
330+
} else if ("myMostUsed" in buttonConfig) {
326331
const excludeFrontend = true;
327332
const excludeDeprecated = true
328333
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
@@ -331,7 +336,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
331336
"sort": "hits",
332337
"order": "down"
333338
});
334-
for (let i=0; i<newStudyData["myMostUsed"]; i++) {
339+
for (let i=0; i<buttonConfig["myMostUsed"]; i++) {
335340
const latestMetadata = servicesList[i];
336341
if (latestMetadata && latestMetadata["hits"] > 0) {
337342
const menuButton = new qx.ui.menu.Button().set({
@@ -340,7 +345,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
340345
allowGrowX: true,
341346
});
342347
this.__addIcon(menuButton, null, latestMetadata);
343-
this.__addFromResourceButton(menuButton, newStudyData["category"]);
348+
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
344349
addListenerToButton(menuButton, latestMetadata);
345350
}
346351
}

0 commit comments

Comments
 (0)