@@ -55,7 +55,7 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
5555 const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
5656 if ( anatomicalModelsData && anatomicalModelsData [ "licensedResources" ] . length ) {
5757 this . __addModelsInfo ( ) ;
58- this . __addPricingUnits ( ) ;
58+ this . __addPricing ( ) ;
5959 this . __addSeatsSection ( ) ;
6060 } else {
6161 const selectModelLabel = new qx . ui . basic . Label ( ) . set ( {
@@ -108,7 +108,8 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
108108 const topGrid = new qx . ui . layout . Grid ( 8 , 8 ) ;
109109 topGrid . setColumnFlex ( 0 , 1 ) ;
110110 const topLayout = new qx . ui . container . Composite ( topGrid ) ;
111- const description = anatomicalModel [ "description" ] || "" ;
111+ let description = anatomicalModel [ "description" ] || "" ;
112+ description = description . replace ( / S P E A G / g, " " ) ; // remove SPEAG substring
112113 const delimiter = " - " ;
113114 let titleAndSubtitle = description . split ( delimiter ) ;
114115 if ( titleAndSubtitle . length > 0 ) {
@@ -289,19 +290,28 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
289290 modelId : anatomicalModelsData [ "licensedResources" ] [ selectedIdx ] [ "source" ] [ "id" ]
290291 } ) ;
291292 } , this ) ;
292- if ( anatomicalModelsData [ "purchases " ] . length ) {
293+ if ( anatomicalModelsData [ "seats " ] . length ) {
293294 importSection . add ( importButton ) ;
294295 }
295296 return importSection ;
296297 } ,
297298
298- __addPricingUnits : function ( ) {
299- const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
299+ __addPricing : function ( ) {
300+ const layout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( ) . set ( {
301+ alignX : "center"
302+ } ) )
303+
304+ const pricingLayout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( ) ) . set ( {
305+ allowGrowX : false ,
306+ decorator : "border" ,
307+ } ) ;
308+ layout . add ( pricingLayout )
309+
300310 const pricingUnitsLayout = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 10 ) . set ( {
301311 alignX : "center"
302312 } ) ) ;
303-
304- osparc . store . Pricing . getInstance ( ) . fetchPricingUnits ( anatomicalModelsData [ "pricingPlanId" ] )
313+ const licensedItemData = this . getAnatomicalModelsData ( ) ;
314+ osparc . store . Pricing . getInstance ( ) . fetchPricingUnits ( licensedItemData [ "pricingPlanId" ] )
305315 . then ( pricingUnits => {
306316 pricingUnits . forEach ( pricingUnit => {
307317 pricingUnit . set ( {
@@ -312,35 +322,118 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
312322 } ) ;
313323 pUnit . addListener ( "rentPricingUnit" , ( ) => {
314324 this . fireDataEvent ( "modelPurchaseRequested" , {
315- licensedItemId : anatomicalModelsData [ "licensedItemId" ] ,
316- pricingPlanId : anatomicalModelsData [ "pricingPlanId" ] ,
325+ licensedItemId : licensedItemData [ "licensedItemId" ] ,
326+ pricingPlanId : licensedItemData [ "pricingPlanId" ] ,
317327 pricingUnitId : pricingUnit . getPricingUnitId ( ) ,
318328 } ) ;
319329 } , this ) ;
320330 pricingUnitsLayout . add ( pUnit ) ;
321331 } ) ;
322332 } )
323333 . catch ( err => console . error ( err ) ) ;
324-
325334 this . _add ( pricingUnitsLayout ) ;
335+ pricingLayout . add ( pricingUnitsLayout )
336+
337+ const poweredByLabel = new qx . ui . basic . Label ( ) . set ( {
338+ font : "text-14" ,
339+ padding : 10 ,
340+ rich : true ,
341+ alignX : "center" ,
342+ } ) ;
343+ osparc . store . LicensedItems . getInstance ( ) . getLicensedItems ( )
344+ . then ( licensedItems => {
345+ const lowerLicensedItems = osparc . store . LicensedItems . getLowerLicensedItems ( licensedItems , licensedItemData [ "key" ] , licensedItemData [ "version" ] )
346+ if ( licensedItemData [ "licensedResources" ] . length > 1 || lowerLicensedItems . length ) {
347+ let text = this . tr ( "This Bundle gives you access to:" ) + "<br>" ;
348+ licensedItemData [ "licensedResources" ] . forEach ( licensedResource => {
349+ text += `- ${ osparc . store . LicensedItems . licensedResourceNameAndVersion ( licensedResource ) } <br>` ;
350+ } ) ;
351+ lowerLicensedItems . forEach ( lowerLicensedItem => {
352+ lowerLicensedItem [ "licensedResources" ] . forEach ( licensedResource => {
353+ text += `- ${ osparc . store . LicensedItems . licensedResourceNameAndVersion ( licensedResource ) } <br>` ;
354+ } ) ;
355+ } )
356+ poweredByLabel . setValue ( text ) ;
357+ pricingLayout . add ( poweredByLabel ) ;
358+ }
359+ } ) ;
360+
361+ this . _add ( layout ) ;
326362 } ,
327363
328364 __addSeatsSection : function ( ) {
329- const anatomicalModelsData = this . getAnatomicalModelsData ( ) ;
330- const seatsSection = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 5 ) . set ( {
365+ const licensedItemData = this . getAnatomicalModelsData ( ) ;
366+ if ( licensedItemData [ "seats" ] . length === 0 ) {
367+ return ;
368+ }
369+
370+ const layout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( ) . set ( {
331371 alignX : "center" ,
332372 } ) ) ;
333373
334- anatomicalModelsData [ "purchases" ] . forEach ( purchase => {
335- const seatsText = "seat" + ( purchase [ "numberOfSeats" ] > 1 ? "s" : "" ) ;
336- const entry = new qx . ui . basic . Label ( ) . set ( {
337- value : `${ purchase [ "numberOfSeats" ] } ${ seatsText } available until ${ osparc . utils . Utils . formatDate ( purchase [ "expiresAt" ] ) } ` ,
338- font : "text-14" ,
339- } ) ;
340- seatsSection . add ( entry ) ;
341- } ) ;
374+ osparc . store . LicensedItems . getInstance ( ) . getLicensedItems ( )
375+ . then ( licensedItems => {
376+ const grid = new qx . ui . layout . Grid ( 15 , 5 ) ;
377+ grid . setColumnAlign ( 0 , "left" , "middle" ) ;
378+ grid . setColumnAlign ( 1 , "center" , "middle" ) ;
379+ grid . setColumnAlign ( 2 , "right" , "middle" ) ;
380+ const seatsSection = new qx . ui . container . Composite ( grid ) . set ( {
381+ allowGrowX : false ,
382+ decorator : "border" ,
383+ padding : 10 ,
384+ } ) ;
385+
386+ let rowIdx = 0 ;
387+ seatsSection . add ( new qx . ui . basic . Label ( "Models Rented" ) . set ( { font : "title-14" } ) , {
388+ column : 0 ,
389+ row : rowIdx ,
390+ } ) ;
391+ seatsSection . add ( new qx . ui . basic . Label ( "Seats" ) . set ( { font : "title-14" } ) , {
392+ column : 1 ,
393+ row : rowIdx ,
394+ } ) ;
395+ seatsSection . add ( new qx . ui . basic . Label ( "Until" ) . set ( { font : "title-14" } ) , {
396+ column : 2 ,
397+ row : rowIdx ,
398+ } ) ;
399+ rowIdx ++ ;
400+
401+ const entryToGrid = ( licensedResource , seat , row ) => {
402+ const title = osparc . store . LicensedItems . licensedResourceNameAndVersion ( licensedResource ) ;
403+ seatsSection . add ( new qx . ui . basic . Label ( title ) . set ( { font : "text-14" } ) , {
404+ column : 0 ,
405+ row,
406+ } ) ;
407+ seatsSection . add ( new qx . ui . basic . Label ( seat [ "numOfSeats" ] . toString ( ) ) . set ( { font : "text-14" } ) , {
408+ column : 1 ,
409+ row,
410+ } ) ;
411+ seatsSection . add ( new qx . ui . basic . Label ( osparc . utils . Utils . formatDate ( seat [ "expireAt" ] ) ) . set ( { font : "text-14" } ) , {
412+ column : 2 ,
413+ row,
414+ } ) ;
415+ } ;
416+
417+ licensedItemData [ "seats" ] . forEach ( seat => {
418+ licensedItemData [ "licensedResources" ] . forEach ( licensedResource => {
419+ entryToGrid ( licensedResource , seat , rowIdx ) ;
420+ rowIdx ++ ;
421+ } ) ;
422+ } ) ;
342423
343- this . _add ( seatsSection ) ;
424+ const lowerLicensedItems = osparc . store . LicensedItems . getLowerLicensedItems ( licensedItems , licensedItemData [ "key" ] , licensedItemData [ "version" ] )
425+ lowerLicensedItems . forEach ( lowerLicensedItem => {
426+ lowerLicensedItem [ "seats" ] . forEach ( seat => {
427+ lowerLicensedItem [ "licensedResources" ] . forEach ( licensedResource => {
428+ entryToGrid ( licensedResource , seat , rowIdx ) ;
429+ rowIdx ++ ;
430+ } ) ;
431+ } ) ;
432+ } ) ;
433+
434+ layout . add ( seatsSection ) ;
435+ this . _add ( layout ) ;
436+ } ) ;
344437 } ,
345438 }
346439} ) ;
0 commit comments