Skip to content

Commit b187790

Browse files
authored
Publish template with or without data (ITISFoundation#2659)
1 parent 0c2b223 commit b187790

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

services/web/client/source/class/osparc/component/study/SaveAsTemplate.js

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

services/web/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
669669
__getSaveAsTemplateMenuButton: function(studyData) {
670670
const saveAsTemplateButton = new qx.ui.menu.Button(this.tr("Publish as Template"));
671671
saveAsTemplateButton.addListener("execute", () => {
672-
const saveAsTemplateView = new osparc.component.study.SaveAsTemplate(studyData.uuid, studyData);
672+
const saveAsTemplateView = new osparc.component.study.SaveAsTemplate(studyData);
673673
const title = this.tr("Publish as Template");
674674
const window = osparc.ui.window.Window.popUpInWindow(saveAsTemplateView, title, 400, 300);
675675
saveAsTemplateView.addListener("finished", e => {

services/web/client/source/class/osparc/data/Resources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ qx.Class.define("osparc.data.Resources", {
9292
},
9393
postToTemplate: {
9494
method: "POST",
95-
url: statics.API + "/projects?as_template={study_id}"
95+
url: statics.API + "/projects?as_template={study_id}&copy_data={copy_data}"
9696
},
9797
open: {
9898
method: "POST",

0 commit comments

Comments
 (0)