Skip to content

Commit 8a0c4cb

Browse files
committed
make default value editable
1 parent 612354b commit 8a0c4cb

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ qx.Class.define("osparc.study.CreateFunction", {
6060

6161
const parameters = osparc.study.Utils.extractFunctionableParameters(projectData["workbench"]);
6262
parameters.forEach(parameter => {
63-
const parameterLabel = parameter["label"];
64-
if (exposedInputs[parameterLabel]) {
63+
const parameterKey = parameter["label"];
64+
if (exposedInputs[parameterKey]) {
6565
const parameterMetadata = osparc.store.Services.getMetadata(parameter["key"], parameter["version"]);
6666
if (parameterMetadata) {
6767
const type = osparc.service.Utils.getParameterType(parameterMetadata);
68-
functionData["inputSchema"]["schema_content"]["properties"][parameterLabel] = {
68+
functionData["inputSchema"]["schema_content"]["properties"][parameterKey] = {
6969
"type": type,
7070
};
71-
functionData["inputSchema"]["schema_content"]["required"].push(parameterLabel);
71+
functionData["inputSchema"]["schema_content"]["required"].push(parameterKey);
7272
}
7373
} else {
74-
functionData["defaultInputs"][parameterLabel] = osparc.service.Utils.getParameterValue(parameter);
74+
functionData["defaultInputs"][parameterKey] = osparc.service.Utils.getParameterValue(parameter);
7575
}
7676
});
7777

@@ -164,7 +164,8 @@ qx.Class.define("osparc.study.CreateFunction", {
164164

165165
const parameters = osparc.study.Utils.extractFunctionableParameters(this.__studyData["workbench"]);
166166
parameters.forEach(parameter => {
167-
const parameterLabel = new qx.ui.basic.Label(parameter["label"]);
167+
const parameterKey = parameter["label"];
168+
const parameterLabel = new qx.ui.basic.Label(parameterKey);
168169
inputsLayout.add(parameterLabel, {
169170
row,
170171
column,
@@ -186,15 +187,25 @@ qx.Class.define("osparc.study.CreateFunction", {
186187
row,
187188
column,
188189
});
189-
exposedInputs[parameter["label"]] = true;
190-
parameterExposed.addListener("changeValue", e => exposedInputs[parameter["label"]] = e.getData());
190+
exposedInputs[parameterKey] = true;
191+
parameterExposed.addListener("changeValue", e => exposedInputs[parameterKey] = e.getData());
191192
column++;
192193

193194
const paramValue = osparc.service.Utils.getParameterValue(parameter);
194-
defaultInputs[parameter["label"]] = paramValue;
195+
defaultInputs[parameterKey] = paramValue;
195196
let ctrl = null;
196197
if (parameterMetadata && osparc.service.Utils.getParameterType(parameterMetadata) === "number") {
197198
ctrl = new qx.ui.form.TextField(String(paramValue));
199+
ctrl.addListener("changeValue", e => {
200+
const newValue = e.getData();
201+
const oldValue = e.getOldData();
202+
if (newValue === oldValue) {
203+
return;
204+
}
205+
const curatedValue = (!isNaN(parseFloat(newValue))) ? parseFloat(newValue) : parseFloat(oldValue);
206+
defaultInputs[parameterKey] = curatedValue;
207+
ctrl.setValue(String(curatedValue));
208+
});
198209
} else {
199210
ctrl = new qx.ui.basic.Label(String(paramValue));
200211
}

0 commit comments

Comments
 (0)