Skip to content

Commit e3e6af6

Browse files
committed
updateMetadata
1 parent 76be64b commit e3e6af6

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

services/static-webserver/client/source/class/osparc/store/Study.js

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,41 @@ qx.Class.define("osparc.store.Study", {
7575
return osparc.data.Resources.fetch("studies", "patch", params);
7676
},
7777

78+
patchStudyData: function(studyData, fieldKey, value) {
79+
if (osparc.data.model.Study.OwnPatch.includes(fieldKey)) {
80+
console.error(fieldKey, "has it's own PATCH path");
81+
return null;
82+
}
83+
84+
const patchData = {};
85+
patchData[fieldKey] = value;
86+
return this.patchStudy(studyData["uuid"], patchData)
87+
.then(() => {
88+
studyData[fieldKey] = value;
89+
// A bit hacky, but it's not sent back to the backend
90+
studyData["lastChangeDate"] = new Date().toISOString();
91+
});
92+
},
93+
94+
patchTemplateType: function(templateId, templateType) {
95+
const patchData = {
96+
"templateType": templateType,
97+
};
98+
return this.patchStudy(templateId, patchData)
99+
.catch(err => osparc.FlashMessenger.logError(err));
100+
},
101+
102+
updateMetadata: function(studyId, metadata) {
103+
const params = {
104+
url: {
105+
studyId,
106+
},
107+
data: metadata
108+
};
109+
osparc.data.Resources.fetch("studies", "updateMetadata", params)
110+
.catch(err => console.error(err));
111+
},
112+
78113
trashStudy: function(studyId) {
79114
const params = {
80115
url: {
@@ -118,30 +153,6 @@ qx.Class.define("osparc.store.Study", {
118153
return osparc.data.Resources.fetch("studies", "moveToFolder", params);
119154
},
120155

121-
patchStudyData: function(studyData, fieldKey, value) {
122-
if (osparc.data.model.Study.OwnPatch.includes(fieldKey)) {
123-
console.error(fieldKey, "has it's own PATCH path");
124-
return null;
125-
}
126-
127-
const patchData = {};
128-
patchData[fieldKey] = value;
129-
return this.patchStudy(studyData["uuid"], patchData)
130-
.then(() => {
131-
studyData[fieldKey] = value;
132-
// A bit hacky, but it's not sent back to the backend
133-
studyData["lastChangeDate"] = new Date().toISOString();
134-
});
135-
},
136-
137-
patchTemplateType: function(templateId, templateType) {
138-
const patchData = {
139-
"templateType": templateType,
140-
};
141-
return this.patchStudy(templateId, patchData)
142-
.catch(err => osparc.FlashMessenger.logError(err));
143-
},
144-
145156
patchNodeData: function(studyData, nodeId, patchData) {
146157
const params = {
147158
url: {

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,12 @@ qx.Class.define("osparc.study.CreateFunction", {
330330
},
331331

332332
__updateTemplateMetadata: function(templateData) {
333-
const patchData = {
333+
const metadata = {
334334
"custom" : {
335335
"hidden": "Base template for function",
336336
}
337337
};
338-
const params = {
339-
url: {
340-
"studyId": templateData["uuid"],
341-
},
342-
data: patchData
343-
};
344-
osparc.data.Resources.fetch("studies", "updateMetadata", params)
345-
.catch(err => console.error(err));
338+
osparc.store.Study.updateMetadata(templateData["uuid"], metadata);
346339
},
347340

348341
__registerFunction: function(templateData, defaultInputs, exposedInputs, exposedOutputs) {

0 commit comments

Comments
 (0)