@@ -33,30 +33,49 @@ qx.Class.define("osparc.study.BillingSettings", {
3333
3434 members : {
3535 __studyData : null ,
36+ __walletDebtButton : null ,
3637
3738 _createChildControlImpl : function ( id ) {
3839 let control ;
3940 switch ( id ) {
40- case "credit-account-layout " :
41+ case "credit-account-box " :
4142 control = osparc . study . StudyOptions . createGroupBox ( this . tr ( "Credit Account" ) ) ;
4243 this . _add ( control ) ;
44+ break ;
45+ case "credit-account-layout" :
46+ control = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) ) . set ( {
47+ alignY : "middle"
48+ } ) ;
49+ this . getChildControl ( "credit-account-box" ) . add ( control ) ;
50+ break ;
4351 }
4452 return control || this . base ( arguments , id ) ;
4553 } ,
4654
4755 __buildLayout : function ( ) {
56+ if ( osparc . study . Utils . isInDebt ( this . __studyData ) ) {
57+ this . __buildDebtMessage ( ) ;
58+ }
4859 this . __buildWalletGroup ( ) ;
4960 this . __buildPricingUnitsGroup ( ) ;
5061 } ,
5162
52- __buildWalletGroup : function ( ) {
53- const creditAccountLayout = this . getChildControl ( "credit-account-layout" ) ;
54- creditAccountLayout . removeAll ( ) ;
55-
56- const boxContent = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) ) . set ( {
57- alignY : "middle"
63+ __buildDebtMessage : function ( ) {
64+ const studyAlias = osparc . product . Utils . getStudyAlias ( ) ;
65+ let msg = this . tr ( `This ${ studyAlias } is currently Embargoed.` ) + "<br>" ;
66+ msg += this . tr ( "Credits required to unblock it:" ) + "<br>" ;
67+ msg += - 1 * this . __studyData [ "debt" ] ;
68+ const label = new qx . ui . basic . Label ( msg ) . set ( {
69+ font : "text-14" ,
70+ rich : true ,
71+ paddingBottom : 20 ,
5872 } ) ;
59- creditAccountLayout . add ( boxContent ) ;
73+ this . _add ( label ) ;
74+ } ,
75+
76+ __buildWalletGroup : function ( ) {
77+ const boxContent = this . getChildControl ( "credit-account-layout" ) ;
78+ boxContent . removeAll ( ) ;
6079
6180 const walletSelector = osparc . desktop . credits . Utils . createWalletSelector ( "read" ) ;
6281 boxContent . add ( walletSelector ) ;
@@ -72,6 +91,9 @@ qx.Class.define("osparc.study.BillingSettings", {
7291 const walletFound = walletSelector . getSelectables ( ) . find ( selectables => selectables . walletId === wallet [ "walletId" ] ) ;
7392 if ( walletFound ) {
7493 walletSelector . setSelection ( [ walletFound ] ) ;
94+ if ( osparc . study . Utils . isInDebt ( this . __studyData ) ) {
95+ this . __addPayDebtButton ( wallet [ "walletId" ] ) ;
96+ }
7597 } else {
7698 const emptyItem = new qx . ui . form . ListItem ( "" ) ;
7799 emptyItem . walletId = null ;
@@ -90,12 +112,30 @@ qx.Class.define("osparc.study.BillingSettings", {
90112 if ( walletId === null ) {
91113 return ;
92114 }
93- this . __switchWallet ( walletId ) ;
115+ if ( osparc . study . Utils . isInDebt ( this . __studyData ) ) {
116+ this . __addPayDebtButton ( walletId ) ;
117+ } else {
118+ this . __switchWallet ( walletId ) ;
119+ }
94120 }
95121 } ) ;
96122 } ) ;
97123 } ,
98124
125+ __addPayDebtButton : function ( walletId ) {
126+ const boxContent = this . getChildControl ( "credit-account-layout" ) ;
127+ if ( this . __walletDebtButton ) {
128+ boxContent . remove ( this . __walletDebtButton ) ;
129+ }
130+ const wallet = osparc . desktop . credits . Utils . getWallet ( walletId ) ;
131+ if ( wallet . getCreditsAvailable ( ) > - 1 * this . __studyData [ "debt" ] ) {
132+ this . __walletDebtButton = new qx . ui . form . Button ( this . tr ( "Pay with this Credit Account" ) ) ;
133+ } else {
134+ this . __walletDebtButton = new qx . ui . form . Button ( this . tr ( "Buy Credits" ) ) ;
135+ }
136+ boxContent . add ( this . __walletDebtButton ) ;
137+ } ,
138+
99139 __switchWallet : function ( walletId ) {
100140 const creditAccountLayout = this . getChildControl ( "credit-account-layout" ) ;
101141 creditAccountLayout . setEnabled ( false ) ;
0 commit comments