@@ -77,6 +77,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
7777 "updateStudy" : "qx.event.type.Data" ,
7878 "updateTemplate" : "qx.event.type.Data" ,
7979 "updateService" : "qx.event.type.Data" ,
80+ "updateHypertool" : "qx.event.type.Data" ,
8081 "publishTemplate" : "qx.event.type.Data" ,
8182 } ,
8283
@@ -387,6 +388,23 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
387388 this . fireEvent ( "pagesAdded" ) ;
388389 } ,
389390
391+ __fireUpdateEvent : function ( resourceData , updatedData ) {
392+ switch ( resourceData [ "resourceType" ] ) {
393+ case "study" :
394+ this . fireDataEvent ( "updateStudy" , updatedData ) ;
395+ break ;
396+ case "template" :
397+ this . fireDataEvent ( "updateTemplate" , updatedData ) ;
398+ break ;
399+ case "hypertool" :
400+ this . fireDataEvent ( "updateHypertool" , updatedData ) ;
401+ break ;
402+ case "service" :
403+ this . fireDataEvent ( "updateService" , updatedData ) ;
404+ break ;
405+ }
406+ } ,
407+
390408 __getInfoPage : function ( ) {
391409 const id = "Information" ;
392410 const title = this . tr ( "Overview" ) ;
@@ -402,19 +420,13 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
402420 infoCard = new osparc . info . ServiceLarge ( resourceData , null , false ) ;
403421 infoCard . addListener ( "updateService" , e => {
404422 const updatedData = e . getData ( ) ;
405- if ( osparc . utils . Resources . isService ( resourceData ) ) {
406- this . fireDataEvent ( "updateService" , updatedData ) ;
407- }
423+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
408424 } ) ;
409425 } else {
410426 infoCard = new osparc . info . StudyLarge ( resourceModel , false ) ;
411427 infoCard . addListener ( "updateStudy" , e => {
412428 const updatedData = e . getData ( ) ;
413- if ( osparc . utils . Resources . isStudy ( resourceData ) ) {
414- this . fireDataEvent ( "updateStudy" , updatedData ) ;
415- } else if ( osparc . utils . Resources . isTemplate ( resourceData ) ) {
416- this . fireDataEvent ( "updateTemplate" , updatedData ) ;
417- }
429+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
418430 } ) ;
419431 infoCard . addListener ( "openTags" , ( ) => this . openTags ( ) ) ;
420432 }
@@ -550,9 +562,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
550562 collaboratorsView = new osparc . share . CollaboratorsService ( resourceData ) ;
551563 collaboratorsView . addListener ( "updateAccessRights" , e => {
552564 const updatedData = e . getData ( ) ;
553- if ( osparc . utils . Resources . isService ( resourceData ) ) {
554- this . fireDataEvent ( "updateService" , updatedData ) ;
555- }
565+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
556566 } , this ) ;
557567 } else {
558568 collaboratorsView = new osparc . share . CollaboratorsStudy ( resourceData ) ;
@@ -563,11 +573,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
563573 }
564574 collaboratorsView . addListener ( "updateAccessRights" , e => {
565575 const updatedData = e . getData ( ) ;
566- if ( osparc . utils . Resources . isStudy ( resourceData ) ) {
567- this . fireDataEvent ( "updateStudy" , updatedData ) ;
568- } else if ( osparc . utils . Resources . isTemplate ( resourceData ) ) {
569- this . fireDataEvent ( "updateTemplate" , updatedData ) ;
570- }
576+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
571577 } , this ) ;
572578 }
573579 page . addToContent ( collaboratorsView ) ;
@@ -600,13 +606,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
600606 classifiers = new osparc . metadata . ClassifiersEditor ( resourceData ) ;
601607 classifiers . addListener ( "updateClassifiers" , e => {
602608 const updatedData = e . getData ( ) ;
603- if ( osparc . utils . Resources . isStudy ( resourceData ) ) {
604- this . fireDataEvent ( "updateStudy" , updatedData ) ;
605- } else if ( osparc . utils . Resources . isTemplate ( resourceData ) ) {
606- this . fireDataEvent ( "updateTemplate" , updatedData ) ;
607- } else if ( osparc . utils . Resources . isService ( resourceData ) ) {
608- this . fireDataEvent ( "updateService" , updatedData ) ;
609- }
609+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
610610 } , this ) ;
611611 } else {
612612 classifiers = new osparc . metadata . ClassifiersViewer ( resourceData ) ;
@@ -638,11 +638,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
638638 const qualityEditor = new osparc . metadata . QualityEditor ( resourceData ) ;
639639 qualityEditor . addListener ( "updateQuality" , e => {
640640 const updatedData = e . getData ( ) ;
641- if ( osparc . utils . Resources . isStudy ( resourceData ) ) {
642- this . fireDataEvent ( "updateStudy" , updatedData ) ;
643- } else if ( osparc . utils . Resources . isTemplate ( resourceData ) ) {
644- this . fireDataEvent ( "updateTemplate" , updatedData ) ;
645- }
641+ this . __fireUpdateEvent ( updatedData ) ;
646642 } ) ;
647643 page . addToContent ( qualityEditor ) ;
648644 }
@@ -673,11 +669,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
673669 tagManager . addListener ( "updateTags" , e => {
674670 const updatedData = e . getData ( ) ;
675671 tagManager . setStudyData ( updatedData ) ;
676- if ( osparc . utils . Resources . isStudy ( resourceData ) ) {
677- this . fireDataEvent ( "updateStudy" , updatedData ) ;
678- } else if ( osparc . utils . Resources . isTemplate ( resourceData ) ) {
679- this . fireDataEvent ( "updateTemplate" , updatedData ) ;
680- }
672+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
681673 } , this ) ;
682674 page . addToContent ( tagManager ) ;
683675 }
@@ -708,11 +700,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
708700 const servicesUpdate = new osparc . metadata . ServicesInStudyUpdate ( resourceData ) ;
709701 servicesUpdate . addListener ( "updateService" , e => {
710702 const updatedData = e . getData ( ) ;
711- if ( osparc . utils . Resources . isStudy ( resourceData ) ) {
712- this . fireDataEvent ( "updateStudy" , updatedData ) ;
713- } else if ( osparc . utils . Resources . isTemplate ( resourceData ) ) {
714- this . fireDataEvent ( "updateTemplate" , updatedData ) ;
715- }
703+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
716704 } ) ;
717705 page . addToContent ( servicesUpdate ) ;
718706 }
@@ -746,11 +734,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
746734 const servicesBootOpts = new osparc . metadata . ServicesInStudyBootOpts ( resourceData ) ;
747735 servicesBootOpts . addListener ( "updateService" , e => {
748736 const updatedData = e . getData ( ) ;
749- if ( osparc . utils . Resources . isStudy ( resourceData ) ) {
750- this . fireDataEvent ( "updateStudy" , updatedData ) ;
751- } else if ( osparc . utils . Resources . isTemplate ( resourceData ) ) {
752- this . fireDataEvent ( "updateTemplate" , updatedData ) ;
753- }
737+ this . __fireUpdateEvent ( resourceData , updatedData ) ;
754738 } ) ;
755739 page . addToContent ( servicesBootOpts ) ;
756740
0 commit comments