@@ -66,6 +66,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
6666 const studyStore = osparc . store . Study . getInstance ( ) ;
6767 this . __resourceData [ "debt" ] = studyStore . getStudyDebt ( this . __resourceData [ "uuid" ] ) ;
6868 }
69+ // prefetch project's services metadata
6970 osparc . store . Services . getStudyServicesMetadata ( latestResourceData )
7071 . finally ( ( ) => {
7172 this . __resourceModel = new osparc . data . model . Study ( latestResourceData ) ;
@@ -75,16 +76,25 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
7576 } ) ;
7677 break ;
7778 case "function" : {
78- osparc . store . Templates . fetchTemplate ( resourceData [ "templateId" ] )
79- . then ( templateData => {
80- osparc . store . Services . getStudyServicesMetadata ( templateData )
81- . finally ( ( ) => {
82- this . __resourceModel = new osparc . data . model . Function ( latestResourceData , templateData ) ;
83- this . __resourceModel [ "resourceType" ] = resourceData [ "resourceType" ] ;
84- this . __resourceData [ "services" ] = resourceData [ "services" ] ;
85- this . __addPages ( ) ;
86- } ) ;
87- } ) ;
79+ addPages = ( ) => {
80+ this . __resourceModel = new osparc . data . model . Function ( latestResourceData , templateData ) ;
81+ this . __resourceModel [ "resourceType" ] = resourceData [ "resourceType" ] ;
82+ this . __addPages ( ) ;
83+ }
84+ if ( resourceData [ "functionClass" ] === "PROJECT" ) {
85+ // this is only required for functions that have a template linked
86+ osparc . store . Templates . fetchTemplate ( resourceData [ "templateId" ] )
87+ . then ( templateData => {
88+ // prefetch function's underlying template's services metadata
89+ osparc . store . Services . getStudyServicesMetadata ( templateData )
90+ . finally ( ( ) => {
91+ this . __resourceData [ "services" ] = resourceData [ "services" ] ;
92+ addPages ( ) ;
93+ } ) ;
94+ } ) ;
95+ } else {
96+ addPages ( ) ;
97+ }
8898 break ;
8999 }
90100 case "service" : {
@@ -174,7 +184,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
174184 __addToolbarButtons : function ( page ) {
175185 const resourceData = this . __resourceData ;
176186
177- if ( this . __resourceData [ "resourceType" ] === "function" ) {
187+ if ( osparc . utils . Resources . isFunction ( this . __resourceData ) ) {
178188 return ; // no toolbar buttons for functions
179189 }
180190
@@ -396,10 +406,11 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
396406 this . __addPreviewPage ( ) ;
397407 this . fireEvent ( "pagesAdded" ) ;
398408 return ;
399- } else if ( this . __resourceData [ "resourceType" ] === "function" ) {
409+ } else if ( osparc . utils . Resources . isFunction ( this . __resourceData ) ) {
400410 this . __addInfoPage ( ) ;
401- // to build the preview page we need the underlying template data
402- this . __addPreviewPage ( ) ;
411+ if ( this . __resourceModel . getFunctionClass ( ) === "PROJECT" ) {
412+ this . __addPreviewPage ( ) ;
413+ }
403414 this . fireEvent ( "pagesAdded" ) ;
404415 return ;
405416 }
0 commit comments