|
| 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