Skip to content

Commit 7aa66b9

Browse files
committed
patch template after creation
1 parent a22d89c commit 7aa66b9

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

services/static-webserver/client/source/class/osparc/desktop/MainPage.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 => {

services/static-webserver/client/source/class/osparc/study/SaveAsTemplate.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ qx.Class.define("osparc.study.SaveAsTemplate", {
9090
__publishTemplate: function() {
9191
const publishWithDataCB = this.__form.getItem("publishWithData");
9292
const templateTypeSB = this.__form.getItem("templateType");
93-
9493
const templateType = templateTypeSB ? templateTypeSB.getSelection()[0].getModel() : null;
95-
if (templateType) {
96-
this.__studyDataClone["ui"]["templateType"] = templateType;
97-
}
9894

9995
const readAccessRole = osparc.data.Roles.STUDY["read"];
10096
// AccessRights will be POSTed after the template is created.
@@ -109,8 +105,8 @@ qx.Class.define("osparc.study.SaveAsTemplate", {
109105
this.fireDataEvent("publishTemplate", {
110106
"studyData": this.__studyDataClone,
111107
"copyData": publishWithDataCB.getValue(),
112-
113108
"accessRights": accessRights,
109+
"templateType": templateType,
114110
});
115111
},
116112

0 commit comments

Comments
 (0)