@@ -57,6 +57,47 @@ qx.Class.define("osparc.info.StudyLarge", {
5757
5858 const vBox = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 10 ) ) ;
5959
60+ if ( this . getStudy ( ) . getTemplateType ( ) && osparc . data . Permissions . getInstance ( ) . isTester ( ) ) {
61+ // let testers change the template type
62+ const hBox = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 5 ) . set ( {
63+ alignY : "middle" ,
64+ } ) ) ;
65+ hBox . add ( new qx . ui . basic . Label ( this . tr ( "Template Type:" ) ) ) ;
66+ const templateTypeSB = osparc . study . Utils . createTemplateTypeSB ( ) ;
67+ hBox . add ( templateTypeSB ) ;
68+ const saveBtn = new osparc . ui . form . FetchButton ( this . tr ( "Save" ) ) . set ( {
69+ enabled : false ,
70+ allowGrowX : false ,
71+ } ) ;
72+ hBox . add ( saveBtn ) ;
73+ vBox . add ( hBox ) ;
74+
75+ templateTypeSB . addListener ( "changeSelection" , e => {
76+ const selected = e . getData ( ) [ 0 ] ;
77+ if ( selected ) {
78+ const templateType = selected . getModel ( ) ;
79+ saveBtn . setEnabled ( this . getStudy ( ) . getTemplateType ( ) !== templateType ) ;
80+ }
81+ } , this ) ;
82+
83+ templateTypeSB . getSelectables ( ) . forEach ( selectable => {
84+ if ( selectable . getModel ( ) === this . getStudy ( ) . getTemplateType ( ) ) {
85+ templateTypeSB . setSelection ( [ selectable ] ) ;
86+ }
87+ } ) ;
88+
89+ saveBtn . addListener ( "execute" , ( ) => {
90+ const selected = templateTypeSB . getSelection ( ) [ 0 ] ;
91+ if ( selected ) {
92+ saveBtn . setFetching ( true ) ;
93+ const templateType = selected . getModel ( ) ;
94+ osparc . store . Study . patchTemplateType ( this . getStudy ( ) . getUuid ( ) , templateType )
95+ . then ( ( ) => osparc . FlashMessenger . logAs ( this . tr ( "Template type updated, please reload" ) , "INFO" ) )
96+ . finally ( ( ) => saveBtn . setFetching ( false ) ) ;
97+ }
98+ } , this ) ;
99+ }
100+
60101 const infoElements = this . __infoElements ( ) ;
61102 const infoLayout = osparc . info . StudyUtils . infoElementsToLayout ( infoElements ) ;
62103 vBox . add ( infoLayout ) ;
0 commit comments