@@ -54,9 +54,9 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
5454
5555 const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
5656 if ( anatomicalModelsData && anatomicalModelsData [ "licensedResources" ] . length ) {
57- this . __addModelsInfo ( anatomicalModelsData ) ;
58- this . __addPricingUnits ( anatomicalModelsData ) ;
59- this . __addSeatsSection ( anatomicalModelsData ) ;
57+ this . __addModelsInfo ( ) ;
58+ this . __addPricingUnits ( ) ;
59+ this . __addSeatsSection ( ) ;
6060 } else {
6161 const selectModelLabel = new qx . ui . basic . Label ( ) . set ( {
6262 value : this . tr ( "Select a model for more details" ) ,
@@ -70,9 +70,10 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
7070 }
7171 } ,
7272
73- __addModelsInfo : function ( anatomicalModelsData ) {
73+ __addModelsInfo : function ( ) {
7474 const modelLayout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 16 ) ) ;
7575
76+ const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
7677 const modelsInfo = anatomicalModelsData [ "licensedResources" ] ;
7778 if ( modelsInfo . length > 1 ) {
7879 const sBox = new qx . ui . form . SelectBox ( ) . set ( {
@@ -100,10 +101,10 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
100101 this . _add ( modelLayout ) ;
101102 } ,
102103
103- __populateModelInfo : function ( modelLayout , anatomicalModelsData , idxFound = 0 ) {
104+ __populateModelInfo : function ( modelLayout , anatomicalModelsData , selectedIdx = 0 ) {
104105 modelLayout . removeAll ( ) ;
105106
106- const anatomicalModel = anatomicalModelsData [ "licensedResources" ] [ idxFound ] [ "source" ] ;
107+ const anatomicalModel = anatomicalModelsData [ "licensedResources" ] [ selectedIdx ] [ "source" ] ;
107108 const topGrid = new qx . ui . layout . Grid ( 8 , 8 ) ;
108109 topGrid . setColumnFlex ( 0 , 1 ) ;
109110 const topLayout = new qx . ui . container . Composite ( topGrid ) ;
@@ -264,11 +265,38 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
264265
265266 modelLayout . add ( middleLayout ) ;
266267
267- const importButton = this . __createImportSection ( anatomicalModelsData ) ;
268+ const importButton = this . __createImportSection ( anatomicalModelsData , selectedIdx ) ;
268269 modelLayout . add ( importButton ) ;
269270 } ,
270271
271- __addPricingUnits : function ( anatomicalModelsData ) {
272+ __createImportSection : function ( anatomicalModelsData , selectedIdx ) {
273+ const importSection = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 5 ) . set ( {
274+ alignX : "center"
275+ } ) ) ;
276+
277+ const importButton = new qx . ui . form . Button ( ) . set ( {
278+ label : this . tr ( "Import" ) ,
279+ appearance : "strong-button" ,
280+ center : true ,
281+ maxWidth : 200 ,
282+ alignX : "center" ,
283+ } ) ;
284+ this . bind ( "openBy" , importButton , "visibility" , {
285+ converter : openBy => openBy ? "visible" : "excluded"
286+ } ) ;
287+ importButton . addListener ( "execute" , ( ) => {
288+ this . fireDataEvent ( "modelImportRequested" , {
289+ modelId : anatomicalModelsData [ "licensedResources" ] [ selectedIdx ] [ "source" ] [ "id" ]
290+ } ) ;
291+ } , this ) ;
292+ if ( anatomicalModelsData [ "purchases" ] . length ) {
293+ importSection . add ( importButton ) ;
294+ }
295+ return importSection ;
296+ } ,
297+
298+ __addPricingUnits : function ( ) {
299+ const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
272300 const pricingUnitsLayout = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) . set ( {
273301 alignX : "center"
274302 } ) ) ;
@@ -297,33 +325,8 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
297325 this . _add ( pricingUnitsLayout ) ;
298326 } ,
299327
300- __createImportSection : function ( anatomicalModelsData ) {
301- const importSection = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 5 ) . set ( {
302- alignX : "center"
303- } ) ) ;
304-
305- const importButton = new qx . ui . form . Button ( ) . set ( {
306- label : this . tr ( "Import" ) ,
307- appearance : "strong-button" ,
308- center : true ,
309- maxWidth : 200 ,
310- alignX : "center" ,
311- } ) ;
312- this . bind ( "openBy" , importButton , "visibility" , {
313- converter : openBy => openBy ? "visible" : "excluded"
314- } ) ;
315- importButton . addListener ( "execute" , ( ) => {
316- this . fireDataEvent ( "modelImportRequested" , {
317- modelId : anatomicalModelsData [ "licensedResourceData" ] [ "source" ] [ "id" ]
318- } ) ;
319- } , this ) ;
320- if ( anatomicalModelsData [ "purchases" ] . length ) {
321- importSection . add ( importButton ) ;
322- }
323- return importSection ;
324- } ,
325-
326- __addSeatsSection : function ( anatomicalModelsData ) {
328+ __addSeatsSection : function ( ) {
329+ const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
327330 const seatsSection = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 5 ) . set ( {
328331 alignX : "center" ,
329332 } ) ) ;
0 commit comments