@@ -45,8 +45,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
4545 check : [ "display" , "edit" ] ,
4646 init : "display" ,
4747 nullable : false ,
48- event : "changeMode" ,
49- apply : "__populateForms"
48+ event : "changeMode"
5049 }
5150 } ,
5251
@@ -165,12 +164,6 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
165164 }
166165 } ,
167166
168- __populateForms : function ( ) {
169- this . __populateEnable ( ) ;
170- this . __populateTSR ( ) ;
171- this . __populateAnnotations ( ) ;
172- } ,
173-
174167 __createEnableSection : function ( ) {
175168 const enabledQuality = this . __enabledQuality = new qx . ui . form . CheckBox ( this . tr ( "Enabled" ) ) ;
176169 this . bind ( "mode" , enabledQuality , "enabled" , {
@@ -225,6 +218,12 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
225218 this . _add ( box ) ;
226219 } ,
227220
221+ __populateForms : function ( ) {
222+ this . __populateEnable ( ) ;
223+ this . __populateTSR ( ) ;
224+ this . __populateAnnotations ( ) ;
225+ } ,
226+
228227 __populateEnable : function ( ) {
229228 this . __enabledQuality . setValue ( this . __copyResourceData [ "quality" ] [ "enabled" ] ) ;
230229 this . __enabledQuality . addListener ( "changeValue" , e => {
@@ -309,61 +308,6 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
309308 } ,
310309
311310 __populateTSRData : function ( ) {
312- switch ( this . getMode ( ) ) {
313- case "edit" :
314- this . __populateTSRDataEdit ( ) ;
315- break ;
316- default :
317- this . __populateTSRDataView ( ) ;
318- break ;
319- }
320- } ,
321-
322- __populateTSRDataView : function ( ) {
323- const currentTSR = this . __copyResourceData [ "quality" ] [ "tsr_current" ] ;
324- const targetTSR = this . __copyResourceData [ "quality" ] [ "tsr_target" ] ;
325- let row = 1 ;
326- Object . entries ( currentTSR ) . forEach ( ( [ tsrKey , cTSR ] ) => {
327- const ruleRating = new osparc . ui . basic . StarsRating ( ) ;
328- ruleRating . set ( {
329- score : cTSR . level ,
330- maxScore : targetTSR [ tsrKey ] . level ,
331- nStars : targetTSR [ tsrKey ] . level ,
332- showEmptyStars : true ,
333- marginTop : 5
334- } ) ;
335- const confLevel = osparc . component . metadata . Quality . findConformanceLevel ( cTSR . level ) ;
336- const hint = confLevel . title + "<br>" + confLevel . description ;
337- const ruleRatingWHint = new osparc . component . form . FieldWHint ( null , hint , ruleRating ) . set ( {
338- hintPosition : "left"
339- } ) ;
340- this . __tsrGrid . add ( ruleRatingWHint , {
341- row,
342- column : this . __tsrGridPos . clCurrent
343- } ) ;
344-
345- const referenceMD = new osparc . ui . markdown . Markdown ( cTSR . references ) ;
346- this . __tsrGrid . add ( referenceMD , {
347- row,
348- column : this . __tsrGridPos . reference
349- } ) ;
350-
351- row ++ ;
352- } ) ;
353-
354- const tsrRating = new osparc . ui . basic . StarsRating ( ) . set ( {
355- nStars : 4 ,
356- showScore : true ,
357- marginTop : 5
358- } ) ;
359- osparc . ui . basic . StarsRating . scoreToStarsRating ( currentTSR , targetTSR , tsrRating ) ;
360- this . __tsrGrid . add ( tsrRating , {
361- row,
362- column : this . __tsrGridPos . clCurrent
363- } ) ;
364- } ,
365-
366- __populateTSRDataEdit : function ( ) {
367311 const copyTSRCurrent = this . __copyResourceData [ "quality" ] [ "tsr_current" ] ;
368312 const copyTSRTarget = this . __copyResourceData [ "quality" ] [ "tsr_target" ] ;
369313 const tsrTotalRating = new osparc . ui . basic . StarsRating ( ) ;
@@ -391,9 +335,9 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
391335 maxScore : copyTSRTarget [ ruleKey ] . level ,
392336 nStars : copyTSRTarget [ ruleKey ] . level ,
393337 score : value ,
394- marginTop : 5 ,
395- mode : "edit"
338+ marginTop : 5
396339 } ) ;
340+ this . bind ( "mode" , ruleRating , "mode" ) ;
397341 ruleRating . addListener ( "changeScore" , e => {
398342 const newScore = e . getData ( ) ;
399343 copyTSRCurrent [ ruleKey ] . level = newScore ;
@@ -437,6 +381,9 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
437381 updateCurrentLevel ( copyTSRCurrent [ ruleKey ] . level ) ;
438382 updateTotalTSR ( ) ;
439383 } , this ) ;
384+ this . bind ( "mode" , targetsBox , "visibility" , {
385+ converter : mode => mode === "edit" ? "visible" : "excluded"
386+ } ) ;
440387 this . __tsrGrid . add ( targetsBox , {
441388 row,
442389 column : this . __tsrGridPos . clTarget
@@ -453,6 +400,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
453400 const title = this . tr ( "Edit References" ) ;
454401 const subtitle = this . tr ( "Supports Markdown" ) ;
455402 const textEditor = new osparc . component . widget . TextEditor ( currentRule . references , subtitle , title ) ;
403+ textEditor . getChildControl ( "accept-button" ) . setLabel ( this . tr ( "Accept" ) ) ;
456404 const win = osparc . ui . window . Window . popUpInWindow ( textEditor , title , 400 , 300 ) ;
457405 textEditor . addListener ( "textChanged" , e => {
458406 const newText = e . getData ( ) ;
@@ -464,6 +412,9 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
464412 win . close ( ) ;
465413 } , this ) ;
466414 } , this ) ;
415+ this . bind ( "mode" , button , "visibility" , {
416+ converter : mode => mode === "edit" ? "visible" : "excluded"
417+ } ) ;
467418 this . __tsrGrid . add ( button , {
468419 row,
469420 column : this . __tsrGridPos . edit
@@ -480,103 +431,164 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
480431
481432 // ANNOTATIONS //
482433 __populateAnnotations : function ( ) {
483- this . __annotationsGrid . removeAll ( ) ;
484- this . __populateAnnotationsHeaders ( ) ;
485- this . __populateAnnotationsData ( ) ;
486- } ,
487-
488- __populateAnnotationsHeaders : function ( ) {
489434 const schemaAnnotations = this . __schema [ "properties" ] [ "annotations" ] [ "properties" ] ;
435+ const copyMetadataAnnotations = this . __copyResourceData [ "quality" ] [ "annotations" ] ;
490436
491437 let row = 0 ;
492- Object . values ( schemaAnnotations ) . forEach ( annotation => {
493- let header = new qx . ui . basic . Label ( annotation . title ) . set ( {
494- marginTop : 5
495- } ) ;
496- if ( annotation . description !== "" ) {
497- header = new osparc . component . form . FieldWHint ( null , annotation . description , header ) . set ( {
498- allowGrowX : false
499- } ) ;
438+
439+ // certificationStatus
440+ const headerCS = this . __getAnnotationHeader ( schemaAnnotations . certificationStatus ) ;
441+ this . __annotationsGrid . add ( headerCS , {
442+ row,
443+ column : 0
444+ } ) ;
445+
446+ const certificationBox = new qx . ui . form . SelectBox ( ) . set ( {
447+ allowGrowX : false
448+ } ) ;
449+ this . bind ( "mode" , certificationBox , "enabled" , {
450+ converter : mode => mode === "edit"
451+ } ) ;
452+ schemaAnnotations . certificationStatus [ "enum" ] . forEach ( certStatus => {
453+ const certItem = new qx . ui . form . ListItem ( certStatus ) ;
454+ certificationBox . add ( certItem ) ;
455+ if ( copyMetadataAnnotations . certificationStatus === certStatus ) {
456+ certificationBox . setSelection ( [ certItem ] ) ;
500457 }
501- this . __annotationsGrid . add ( header , {
502- row,
503- column : 0
504- } ) ;
505- row ++ ;
506458 } ) ;
507- } ,
459+ certificationBox . addListener ( "changeSelection" , e => {
460+ const selection = e . getData ( ) ;
461+ copyMetadataAnnotations . certificationStatus = selection [ 0 ] . getLabel ( ) ;
462+ } , this ) ;
463+ this . __annotationsGrid . add ( certificationBox , {
464+ row,
465+ column : 1
466+ } ) ;
467+ row ++ ;
508468
509- __populateAnnotationsData : function ( ) {
510- const schemaAnnotations = this . __schema [ "properties" ] [ "annotations" ] [ "properties" ] ;
511- const copyMetadataAnnotations = this . __copyResourceData [ "quality" ] [ "annotations" ] ;
469+ // certificationLink
470+ const headerCL = this . __getAnnotationHeader ( schemaAnnotations . certificationLink ) ;
471+ certificationBox . bind ( "selection" , headerCL , "visibility" , {
472+ converter : selection => selection [ 0 ] . getLabel ( ) === "Uncertified" ? "excluded" : "visible"
473+ } , this ) ;
474+ this . __annotationsGrid . add ( headerCL , {
475+ row,
476+ column : 0
477+ } ) ;
512478
513- const isEditMode = this . getMode ( ) === "edit" ;
479+ const annotationCL = new osparc . ui . markdown . Markdown ( ) ;
480+ annotationCL . setValue ( copyMetadataAnnotations . certificationLink ) ;
481+ certificationBox . bind ( "selection" , annotationCL , "visibility" , {
482+ converter : selection => selection [ 0 ] . getLabel ( ) === "Uncertified" ? "excluded" : "visible"
483+ } , this ) ;
484+ this . __annotationsGrid . add ( annotationCL , {
485+ row,
486+ column : 1
487+ } ) ;
514488
515- let row = 0 ;
516- Object . keys ( schemaAnnotations ) . forEach ( annotationKey => {
517- if ( annotationKey === "certificationStatus" ) {
518- const certificationBox = new qx . ui . form . SelectBox ( ) . set ( {
519- allowGrowX : false ,
520- enabled : isEditMode
521- } ) ;
522- schemaAnnotations [ annotationKey ] [ "enum" ] . forEach ( certStatus => {
523- const certItem = new qx . ui . form . ListItem ( certStatus ) ;
524- certificationBox . add ( certItem ) ;
525- if ( copyMetadataAnnotations . certificationStatus === certStatus ) {
526- certificationBox . setSelection ( [ certItem ] ) ;
527- }
528- } ) ;
529- certificationBox . addListener ( "changeSelection" , e => {
530- copyMetadataAnnotations . certificationStatus = e . getData ( ) [ 0 ] . getLabel ( ) ;
531- } , this ) ;
532- this . __annotationsGrid . add ( certificationBox , {
533- row,
534- column : 1
535- } ) ;
536- } else {
537- let serviceLimitations = "" ;
538- if ( "workbench" in this . __resourceData && annotationKey === "limitations" ) {
539- const services = osparc . utils . Services . getUniqueServicesFromWorkbench ( this . __resourceData [ "workbench" ] ) ;
540- services . forEach ( service => {
541- const metaData = osparc . utils . Services . getMetaData ( service . key , service . version ) ;
542- const knownLimitations = osparc . component . metadata . Quality . getKnownLimitations ( metaData ) ;
543- if ( knownLimitations !== "" ) {
544- serviceLimitations += "<br>" + metaData . name + ":<br>" + knownLimitations ;
545- }
546- } ) ;
547- }
548- const annotationMD = new osparc . ui . markdown . Markdown ( ) ;
549- annotationMD . setValue ( copyMetadataAnnotations [ annotationKey ] + serviceLimitations ) ;
550- this . __annotationsGrid . add ( annotationMD , {
551- row,
552- column : 1
553- } ) ;
489+ const buttonCL = this . __getEditButton ( copyMetadataAnnotations . certificationLink , annotationCL ) ;
490+ certificationBox . bind ( "selection" , buttonCL , "visibility" , {
491+ converter : selection => ( this . getMode ( ) === "edit" && selection [ 0 ] . getLabel ( ) !== "Uncertified" ) ? "visible" : "excluded"
492+ } , this ) ;
493+ this . bind ( "mode" , buttonCL , "visibility" , {
494+ converter : mode => ( mode === "edit" && certificationBox . getSelection ( ) [ 0 ] . getLabel ( ) !== "Uncertified" ) ? "visible" : "excluded"
495+ } ) ;
496+ this . __annotationsGrid . add ( buttonCL , {
497+ row,
498+ column : 2
499+ } ) ;
500+ row ++ ;
554501
555- if ( isEditMode ) {
556- const button = osparc . utils . Utils . getEditButton ( ) ;
557- button . addListener ( "execute" , ( ) => {
558- const title = this . tr ( "Edit Annotations" ) ;
559- const subtitle = this . tr ( "Supports Markdown" ) ;
560- const textEditor = new osparc . component . widget . TextEditor ( copyMetadataAnnotations [ annotationKey ] , subtitle , title ) ;
561- const win = osparc . ui . window . Window . popUpInWindow ( textEditor , title , 400 , 300 ) ;
562- textEditor . addListener ( "textChanged" , e => {
563- const newText = e . getData ( ) ;
564- annotationMD . setValue ( newText + serviceLimitations ) ;
565- copyMetadataAnnotations [ annotationKey ] = newText ;
566- win . close ( ) ;
567- } , this ) ;
568- textEditor . addListener ( "cancel" , ( ) => {
569- win . close ( ) ;
570- } , this ) ;
571- } , this ) ;
572- this . __annotationsGrid . add ( button , {
573- row,
574- column : 2
575- } ) ;
502+ // vandv
503+ const headerVV = this . __getAnnotationHeader ( schemaAnnotations . vandv ) ;
504+ this . __annotationsGrid . add ( headerVV , {
505+ row,
506+ column : 0
507+ } ) ;
508+
509+ const annotationVV = new osparc . ui . markdown . Markdown ( ) ;
510+ annotationVV . setValue ( copyMetadataAnnotations . vandv ) ;
511+ this . __annotationsGrid . add ( annotationVV , {
512+ row,
513+ column : 1
514+ } ) ;
515+
516+ const buttonVV = this . __getEditButton ( copyMetadataAnnotations . certificationLink , annotationCL ) ;
517+ this . bind ( "mode" , buttonVV , "visibility" , {
518+ converter : mode => mode === "edit" ? "visible" : "excluded"
519+ } ) ;
520+ this . __annotationsGrid . add ( buttonVV , {
521+ row,
522+ column : 2
523+ } ) ;
524+ row ++ ;
525+
526+ // limitations
527+ const headerL = this . __getAnnotationHeader ( schemaAnnotations . limitations ) ;
528+ this . __annotationsGrid . add ( headerL , {
529+ row,
530+ column : 0
531+ } ) ;
532+
533+ let serviceLimitations = "" ;
534+ if ( "workbench" in this . __resourceData ) {
535+ const services = osparc . utils . Services . getUniqueServicesFromWorkbench ( this . __resourceData [ "workbench" ] ) ;
536+ services . forEach ( service => {
537+ const metaData = osparc . utils . Services . getMetaData ( service . key , service . version ) ;
538+ const knownLimitations = osparc . component . metadata . Quality . getKnownLimitations ( metaData ) ;
539+ if ( knownLimitations !== "" ) {
540+ serviceLimitations += "<br>" + metaData . name + ":<br>" + knownLimitations ;
576541 }
577- }
578- row ++ ;
542+ } ) ;
543+ }
544+ const annotationLimitations = new osparc . ui . markdown . Markdown ( ) ;
545+ annotationLimitations . setValue ( copyMetadataAnnotations . limitations + serviceLimitations ) ;
546+ this . __annotationsGrid . add ( annotationLimitations , {
547+ row,
548+ column : 1
579549 } ) ;
550+
551+ const buttonL = this . __getEditButton ( copyMetadataAnnotations . certificationLink , annotationCL ) ;
552+ this . bind ( "mode" , buttonL , "visibility" , {
553+ converter : mode => mode === "edit" ? "visible" : "excluded"
554+ } ) ;
555+ this . __annotationsGrid . add ( buttonL , {
556+ row,
557+ column : 2
558+ } ) ;
559+ } ,
560+
561+ __getAnnotationHeader : function ( annotation ) {
562+ let header = new qx . ui . basic . Label ( annotation . title ) . set ( {
563+ marginTop : 5
564+ } ) ;
565+ if ( annotation . description !== "" ) {
566+ header = new osparc . component . form . FieldWHint ( null , annotation . description , header ) . set ( {
567+ allowGrowX : false
568+ } ) ;
569+ }
570+ return header ;
571+ } ,
572+
573+ __getEditButton : function ( fieldValue , viewMD , suffixText = "" ) {
574+ const button = osparc . utils . Utils . getEditButton ( ) ;
575+ button . addListener ( "execute" , ( ) => {
576+ const title = this . tr ( "Edit Annotations" ) ;
577+ const subtitle = this . tr ( "Supports Markdown" ) ;
578+ const textEditor = new osparc . component . widget . TextEditor ( fieldValue , subtitle , title ) ;
579+ textEditor . getChildControl ( "accept-button" ) . setLabel ( this . tr ( "Accept" ) ) ;
580+ const win = osparc . ui . window . Window . popUpInWindow ( textEditor , title , 400 , 300 ) ;
581+ textEditor . addListener ( "textChanged" , e => {
582+ const newText = e . getData ( ) ;
583+ viewMD . setValue ( newText + suffixText ) ;
584+ fieldValue = newText ;
585+ win . close ( ) ;
586+ } , this ) ;
587+ textEditor . addListener ( "cancel" , ( ) => {
588+ win . close ( ) ;
589+ } , this ) ;
590+ } , this ) ;
591+ return button ;
580592 } ,
581593 // ANNOTATIONS //
582594
0 commit comments