@@ -225,12 +225,17 @@ qx.Class.define("osparc.desktop.MainPage", {
225225 const text = this . tr ( "Started template creation and added to the background tasks" ) ;
226226 osparc . FlashMessenger . logAs ( text , "INFO" ) ;
227227
228+ const studyId = data [ "studyData" ] . uuid ;
229+ const studyName = data [ "studyData" ] . name ;
230+ const copyData = data [ "copyData" ] ;
231+ const templateAccessRights = data [ "accessRights" ] ;
232+ const templateType = data [ "templateType" ] ;
233+
228234 const params = {
229235 url : {
230- "study_id" : data [ "studyData" ] . uuid ,
231- "copy_data" : data [ " copyData" ]
236+ "study_id" : studyId ,
237+ "copy_data" : copyData
232238 } ,
233- data : data [ "studyData" ]
234239 } ;
235240 const options = {
236241 pollTask : true
@@ -241,11 +246,18 @@ qx.Class.define("osparc.desktop.MainPage", {
241246 . then ( task => {
242247 const templateBrowser = this . __dashboard . getTemplateBrowser ( ) ;
243248 if ( templateBrowser ) {
244- templateBrowser . taskToTemplateReceived ( task , data [ "studyData" ] . name ) ;
249+ templateBrowser . taskToTemplateReceived ( task , studyName ) ;
245250 }
246251 task . addListener ( "resultReceived" , e => {
247252 const templateData = e . getData ( ) ;
248- osparc . store . Study . addCollaborators ( templateData , data [ "accessRights" ] ) ;
253+ // these operations need to be done after template creation
254+ osparc . store . Study . addCollaborators ( templateData , templateAccessRights ) ;
255+ if ( templateType ) {
256+ const studyUI = osparc . utils . Utils . deepCloneObject ( templateData [ "ui" ] ) ;
257+ studyUI [ "templateType" ] = templateType ;
258+ osparc . store . Study . patchStudyData ( templateData , "ui" , studyUI )
259+ . then ( ( ) => console . log ( "patched" ) ) ;
260+ }
249261 } ) ;
250262 } )
251263 . catch ( errMsg => {
0 commit comments