@@ -54,11 +54,8 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
5454
5555 const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
5656 if ( anatomicalModelsData && anatomicalModelsData [ "licensedResources" ] . length ) {
57- this . __addModelsInfo ( anatomicalModelsData [ "licensedResources" ] ) ;
58- const importButton = this . __createImportSection ( anatomicalModelsData ) ;
59- this . _add ( importButton ) ;
60- const pricingUnits = this . __createPricingUnits ( anatomicalModelsData ) ;
61- this . _add ( pricingUnits ) ;
57+ this . __addModelsInfo ( anatomicalModelsData ) ;
58+ this . __addPricingUnits ( anatomicalModelsData ) ;
6259 } else {
6360 const selectModelLabel = new qx . ui . basic . Label ( ) . set ( {
6461 value : this . tr ( "Select a model for more details" ) ,
@@ -72,9 +69,10 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
7269 }
7370 } ,
7471
75- __addModelsInfo : function ( modelsInfo ) {
72+ __addModelsInfo : function ( anatomicalModelsData ) {
7673 const modelLayout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 16 ) ) ;
7774
75+ const modelsInfo = anatomicalModelsData [ "licensedResources" ] ;
7876 if ( modelsInfo . length > 1 ) {
7977 const sBox = new qx . ui . form . SelectBox ( ) . set ( {
8078 minWidth : 200 ,
@@ -89,21 +87,22 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
8987 sBox . addListener ( "changeSelection" , e => {
9088 const selection = e . getData ( ) ;
9189 if ( selection . length ) {
92- const modelFound = modelsInfo . find ( mdlInfo => mdlInfo [ "source" ] [ "id" ] === selection [ 0 ] . modelId )
93- this . __populateModelInfo ( modelLayout , modelFound [ "source" ] ) ;
90+ const idxFound = modelsInfo . findIndex ( mdlInfo => mdlInfo [ "source" ] [ "id" ] === selection [ 0 ] . modelId )
91+ this . __populateModelInfo ( modelLayout , anatomicalModelsData , idxFound ) ;
9492 }
9593 } , this ) ;
96- this . __populateModelInfo ( modelLayout , modelsInfo [ 0 ] [ "source" ] ) ;
94+ this . __populateModelInfo ( modelLayout , anatomicalModelsData , 0 ) ;
9795 } else {
98- this . __populateModelInfo ( modelLayout , modelsInfo [ 0 ] [ "source" ] ) ;
96+ this . __populateModelInfo ( modelLayout , anatomicalModelsData , 0 ) ;
9997 }
10098
10199 this . _add ( modelLayout ) ;
102100 } ,
103101
104- __populateModelInfo : function ( modelLayout , anatomicalModel ) {
102+ __populateModelInfo : function ( modelLayout , anatomicalModelsData , idxFound = 0 ) {
105103 modelLayout . removeAll ( ) ;
106104
105+ const anatomicalModel = anatomicalModelsData [ "licensedResources" ] [ idxFound ] [ "source" ] ;
107106 const topGrid = new qx . ui . layout . Grid ( 8 , 8 ) ;
108107 topGrid . setColumnFlex ( 0 , 1 ) ;
109108 const topLayout = new qx . ui . container . Composite ( topGrid ) ;
@@ -260,10 +259,13 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
260259
261260 middleLayout . add ( featuresLayout ) ;
262261
262+ const importButton = this . __createImportSection ( anatomicalModelsData ) ;
263+ modelLayout . add ( importButton ) ;
264+
263265 modelLayout . add ( middleLayout ) ;
264266 } ,
265267
266- __createPricingUnits : function ( anatomicalModelsData ) {
268+ __addPricingUnits : function ( anatomicalModelsData ) {
267269 const pricingUnitsLayout = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) . set ( {
268270 alignX : "center"
269271 } ) ) ;
@@ -290,7 +292,7 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
290292 } )
291293 . catch ( err => console . error ( err ) ) ;
292294
293- return pricingUnitsLayout ;
295+ this . _add ( pricingUnitsLayout ) ;
294296 } ,
295297
296298 __createImportSection : function ( anatomicalModelsData ) {
0 commit comments