Skip to content

Commit 390afe1

Browse files
authored
🐛 Frontend Fix: Make sure SelectBox's selection is not null (#5785)
1 parent cd54920 commit 390afe1

File tree

12 files changed

+77
-54
lines changed

12 files changed

+77
-54
lines changed

services/static-webserver/client/source/class/osparc/cluster/ClustersDetails.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ qx.Class.define("osparc.cluster.ClustersDetails", {
5050
});
5151
osparc.cluster.Utils.populateClustersSelectBox(selectBox);
5252
selectBox.addListener("changeSelection", e => {
53-
const clusterId = e.getData()[0].id;
54-
this.__selectedClusterChanged(clusterId);
53+
const selection = e.getData();
54+
if (selection.length) {
55+
const clusterId = selection[0].id;
56+
this.__selectedClusterChanged(clusterId);
57+
}
5558
}, this);
5659
clustersLayout.add(selectBox);
5760

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
245245
});
246246

247247
// then listen to changes
248-
versionsBox.addListener("changeSelection", () => {
249-
const selection = versionsBox.getSelection();
250-
if (selection && selection.length) {
248+
versionsBox.addListener("changeSelection", e => {
249+
const selection = e.getData();
250+
if (selection.length) {
251251
const serviceVersion = selection[0].getLabel();
252252
if (serviceVersion !== this.__resourceData["version"]) {
253253
const serviceData = osparc.service.Utils.getFromObject(services, this.__resourceData["key"], serviceVersion);

services/static-webserver/client/source/class/osparc/desktop/credits/Usage.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ qx.Class.define("osparc.desktop.credits.Usage", {
8484
this._add(container);
8585

8686
walletSelectBox.addListener("changeSelection", e => {
87-
if (walletSelectBox.getSelection().length) {
88-
this.__selectedWallet = walletSelectBox.getSelection()[0].getModel()
87+
const selection = e.getData();
88+
if (selection.length) {
89+
this.__selectedWallet = selection[0].getModel()
8990
if (this.__table) {
9091
this.__table.getTableModel().setWalletId(this.__selectedWallet.getWalletId())
9192
this.__table.getTableModel().reloadData()

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
168168
},
169169

170170
__organizationSelected: function(data) {
171-
if (data && data.length>0) {
171+
if (data && data.length) {
172172
const org = data[0];
173173
this.fireDataEvent("organizationSelected", org.getModel());
174174
}

services/static-webserver/client/source/class/osparc/desktop/preferences/pages/ClustersPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ qx.Class.define("osparc.desktop.preferences.pages.ClustersPage", {
218218

219219
__clusterSelected: function(data) {
220220
this.__selectOrgMemberLayout.exclude();
221-
if (data && data.length>0) {
221+
if (data && data.length) {
222222
this.__currentCluster = data[0];
223223
} else {
224224
this.__currentCluster = null;

services/static-webserver/client/source/class/osparc/metadata/QualityEditor.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,14 @@ qx.Class.define("osparc.metadata.QualityEditor", {
354354
}
355355
});
356356
targetsBox.addListener("changeSelection", e => {
357-
const newMaxScore = e.getData()[0].level;
358-
copyTSRTarget[ruleKey].level = newMaxScore;
359-
copyTSRCurrent[ruleKey].level = Math.min(newMaxScore, copyTSRCurrent[ruleKey].level);
360-
updateCurrentLevel(copyTSRCurrent[ruleKey].level);
361-
updateTotalTSR();
357+
const selection = e.getData();
358+
if (selection.length) {
359+
const newMaxScore = selection[0].level;
360+
copyTSRTarget[ruleKey].level = newMaxScore;
361+
copyTSRCurrent[ruleKey].level = Math.min(newMaxScore, copyTSRCurrent[ruleKey].level);
362+
updateCurrentLevel(copyTSRCurrent[ruleKey].level);
363+
updateTotalTSR();
364+
}
362365
}, this);
363366
this.bind("mode", targetsBox, "visibility", {
364367
converter: mode => mode === "edit" ? "visible" : "excluded"

services/static-webserver/client/source/class/osparc/metadata/ServicesInStudyBootOpts.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ qx.Class.define("osparc.metadata.ServicesInStudyBootOpts", {
8585
if (canIWrite && hasBootModes) {
8686
const bootModeSB = osparc.data.model.Node.getBootModesSelectBox(nodeMetaData, workbench, nodeId);
8787
bootModeSB.addListener("changeSelection", e => {
88-
const newBootModeId = e.getData()[0].bootModeId;
89-
this.__updateBootMode(nodeId, newBootModeId);
88+
const selection = e.getData();
89+
if (selection.length) {
90+
const newBootModeId = e.getData()[0].bootModeId;
91+
this.__updateBootMode(nodeId, newBootModeId);
92+
}
9093
}, this);
9194
this._servicesGrid.add(bootModeSB, {
9295
row: i,

services/static-webserver/client/source/class/osparc/node/BootOptionsView.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,19 @@ qx.Class.define("osparc.node.BootOptionsView", {
5454
converter: interactive => interactive === "idle"
5555
});
5656
bootModeSB.addListener("changeSelection", e => {
57-
buttonsLayout.setEnabled(false);
58-
const newBootModeId = e.getData()[0].bootModeId;
59-
node.setBootOptions({
60-
"boot_mode": newBootModeId
61-
});
62-
setTimeout(() => {
63-
buttonsLayout.setEnabled(true);
64-
node.requestStartNode();
65-
this.fireEvent("bootModeChanged");
66-
}, osparc.desktop.StudyEditor.AUTO_SAVE_INTERVAL*2);
57+
const selection = e.getData();
58+
if (selection.length) {
59+
buttonsLayout.setEnabled(false);
60+
const newBootModeId = selection[0].bootModeId;
61+
node.setBootOptions({
62+
"boot_mode": newBootModeId
63+
});
64+
setTimeout(() => {
65+
buttonsLayout.setEnabled(true);
66+
node.requestStartNode();
67+
this.fireEvent("bootModeChanged");
68+
}, osparc.desktop.StudyEditor.AUTO_SAVE_INTERVAL*2);
69+
}
6770
}, this);
6871
buttonsLayout.add(bootModeSB);
6972

services/static-webserver/client/source/class/osparc/po/MessageTemplates.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ qx.Class.define("osparc.po.MessageTemplates", {
5555
});
5656

5757
templatesSB.addListener("changeSelection", e => {
58-
const templateId = e.getData()[0].getModel();
59-
this.__populateMessage(templateId);
58+
const selection = e.getData();
59+
if (selection.length) {
60+
const templateId = selection[0].getModel();
61+
this.__populateMessage(templateId);
62+
}
6063
}, this);
6164
this.__messageTemplates.forEach(template => {
6265
const lItem = new qx.ui.form.ListItem(template.id, null, template.id);

services/static-webserver/client/source/class/osparc/pricing/Plans.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ qx.Class.define("osparc.pricing.Plans", {
5858
spacing: 3
5959
});
6060
control.addListener("changeSelection", e => {
61-
const ppSelected = e.getData()[0];
62-
this.fireDataEvent("pricingPlanSelected", ppSelected);
61+
const selection = e.getData();
62+
if (selection.length) {
63+
const ppSelected = selection[0];
64+
this.fireDataEvent("pricingPlanSelected", ppSelected);
65+
}
6366
}, this);
6467
this.getChildControl("pricing-plans-container").add(control);
6568
break;

0 commit comments

Comments
 (0)