@@ -25,61 +25,48 @@ qx.Class.define("osparc.component.study.SaveAsTemplate", {
2525 extend : qx . ui . core . Widget ,
2626
2727 /**
28- * @param studyId {String} Study Id
2928 * @param studyData {Object} Object containing part or the entire serialized Study Data
3029 */
31- construct : function ( studyId , studyData ) {
30+ construct : function ( studyData ) {
3231 this . base ( arguments ) ;
3332
3433 this . _setLayout ( new qx . ui . layout . VBox ( 5 ) ) ;
3534
36- this . __studyId = studyId ;
37- this . __formData = osparc . data . model . Study . deepCloneStudyObject ( studyData ) ;
35+ this . __studyDataClone = osparc . data . model . Study . deepCloneStudyObject ( studyData ) ;
3836
3937 this . __buildLayout ( ) ;
40-
41- this . setHeaderText ( this . tr ( "Make Template accessible to" ) ) ;
42- this . setButtonText ( this . tr ( "Publish" ) ) ;
43- } ,
44-
45- properties : {
46- headerText : {
47- check : "String" ,
48- init : "" ,
49- event : "changeHeaderText"
50- } ,
51-
52- buttonText : {
53- check : "String" ,
54- init : "" ,
55- event : "changeButtonText"
56- }
5738 } ,
5839
5940 events : {
6041 "finished" : "qx.event.type.Data"
6142 } ,
6243
6344 members : {
64- __studyId : null ,
45+ __studyDataClone : null ,
6546 __shareWith : null ,
66- __formData : null ,
47+ __copyWData : null ,
6748
6849 __buildLayout : function ( ) {
6950 const shareWith = this . __shareWith = new osparc . component . permissions . ShareWith ( ) ;
70- this . bind ( "headerText" , shareWith , "legend" ) ;
51+ shareWith . getChildControl ( "legend" ) . set ( {
52+ label : this . tr ( "Make Template accessible to" ) ,
53+ font : "title-14"
54+ } ) ;
7155 this . _add ( shareWith , {
7256 flex : 1
7357 } ) ;
7458
59+ const publishWithdData = this . __copyWData = new qx . ui . form . CheckBox ( this . tr ( "Publish with data" ) ) . set ( {
60+ value : true
61+ } ) ;
62+ this . _add ( publishWithdData ) ;
63+
7564 const shareResourceBtn = new osparc . ui . form . FetchButton ( ) . set ( {
65+ label : this . tr ( "Publish" ) ,
7666 allowGrowX : false ,
7767 alignX : "right"
7868 } ) ;
79- this . bind ( "buttonText" , shareResourceBtn , "label" ) ;
80- shareResourceBtn . addListener ( "execute" , ( ) => {
81- this . __shareResource ( shareResourceBtn ) ;
82- } , this ) ;
69+ shareResourceBtn . addListener ( "execute" , ( ) => this . __shareResource ( shareResourceBtn ) , this ) ;
8370 shareWith . bind ( "ready" , shareResourceBtn , "enabled" ) ;
8471 this . _add ( shareResourceBtn ) ;
8572 } ,
@@ -89,7 +76,7 @@ qx.Class.define("osparc.component.study.SaveAsTemplate", {
8976
9077 const selectedGroupIDs = this . __shareWith . getSelectedGroups ( ) ;
9178 selectedGroupIDs . forEach ( gid => {
92- this . __formData [ "accessRights" ] [ gid ] = {
79+ this . __studyDataClone [ "accessRights" ] [ gid ] = {
9380 "read" : true ,
9481 "write" : false ,
9582 "delete" : false
@@ -98,9 +85,10 @@ qx.Class.define("osparc.component.study.SaveAsTemplate", {
9885
9986 const params = {
10087 url : {
101- "study_id" : this . __studyId
88+ "study_id" : this . __studyDataClone . uuid ,
89+ "copy_data" : this . __copyWData . getValue ( )
10290 } ,
103- data : this . __formData
91+ data : this . __studyDataClone
10492 } ;
10593 osparc . data . Resources . fetch ( "studies" , "postToTemplate" , params )
10694 . then ( template => {
0 commit comments