Skip to content

Commit 94dc2fd

Browse files
committed
complete patches
1 parent 1855219 commit 94dc2fd

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
179179
promises.push(osparc.study.StudyOptions.updateWallet(studyData["uuid"], walletId));
180180
}
181181
nodesPricingUnits.forEach(nodePricingUnits => {
182-
console.log("nodePricingUnits", nodePricingUnits);
183-
// osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, )
182+
const nodeId = nodePricingUnits.getNodeId();
183+
const pricingPlanId = nodePricingUnits.getPricingPlanId();
184+
const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId();
185+
promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId));
184186
})
185187

186188
Promise.all(promises)

services/static-webserver/client/source/class/osparc/study/NodePricingUnits.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ qx.Class.define("osparc.study.NodePricingUnits", {
5757
init: null,
5858
nullable: false,
5959
},
60+
61+
pricingPlanId: {
62+
check: "String",
63+
init: null,
64+
nullable: false,
65+
},
6066
},
6167

6268
statics: {
@@ -77,6 +83,7 @@ qx.Class.define("osparc.study.NodePricingUnits", {
7783
__nodeKey: null,
7884
__nodeVersion: null,
7985
__nodeLabel: null,
86+
__pricingUnits: null,
8087

8188
showPricingUnits: function(inGroupBox = true) {
8289
return new Promise(resolve => {
@@ -93,37 +100,45 @@ qx.Class.define("osparc.study.NodePricingUnits", {
93100
)
94101
};
95102
osparc.data.Resources.fetch("services", "pricingPlans", plansParams)
96-
.then(pricingPlans => {
97-
if (pricingPlans) {
103+
.then(pricingPlan => {
104+
if (pricingPlan) {
98105
const unitParams = {
99106
url: {
100107
studyId,
101108
nodeId
102109
}
103110
};
111+
this.set({
112+
pricingPlanId: pricingPlan["pricingPlanId"]
113+
});
104114
osparc.data.Resources.fetch("studies", "getPricingUnit", unitParams)
105115
.then(preselectedPricingUnit => {
106-
if (pricingPlans && "pricingUnits" in pricingPlans && pricingPlans["pricingUnits"].length) {
107-
const unitButtons = new osparc.study.PricingUnits(pricingPlans["pricingUnits"], preselectedPricingUnit);
116+
if (pricingPlan && "pricingUnits" in pricingPlan && pricingPlan["pricingUnits"].length) {
117+
const pricingUnitButtons = this.__pricingUnits = new osparc.study.PricingUnits(pricingPlan["pricingUnits"], preselectedPricingUnit);
108118
if (inGroupBox) {
109119
const pricingUnitsLayout = osparc.study.StudyOptions.createGroupBox(nodeLabel);
110-
pricingUnitsLayout.add(unitButtons);
120+
pricingUnitsLayout.add(pricingUnitButtons);
111121
this._add(pricingUnitsLayout);
112122
} else {
113-
this._add(unitButtons);
123+
this._add(pricingUnitButtons);
114124
}
115-
unitButtons.addListener("changeSelectedUnitId", e => {
116-
unitButtons.setEnabled(false);
125+
pricingUnitButtons.addListener("changeSelectedUnitId", e => {
126+
pricingUnitButtons.setEnabled(false);
127+
const pricingPlanId = this.getPricingPlanId();
117128
const selectedPricingUnitId = e.getData();
118-
this.self().patchPricingUnitSelection(studyId, nodeId, pricingPlans["pricingPlanId"], selectedPricingUnitId)
119-
.finally(() => unitButtons.setEnabled(true));
129+
this.self().patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId)
130+
.finally(() => pricingUnitButtons.setEnabled(true));
120131
});
121132
}
122133
})
123134
.finally(() => resolve());
124135
}
125136
});
126137
});
127-
}
138+
},
139+
140+
getPricingUnits: function() {
141+
return this.__pricingUnits;
142+
},
128143
}
129144
});

0 commit comments

Comments
 (0)