Skip to content

Commit aa07dd8

Browse files
authored
🎨 [Frontend] Hide template used to register function (#7886)
1 parent b04091c commit aa07dd8

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ qx.Class.define("osparc.data.Resources", {
151151
},
152152
postToTemplate: {
153153
method: "POST",
154-
url: statics.API + "/projects?from_study={study_id}&as_template=true&copy_data={copy_data}"
154+
url: statics.API + "/projects?from_study={study_id}&as_template=true&copy_data={copy_data}&hidden={hidden}"
155155
},
156156
open: {
157157
method: "POST",
@@ -303,6 +303,10 @@ qx.Class.define("osparc.data.Resources", {
303303
method: "POST",
304304
url: statics.API + "/projects/{studyId}/workspaces/{workspaceId}:move"
305305
},
306+
updateMetadata: {
307+
method: "PATCH",
308+
url: statics.API + "/projects/{studyId}/metadata"
309+
},
306310
}
307311
},
308312
"conversations": {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ qx.Class.define("osparc.desktop.MainPage", {
240240
const params = {
241241
url: {
242242
"study_id": studyId,
243-
"copy_data": copyData
243+
"copy_data": copyData,
244+
"hidden": false,
244245
},
245246
};
246247
const options = {

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,12 @@ qx.Class.define("osparc.study.CreateFunction", {
282282
__createFunction: function(exposedInputs, exposedOutputs) {
283283
this.__createFunctionBtn.setFetching(true);
284284

285-
// first publish it as a template
285+
// first publish it as a hidden template
286286
const params = {
287287
url: {
288288
"study_id": this.__studyData["uuid"],
289289
"copy_data": true,
290+
"hidden": true,
290291
},
291292
};
292293
const options = {
@@ -298,7 +299,8 @@ qx.Class.define("osparc.study.CreateFunction", {
298299
.then(task => {
299300
task.addListener("resultReceived", e => {
300301
const templateData = e.getData();
301-
this.__doCreateFunction(templateData, exposedInputs, exposedOutputs);
302+
this.__updateTemplateMetadata(templateData);
303+
this.__registerFunction(templateData, exposedInputs, exposedOutputs);
302304
});
303305
})
304306
.catch(err => {
@@ -307,13 +309,27 @@ qx.Class.define("osparc.study.CreateFunction", {
307309
});
308310
},
309311

310-
__doCreateFunction: function(templateData, exposedInputs, exposedOutputs) {
312+
__updateTemplateMetadata: function(templateData) {
313+
const patchData = {
314+
"custom" : {
315+
"hidden": "Base template for function",
316+
}
317+
};
318+
const params = {
319+
url: {
320+
"studyId": templateData["uuid"],
321+
},
322+
data: patchData
323+
};
324+
osparc.data.Resources.fetch("studies", "updateMetadata", params)
325+
.catch(err => console.error(err));
326+
},
327+
328+
__registerFunction: function(templateData, exposedInputs, exposedOutputs) {
311329
const nameField = this.__form.getItem("name");
312330
const descriptionField = this.__form.getItem("description");
313331

314332
const functionData = this.self().createFunctionData(templateData, nameField.getValue(), descriptionField.getValue(), exposedInputs, exposedOutputs);
315-
console.log("functionData", functionData);
316-
317333
const params = {
318334
data: functionData,
319335
};

0 commit comments

Comments
 (0)