Skip to content

Commit 3c61103

Browse files
authored
bugfix: Catalog filter (#2539)
1 parent c89a4d9 commit 3c61103

File tree

4 files changed

+81
-45
lines changed

4 files changed

+81
-45
lines changed

services/web/client/source/class/osparc/component/service/ServiceButtonSmall.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,25 @@ qx.Class.define("osparc.component.service.ServiceButtonSmall", {
8383
allowGrowY: true
8484
});
8585
}
86+
},
87+
88+
_filterText: function(text) {
89+
const checks = [
90+
this.getServiceModel().getName(),
91+
this.getServiceModel().getDescription(),
92+
this.getServiceModel().getContact()
93+
];
94+
return osparc.dashboard.CardBase.filterText(checks, text);
95+
},
96+
97+
_filterTags: function(tags) {
98+
const checks = this.getServiceModel().getTags().map(tag => tag.name);
99+
return osparc.dashboard.CardBase.filterText(checks, tags);
100+
},
101+
102+
_filterClassifiers: function(classifiers) {
103+
const checks = this.getServiceModel().getClassifiers();
104+
return osparc.dashboard.CardBase.filterText(checks, classifiers);
86105
}
87106
}
88107
});

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

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,34 @@ qx.Class.define("osparc.dashboard.CardBase", {
4646
SERVICE_ICON: "@FontAwesome5Solid/paw/",
4747
COMP_SERVICE_ICON: "@FontAwesome5Solid/cogs/",
4848
DYNAMIC_SERVICE_ICON: "@FontAwesome5Solid/mouse-pointer/",
49-
PERM_READ: "@FontAwesome5Solid/eye/14"
49+
PERM_READ: "@FontAwesome5Solid/eye/14",
50+
51+
filterText: function(checks, text) {
52+
if (text && checks.filter(label => label && label.toLowerCase().trim().includes(text)).length == 0) {
53+
return true;
54+
}
55+
return false;
56+
},
57+
58+
filterTags: function(checks, tags) {
59+
if (tags && tags.length) {
60+
const tagNames = checks.map(tag => tag.name);
61+
if (tags.filter(tag => tagNames.includes(tag)).length == 0) {
62+
return true;
63+
}
64+
}
65+
return false;
66+
},
67+
68+
filterClassifiers: function(checks, classifiers) {
69+
if (classifiers && classifiers.length) {
70+
const classes = osparc.utils.Classifiers.getLeafClassifiers(classifiers);
71+
if (classes.filter(clas => checks.includes(clas.data.classifier)).length == 0) {
72+
return true;
73+
}
74+
}
75+
return false;
76+
}
5077
},
5178

5279
properties: {
@@ -300,49 +327,33 @@ qx.Class.define("osparc.dashboard.CardBase", {
300327
this.show();
301328
},
302329

303-
__filterText: function(text) {
304-
if (text) {
305-
const checks = [
306-
this.getTitle(),
307-
this.getDescription(),
308-
this.getOwner()
309-
];
310-
if (checks.filter(label => label.toLowerCase().trim().includes(text)).length == 0) {
311-
return true;
312-
}
313-
}
314-
return false;
330+
_filterText: function(text) {
331+
const checks = [
332+
this.getTitle(),
333+
this.getDescription(),
334+
this.getOwner()
335+
];
336+
return this.self().filterText(checks, text);
315337
},
316338

317-
__filterTags: function(tags) {
318-
if (tags && tags.length) {
319-
const tagNames = this.getTags().map(tag => tag.name);
320-
if (tags.filter(tag => tagNames.includes(tag)).length == 0) {
321-
return true;
322-
}
323-
}
324-
return false;
339+
_filterTags: function(tags) {
340+
const checks = this.getTags().map(tag => tag.name);
341+
return this.self().filterText(checks, tags);
325342
},
326343

327-
__filterClassifiers: function(classifiers) {
328-
if (classifiers && classifiers.length) {
329-
const classes = osparc.utils.Classifiers.getLeafClassifiers(classifiers);
330-
const myClassifiers = this.getClassifiers();
331-
if (classes.filter(clas => myClassifiers.includes(clas.data.classifier)).length == 0) {
332-
return true;
333-
}
334-
}
335-
return false;
344+
_filterClassifiers: function(classifiers) {
345+
const checks = this.getClassifiers();
346+
return this.self().filterText(checks, classifiers);
336347
},
337348

338349
_shouldApplyFilter: function(data) {
339-
if (this.__filterText(data.text)) {
350+
if (this._filterText(data.text)) {
340351
return true;
341352
}
342-
if (this.__filterTags(data.tags)) {
353+
if (this._filterTags(data.tags)) {
343354
return true;
344355
}
345-
if (this.__filterClassifiers(data.classifiers)) {
356+
if (this._filterClassifiers(data.classifiers)) {
346357
return true;
347358
}
348359
return false;

services/web/client/source/class/osparc/ui/tree/CheckboxTreeItem.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ qx.Class.define("osparc.ui.tree.CheckboxTreeItem", {
2828
this.addSpacer();
2929
this.addOpenButton();
3030
this._add(this.getChildControl("checkbox"));
31-
this.addLabel();
31+
const label = this.getChildControl("label");
32+
this._add(label, {
33+
flex: 1
34+
});
3235
this._add(new qx.ui.core.Spacer(), {
3336
flex: 1
3437
});
3538
this.addHint();
39+
40+
this.setMaxWidth(240);
3641
},
3742

3843
_createChildControlImpl: function(id) {

services/web/client/source/class/osparc/ui/tree/MHintInTree.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,28 @@ qx.Mixin.define("osparc.ui.tree.MHintInTree", {
5151
},
5252

5353
__populateInfoButton: function() {
54-
const desc = this.getDescription();
55-
const desc2 = this.getDescription2();
54+
const texts = [];
55+
[
56+
this.getLabel(),
57+
this.getDescription(),
58+
this.getDescription2()
59+
].forEach(text => {
60+
if (text && text !== "") {
61+
texts.push(text);
62+
}
63+
});
5664
const url = this.getUrl();
57-
const hints = [];
58-
if (desc && desc !== "") {
59-
hints.push(desc);
60-
}
61-
if (desc2 && desc2 !== "") {
62-
hints.push(desc2);
63-
}
6465
if (url && url !== "") {
6566
const link = "<a href=" + url + " target='_blank'>More...</a>";
6667
const linkWithRightColor = link.replace(/^<a /, "<a style=\"color:"+ qx.theme.manager.Color.getInstance().getTheme().colors["link"] + "\"");
67-
hints.push(linkWithRightColor);
68+
texts.push(linkWithRightColor);
6869

6970
const themeManager = qx.theme.manager.Meta.getInstance();
7071
themeManager.addListener("changeTheme", () => {
7172
this.__populateInfoButton();
7273
}, this);
7374
}
74-
const hint = hints.join("<br>");
75+
const hint = texts.join("<br>");
7576
this.__infoButton.setHintText(hint);
7677
}
7778
}

0 commit comments

Comments
 (0)