Skip to content

Commit 2fea403

Browse files
authored
Bugfixes (#2193)
Fix TSR annotations Fix Inputs access level
1 parent ba3684c commit 2fea403

File tree

4 files changed

+41
-52
lines changed

4 files changed

+41
-52
lines changed

services/web/client/source/class/osparc/component/form/renderer/PropForm.js

+13-22
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,20 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {
9494
// overridden
9595
setAccessLevel: function(data) {
9696
const entry = this.self().gridPos;
97+
const disableables = osparc.component.form.renderer.PropFormBase.getDisableables();
9798
Object.entries(data).forEach(([portId, visibility]) => {
98-
Object.values(entry).forEach(entryVal => {
99-
const layoutElement = this._getLayoutChild(portId, entryVal);
100-
if (layoutElement) {
101-
this.__changeControlVisibility(layoutElement.child, visibility);
99+
Object.values(entry).forEach(entryPos => {
100+
const layoutElement = this._getLayoutChild(portId, entryPos);
101+
if (layoutElement && layoutElement.child) {
102+
const control = layoutElement.child;
103+
if (control) {
104+
const vis = visibility === this._visibility.hidden ? "excluded" : "visible";
105+
const enabled = visibility === this._visibility.readWrite;
106+
control.setVisibility(vis);
107+
if (disableables.includes(entryPos)) {
108+
control.setEnabled(enabled);
109+
}
110+
}
102111
}
103112
});
104113
});
@@ -573,24 +582,6 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {
573582
},
574583
/* /PARAMETERS */
575584

576-
__changeControlVisibility: function(control, visibility) {
577-
if (control === null) {
578-
return;
579-
}
580-
581-
switch (visibility) {
582-
case this._visibility.hidden:
583-
control.setVisibility("excluded");
584-
break;
585-
case this._visibility.readOnly:
586-
control.setVisibility("visible");
587-
break;
588-
case this._visibility.readWrite:
589-
control.setVisibility("visible");
590-
break;
591-
}
592-
},
593-
594585
__getRetrieveFieldChild: function(portId) {
595586
return this._getLayoutChild(portId, this.self().gridPos.retrieveStatus);
596587
}

services/web/client/source/class/osparc/component/form/renderer/PropFormBase.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ qx.Class.define("osparc.component.form.renderer.PropFormBase", {
6161
ctrlField: 2,
6262
unit: 3,
6363
menu: 4
64+
},
65+
66+
getDisableables: function() {
67+
return [
68+
this.gridPos.label,
69+
this.gridPos.ctrlField,
70+
this.gridPos.menu
71+
];
6472
}
6573
},
6674

@@ -281,7 +289,9 @@ qx.Class.define("osparc.component.form.renderer.PropFormBase", {
281289
});
282290
osparc.data.model.Sweeper.isSweeperEnabled()
283291
.then(isSweeperEnabled => {
284-
menuBtn.setVisibility(isSweeperEnabled ? "visible" : "excluded");
292+
field.bind("visibility", menuBtn, "visibility", {
293+
converter: visibility => (visibility === "visible" && isSweeperEnabled) ? "visible" : "excluded"
294+
});
285295
});
286296
return menuBtn;
287297
}

services/web/client/source/class/osparc/component/form/renderer/PropFormEditor.js

+11-23
Original file line numberDiff line numberDiff line change
@@ -179,30 +179,18 @@ qx.Class.define("osparc.component.form.renderer.PropFormEditor", {
179179
__setAccessLevel: function(data) {
180180
for (const key in data) {
181181
const label = this._getLabelFieldChild(key).child;
182-
const control = this._form.getControl(key);
183-
switch (data[key]) {
184-
case this._visibility.hidden: {
185-
const newLabel = this.__addDelTag(label.getValue());
186-
label.setValue(newLabel);
187-
label.setEnabled(false);
188-
control.setEnabled(false);
189-
break;
182+
const newLabel = data[key] === this._visibility.hidden ? this.__addDelTag(label.getValue()) : this.__removeDelTag(label.getValue());
183+
label.setValue(newLabel);
184+
185+
const enabled = data[key] === this._visibility.readWrite;
186+
const disableables = osparc.component.form.renderer.PropFormBase.getDisableables();
187+
const ctrls = [];
188+
disableables.forEach(disableable => ctrls.push(this._getLayoutChild(key, disableable)));
189+
ctrls.forEach(ctrl => {
190+
if (ctrl) {
191+
ctrl.child.setEnabled(enabled);
190192
}
191-
case this._visibility.readOnly: {
192-
const newLabel = this.__removeDelTag(label.getValue());
193-
label.setValue(newLabel);
194-
label.setEnabled(false);
195-
control.setEnabled(false);
196-
break;
197-
}
198-
case this._visibility.readWrite: {
199-
const newLabel = this.__removeDelTag(label.getValue());
200-
label.setValue(newLabel);
201-
label.setEnabled(true);
202-
control.setEnabled(true);
203-
break;
204-
}
205-
}
193+
});
206194
}
207195
},
208196

services/web/client/source/class/osparc/component/metadata/QualityEditor.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
487487
column: 1
488488
});
489489

490-
const buttonCL = this.__getEditButton(copyMetadataAnnotations.certificationLink, annotationCL);
490+
const buttonCL = this.__getEditButton(copyMetadataAnnotations, "certificationLink", annotationCL);
491491
certificationBox.bind("selection", buttonCL, "visibility", {
492492
converter: selection => (this.getMode() === "edit" && selection[0].getLabel() !== "Uncertified") ? "visible" : "excluded"
493493
}, this);
@@ -514,7 +514,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
514514
column: 1
515515
});
516516

517-
const buttonVV = this.__getEditButton(copyMetadataAnnotations.certificationLink, annotationCL);
517+
const buttonVV = this.__getEditButton(copyMetadataAnnotations, "vandv", annotationVV);
518518
this.bind("mode", buttonVV, "visibility", {
519519
converter: mode => mode === "edit" ? "visible" : "excluded"
520520
});
@@ -549,7 +549,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
549549
column: 1
550550
});
551551

552-
const buttonL = this.__getEditButton(copyMetadataAnnotations.certificationLink, annotationCL);
552+
const buttonL = this.__getEditButton(copyMetadataAnnotations, "limitations", annotationLimitations, serviceLimitations);
553553
this.bind("mode", buttonL, "visibility", {
554554
converter: mode => mode === "edit" ? "visible" : "excluded"
555555
});
@@ -571,18 +571,18 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
571571
return header;
572572
},
573573

574-
__getEditButton: function(fieldValue, viewMD, suffixText = "") {
574+
__getEditButton: function(annotationsObj, fieldKey, viewMD, suffixText = "") {
575575
const button = osparc.utils.Utils.getEditButton();
576576
button.addListener("execute", () => {
577577
const title = this.tr("Edit Annotations");
578578
const subtitle = this.tr("Supports Markdown");
579-
const textEditor = new osparc.component.widget.TextEditor(fieldValue, subtitle, title);
579+
const textEditor = new osparc.component.widget.TextEditor(annotationsObj[fieldKey], subtitle, title);
580580
textEditor.getChildControl("accept-button").setLabel(this.tr("Accept"));
581581
const win = osparc.ui.window.Window.popUpInWindow(textEditor, title, 400, 300);
582582
textEditor.addListener("textChanged", e => {
583583
const newText = e.getData();
584584
viewMD.setValue(newText + suffixText);
585-
fieldValue = newText;
585+
annotationsObj[fieldKey] = newText;
586586
win.close();
587587
}, this);
588588
textEditor.addListener("cancel", () => {

0 commit comments

Comments
 (0)