Skip to content

Commit 4a0408a

Browse files
committed
CreateFunction
1 parent bfd5872 commit 4a0408a

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,13 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
817817
const iconSrc = "@MaterialIcons/functions/24";
818818
const title = this.tr("Create Function");
819819
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
820+
const createFunction = new osparc.study.CreateFunction(this.__resourceData);
821+
const createFunctionButton = createFunction.getCreateFunctionButton();
822+
osparc.dashboard.resources.pages.BasePage.decorateHeaderButton(createFunctionButton);
823+
const toolbar = this.self().createToolbar();
824+
toolbar.add(createFunctionButton);
825+
page.addToHeader(toolbar);
826+
page.addToContent(createFunction);
820827
return page;
821828
}
822829
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2024 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
19+
qx.Class.define("osparc.study.CreateFunction", {
20+
extend: qx.ui.core.Widget,
21+
22+
/**
23+
* @param studyData {Object} Object containing part or the entire serialized Study Data
24+
*/
25+
construct: function(studyData) {
26+
this.base(arguments);
27+
28+
this._setLayout(new qx.ui.layout.VBox(20));
29+
30+
this.__studyDataClone = osparc.data.model.Study.deepCloneStudyObject(studyData);
31+
32+
this.__buildLayout();
33+
},
34+
35+
members: {
36+
__studyDataClone: null,
37+
__form: null,
38+
__createFunctionBtn: null,
39+
40+
__buildLayout: function() {
41+
const form = this.__form = new qx.ui.form.Form();
42+
this._add(new qx.ui.form.renderer.Single(form));
43+
44+
const title = new qx.ui.form.TextField().set({
45+
required: true,
46+
value: this.__studyDataClone.name,
47+
});
48+
this.addListener("appear", () => {
49+
title.focus();
50+
title.activate();
51+
});
52+
form.add(title, this.tr("Name"), null, "name");
53+
54+
const description = new qx.ui.form.TextField().set({
55+
required: false,
56+
});
57+
form.add(description, this.tr("Description"), null, "description");
58+
59+
const createFunctionBtn = this.__createFunctionBtn = new qx.ui.form.Button().set({
60+
appearance: "strong-button",
61+
label: this.tr("Create"),
62+
allowGrowX: false,
63+
alignX: "right"
64+
});
65+
createFunctionBtn.addListener("execute", () => this.__createFunction(), this);
66+
this._add(createFunctionBtn);
67+
},
68+
69+
__createFunction: function() {
70+
const name = this.__form.getItem("name");
71+
const description = this.__form.getItem("description");
72+
73+
console.log("Creating function with name: ", name.getValue());
74+
console.log("Creating function with description: ", description.getValue());
75+
},
76+
77+
getCreateFunctionButton: function() {
78+
return this.__createFunctionBtn;
79+
}
80+
}
81+
});

0 commit comments

Comments
 (0)