@@ -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