Skip to content

Commit d9591fa

Browse files
authored
Allow disabling Quality Assessment (#2114)
Allow disabling Quality Assessment
1 parent 3f92f41 commit d9591fa

File tree

11 files changed

+123
-67
lines changed

11 files changed

+123
-67
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ qx.Class.define("osparc.component.metadata.Quality", {
2626
if (Object.keys(obj["quality"]).length === 0) {
2727
obj["quality"] = osparc.component.metadata.Quality.getDefaultQuality();
2828
}
29+
if (!("enabled" in obj["quality"])) {
30+
obj["quality"]["enabled"] = true;
31+
}
32+
},
33+
34+
isEnabled: function(quality) {
35+
return quality && "enabled" in quality && quality["enabled"];
2936
},
3037

3138
getConformanceLevel: function() {
@@ -82,8 +89,9 @@ domain and the intended context of use",
8289

8390
getDefaultQuality: function() {
8491
const defaultQuality = {};
85-
defaultQuality["annotations"] = osparc.component.metadata.Quality.getDefaultQualityAnnotations();
92+
defaultQuality["enabled"] = true;
8693
defaultQuality["tsr"] = osparc.component.metadata.Quality.getDefaultQualityTSR();
94+
defaultQuality["annotations"] = osparc.component.metadata.Quality.getDefaultQualityAnnotations();
8795
return defaultQuality;
8896
},
8997

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

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
3131
construct: function(resourceData) {
3232
this.base(arguments);
3333

34-
this._setLayout(new qx.ui.layout.VBox(15));
34+
this._setLayout(new qx.ui.layout.VBox(8));
3535

3636
this.__initResourceData(resourceData);
3737
},
@@ -56,6 +56,9 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
5656
__resourceData: null,
5757
__copyResourceData: null,
5858
__schema: null,
59+
__enabledQuality: null,
60+
__TSRSection: null,
61+
__annotationsSection: null,
5962
__tsrGrid: null,
6063
__annotationsGrid: null,
6164

@@ -134,26 +137,37 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
134137
this._removeAll();
135138

136139
this.__schema = schema;
137-
this.__createTSRSection();
138-
this.__createAnnotationsSection();
139140

140141
if (this.__isUserOwner()) {
141142
this.__createEditBtns();
143+
this.__createEnableSection();
142144
}
143145

146+
this.__createTSRSection();
147+
this.__createAnnotationsSection();
148+
144149
this.__populateForms();
145150
} else {
146151
osparc.component.message.FlashMessenger.logAs(this.tr("There was an error validating the metadata."), "ERROR");
147152
}
148153
},
149154

150155
__populateForms: function() {
156+
this.__populateEnable();
151157
this.__populateTSR();
152158
this.__populateAnnotations();
153159
},
154160

161+
__createEnableSection: function() {
162+
const enabledQuality = this.__enabledQuality = new qx.ui.form.CheckBox(this.tr("Enabled"));
163+
this.bind("mode", enabledQuality, "enabled", {
164+
converter: value => value === "edit"
165+
});
166+
this._add(enabledQuality);
167+
},
168+
155169
__createTSRSection: function() {
156-
const box = new qx.ui.groupbox.GroupBox(this.tr("Ten Simple Rules"));
170+
const box = this.__TSRSection = new qx.ui.groupbox.GroupBox(this.tr("Ten Simple Rules"));
157171
box.getChildControl("legend").set({
158172
font: "title-14"
159173
});
@@ -166,7 +180,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
166180
const helpTextMD = new osparc.ui.markdown.Markdown(helpText);
167181
box.add(helpTextMD);
168182

169-
const grid = new qx.ui.layout.Grid(10, 8);
183+
const grid = new qx.ui.layout.Grid(10, 6);
170184
grid.setColumnAlign(0, "left", "middle");
171185
grid.setColumnAlign(1, "left", "middle");
172186
grid.setColumnAlign(2, "left", "middle");
@@ -183,7 +197,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
183197
},
184198

185199
__createAnnotationsSection: function() {
186-
const box = new qx.ui.groupbox.GroupBox(this.tr("Annotations"));
200+
const box = this.__annotationsSection = new qx.ui.groupbox.GroupBox(this.tr("Annotations"));
187201
box.getChildControl("legend").set({
188202
font: "title-14"
189203
});
@@ -192,7 +206,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
192206
});
193207
box.setLayout(new qx.ui.layout.VBox(10));
194208

195-
const grid = new qx.ui.layout.Grid(10, 8);
209+
const grid = new qx.ui.layout.Grid(10, 6);
196210
grid.setColumnAlign(0, "left", "middle");
197211
grid.setColumnAlign(1, "left", "middle");
198212
grid.setColumnAlign(2, "left", "middle");
@@ -203,6 +217,20 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
203217
this._add(box);
204218
},
205219

220+
__populateEnable: function() {
221+
this.__enabledQuality.setValue(this.__copyResourceData["quality"]["enabled"]);
222+
this.__enabledQuality.addListener("changeValue", e => {
223+
const value = e.getData();
224+
this.__copyResourceData["quality"]["enabled"] = value;
225+
}, this);
226+
this.__enabledQuality.bind("value", this.__TSRSection, "visibility", {
227+
converter: value => value ? "visible" : "excluded"
228+
});
229+
this.__enabledQuality.bind("value", this.__annotationsSection, "visibility", {
230+
converter: value => value ? "visible" : "excluded"
231+
});
232+
},
233+
206234
__populateTSR: function() {
207235
this.__tsrGrid.removeAll();
208236
this.__populateTSRHeaders();
@@ -270,7 +298,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
270298
},
271299

272300
__populateTSRDataView: function() {
273-
const metadataTSR = this.__resourceData["quality"]["tsr"];
301+
const metadataTSR = this.__copyResourceData["quality"]["tsr"];
274302
let row = 1;
275303
Object.values(metadataTSR).forEach(rule => {
276304
const ruleRating = new osparc.ui.basic.StarsRating();
@@ -505,7 +533,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
505533
appearance: "toolbar-md-button"
506534
});
507535
this.bind("mode", editButton, "visibility", {
508-
converter: value => value === "edit" ? "hidden" : "visible"
536+
converter: value => value === "display" ? "visible" : "excluded"
509537
});
510538
editButton.addListener("execute", () => {
511539
this.setMode("edit");
@@ -515,7 +543,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
515543
appearance: "toolbar-md-button"
516544
});
517545
this.bind("mode", saveButton, "visibility", {
518-
converter: value => value === "edit" ? "visible" : "hidden"
546+
converter: value => value === "edit" ? "visible" : "excluded"
519547
});
520548
saveButton.addListener("execute", e => {
521549
this.__save(saveButton);
@@ -525,15 +553,15 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
525553
appearance: "toolbar-md-button"
526554
});
527555
this.bind("mode", cancelButton, "visibility", {
528-
converter: value => value === "edit" ? "visible" : "hidden"
556+
converter: value => value === "edit" ? "visible" : "excluded"
529557
});
530558
cancelButton.addListener("execute", () => {
531559
this.setMode("display");
532560
}, this);
533561

534562
const buttonsToolbar = new qx.ui.toolbar.ToolBar();
535-
buttonsToolbar.add(editButton);
536563
buttonsToolbar.addSpacer();
564+
buttonsToolbar.add(editButton);
537565
buttonsToolbar.add(saveButton);
538566
buttonsToolbar.add(cancelButton);
539567
this._add(buttonsToolbar);
@@ -543,6 +571,7 @@ qx.Class.define("osparc.component.metadata.QualityEditor", {
543571
const data = {
544572
"quality" : {}
545573
};
574+
data["quality"]["enabled"] = this.__copyResourceData["quality"]["enabled"];
546575
data["quality"]["tsr"] = this.__copyResourceData["quality"]["tsr"];
547576
data["quality"]["annotations"] = this.__copyResourceData["quality"]["annotations"];
548577
if (this.__validate(this.__schema, data["quality"])) {

services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
237237

238238
__getZoomAllButton: function() {
239239
const btn = this.__getZoomBtn("@MaterialIcons/zoom_out_map", this.tr("Zoom All"));
240+
btn.setVisibility("excluded");
240241
btn.addListener("execute", () => {
241242
this.__zoomAll();
242243
}, this);
@@ -594,6 +595,9 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
594595
}, this);
595596

596597
nodeUI.addListener("edgeDragEnd", e => {
598+
if (this.__pointerPos === null) {
599+
return;
600+
}
597601
let data = e.getData();
598602
let dragNodeId = data.nodeId;
599603

services/web/client/source/class/osparc/dashboard/ResourceBrowserBase.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
9595
},
9696

9797
__openQualityEditor: function(resourceData) {
98-
const qualityEditor = new osparc.component.metadata.QualityEditor(resourceData);
99-
const title = resourceData.name + " - " + this.tr("Quality Assessment");
100-
osparc.ui.window.Window.popUpInWindow(qualityEditor, title, 650, 760);
98+
const qualityEditor = osparc.studycard.Utils.openQuality(resourceData);
10199
qualityEditor.addListener("updateStudy", e => {
102100
const updatedStudyData = e.getData();
103101
this._resetStudyItem(updatedStudyData);

services/web/client/source/class/osparc/dashboard/StudyBrowserButtonBase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserButtonBase", {
174174
let maxHeight = this.self().ITEM_HEIGHT - 2*this.self().PADDING;
175175
// eslint-disable-next-line no-underscore-dangle
176176
this._mainLayout._getChildren().forEach(child => {
177-
if (child.getSubcontrolId() !== "icon") {
177+
if (child.getSubcontrolId() !== "icon" && child.getBounds()) {
178178
maxHeight -= (child.getBounds().height + 6);
179179
}
180180
});

services/web/client/source/class/osparc/dashboard/StudyBrowserButtonItem.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserButtonItem", {
436436
},
437437

438438
_applyQuality: function(quality) {
439-
if (quality && "tsr" in quality) {
439+
if (osparc.component.metadata.Quality.isEnabled(quality)) {
440440
const {
441441
score,
442442
maxScore
@@ -542,9 +542,7 @@ qx.Class.define("osparc.dashboard.StudyBrowserButtonItem", {
542542

543543
__openQualityEditor: function() {
544544
const resourceData = this.getResourceData();
545-
const qualityEditor = new osparc.component.metadata.QualityEditor(resourceData);
546-
const title = resourceData.name + " - " + this.tr("Quality Assessment");
547-
osparc.ui.window.Window.popUpInWindow(qualityEditor, title, 650, 760);
545+
const qualityEditor = osparc.studycard.Utils.openQuality(resourceData);
548546
qualityEditor.addListener("updateStudy", e => {
549547
const updatedStudyData = e.getData();
550548
this.fireDataEvent("updateQualityStudy", updatedStudyData);

services/web/client/source/class/osparc/data/model/Study.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ qx.Class.define("osparc.data.model.Study", {
157157
quality: {
158158
check: "Object",
159159
init: {},
160-
nullable: true
160+
nullable: true,
161+
event: "changeQuality"
161162
},
162163

163164
readOnly: {
@@ -313,20 +314,22 @@ qx.Class.define("osparc.data.model.Study", {
313314
...params
314315
})
315316
.then(data => {
316-
// TODO OM: Hacky
317-
if ("dev" in data) {
318-
delete data["dev"];
319-
}
320-
this.set({
321-
...data,
322-
creationDate: new Date(data.creationDate),
323-
lastChangeDate: new Date(data.lastChangeDate),
324-
workbench: this.getWorkbench(),
325-
ui: this.getUi(),
326-
sweeper: this.getSweeper()
327-
});
328-
return data;
317+
this.updateModel(data);
329318
});
319+
},
320+
321+
updateModel: function(data) {
322+
if ("dev" in data) {
323+
delete data["dev"];
324+
}
325+
this.set({
326+
...data,
327+
creationDate: new Date(data.creationDate),
328+
lastChangeDate: new Date(data.lastChangeDate),
329+
workbench: this.getWorkbench(),
330+
ui: this.getUi(),
331+
sweeper: this.getSweeper()
332+
});
330333
}
331334
}
332335
});

services/web/client/source/class/osparc/studycard/Large.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ qx.Class.define("osparc.studycard.Large", {
2626
this.base(arguments);
2727

2828
this.set({
29+
minHeight: 350,
2930
padding: this.self().PADDING
3031
});
3132
this._setLayout(new qx.ui.layout.VBox(8));
3233

33-
if (studyData && studyData instanceof Object) {
34+
if (studyData instanceof Object) {
3435
this.__studyData = osparc.data.model.Study.deepCloneStudyObject(studyData);
3536
}
3637

@@ -190,16 +191,20 @@ qx.Class.define("osparc.studycard.Large", {
190191
callback: this.__openClassifiers,
191192
ctx: this
192193
} : null
193-
}, {
194-
label: this.tr("Quality"),
195-
view: this.__createQuality(),
196-
action: {
197-
button: osparc.utils.Utils.getViewButton(),
198-
callback: this.__openQuality,
199-
ctx: this
200-
}
201194
}];
202195

196+
if ("quality" in this.__studyData && osparc.component.metadata.Quality.isEnabled(this.__studyData["quality"])) {
197+
extraInfo.push({
198+
label: this.tr("Quality"),
199+
view: this.__createQuality(),
200+
action: {
201+
button: osparc.utils.Utils.getViewButton(),
202+
callback: this.__openQuality,
203+
ctx: this
204+
}
205+
});
206+
}
207+
203208
if (osparc.data.Permissions.getInstance().isTester()) {
204209
extraInfo.unshift({
205210
label: this.tr("UUID"),

0 commit comments

Comments
 (0)