Skip to content

Commit 1e1cbc2

Browse files
committed
publish with template_type
1 parent da8110a commit 1e1cbc2

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

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

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,35 @@ qx.Class.define("osparc.study.SaveAsTemplate", {
4343

4444
members: {
4545
__studyDataClone: null,
46-
__copyWData: null,
47-
__templateTypeSB: null,
48-
__shareWith: null,
46+
__form: null,
4947
__publishTemplateBtn: null,
5048

5149
__buildLayout: function() {
52-
const publishWithData = this.__copyWData = new qx.ui.form.CheckBox(this.tr("Publish with data")).set({
50+
const form = this.__form = new qx.ui.form.Form();
51+
this._add(new qx.ui.form.renderer.Single(form));
52+
53+
const publishWithData = new qx.ui.form.CheckBox().set({
5354
value: true,
5455
iconPosition: "right",
5556
});
56-
this._add(publishWithData);
57+
form.add(publishWithData, this.tr("Publish with data"), null, "publishWithData");
5758

5859
if (osparc.utils.DisabledPlugins.isHypertoolsEnabled()) {
59-
const templateTypeSB = this.__templateTypeSB = new qx.ui.form.SelectBox();
60-
const countries = osparc.store.StaticInfo.getInstance().getCountries();
61-
[{
62-
label: "Standard",
60+
const templateTypeSB = new qx.ui.form.SelectBox().set({
61+
allowGrowX: false,
62+
});
63+
const templateTypes = [{
64+
label: "Tutorial",
6365
id: null,
6466
}, {
6567
label: "Hypertool",
66-
id: "hypertool",
68+
id: osparc.data.model.StudyUI.HYPERTOOL_TYPE,
6769
}]
68-
countries.forEach(c => {
69-
const cItem = new qx.ui.form.ListItem(c.name, null, c.alpha2).set({
70-
rich: true
71-
});
72-
templateTypeSB.add(cItem);
70+
templateTypes.forEach(tempType => {
71+
const tItem = new qx.ui.form.ListItem(tempType.label, null, tempType.id);
72+
templateTypeSB.add(tItem);
7373
});
74+
form.add(templateTypeSB, this.tr("Template Type"), null, "templateType");
7475
}
7576

7677
const shareWith = this.__shareWith = new osparc.share.ShareTemplateWith(this.__studyDataClone);
@@ -87,6 +88,14 @@ qx.Class.define("osparc.study.SaveAsTemplate", {
8788
},
8889

8990
__publishTemplate: function() {
91+
const publishWithDataCB = this.__form.getItem("publishWithData");
92+
const templateTypeSB = this.__form.getItem("templateType");
93+
94+
const templateType = templateTypeSB ? templateTypeSB.getSelection()[0].getModel() : null;
95+
if (templateType) {
96+
this.__studyDataClone["ui"]["templateType"] = templateType;
97+
}
98+
9099
const readAccessRole = osparc.data.Roles.STUDY["read"];
91100
// AccessRights will be POSTed after the template is created.
92101
// No need to add myself, backend will automatically do it
@@ -99,8 +108,9 @@ qx.Class.define("osparc.study.SaveAsTemplate", {
99108

100109
this.fireDataEvent("publishTemplate", {
101110
"studyData": this.__studyDataClone,
102-
"copyData": this.__copyWData.getValue(),
103-
"accessRights": accessRights
111+
"copyData": publishWithDataCB.getValue(),
112+
113+
"accessRights": accessRights,
104114
});
105115
},
106116

0 commit comments

Comments
 (0)