Skip to content

Commit fbfc6fc

Browse files
authored
πŸ› [Frontend] Fix: Search filter's reset button (ITISFoundation#8182)
1 parent d431ea2 commit fbfc6fc

File tree

5 files changed

+75
-61
lines changed

5 files changed

+75
-61
lines changed

β€Žservices/static-webserver/client/source/class/osparc/dashboard/SearchBarFilter.jsβ€Ž

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
5454
HEIGHT: 36,
5555
BG_COLOR: "input_background",
5656

57+
getInitialFilterData: function() {
58+
return {
59+
tags: [],
60+
classifiers: [],
61+
sharedWith: null,
62+
appType: null,
63+
text: ""
64+
};
65+
},
66+
5767
getSharedWithOptions: function(resourceType) {
5868
if (resourceType === "template") {
5969
resourceType = "tutorial";
@@ -96,7 +106,8 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
96106
},
97107

98108
events: {
99-
"filterChanged": "qx.event.type.Data"
109+
"filterChanged": "qx.event.type.Data",
110+
"resetButtonPressed": "qx.event.type.Event",
100111
},
101112

102113
members: {
@@ -200,7 +211,7 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
200211
textField.addListener("focusout", () => this.__filter(), this);
201212

202213
const resetButton = this.getChildControl("reset-button");
203-
resetButton.addListener("execute", () => this.__resetFilters(), this);
214+
resetButton.addListener("execute", () => this.resetButtonPressed(), this);
204215

205216
osparc.store.Store.getInstance().addListener("changeTags", () => this.__buildFiltersMenu(), this);
206217
},
@@ -359,6 +370,9 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
359370
searchBarFilterExtended.set({
360371
width: bounds.width,
361372
});
373+
searchBarFilterExtended.addListener("resetButtonPressed", () => {
374+
this.resetButtonPressed();
375+
}, this);
362376
return searchBarFilterExtended;
363377
},
364378

@@ -400,19 +414,14 @@ qx.Class.define("osparc.dashboard.SearchBarFilter", {
400414
this.getChildControl("text-field").resetValue();
401415
},
402416

403-
__resetFilters: function() {
417+
resetButtonPressed: function() {
404418
this.resetFilters();
405-
this.__filter();
419+
this._filterChange(this.self().getInitialFilterData());
420+
this.fireEvent("resetButtonPressed");
406421
},
407422

408423
getFilterData: function() {
409-
const filterData = {
410-
tags: [],
411-
classifiers: [],
412-
sharedWith: null,
413-
appType: null,
414-
text: ""
415-
};
424+
const filterData = this.self().getInitialFilterData();
416425
const textFilter = this.getTextFilterValue();
417426
filterData["text"] = textFilter ? textFilter : "";
418427
this.getChildControl("active-filters").getChildren().forEach(chip => {

β€Žservices/static-webserver/client/source/class/osparc/dashboard/SearchBarFilterExtended.jsβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
4444

4545
events: {
4646
"filterChanged": "qx.event.type.Data",
47+
"resetButtonPressed": "qx.event.type.Event",
4748
},
4849

4950
properties: {
@@ -209,6 +210,7 @@ qx.Class.define("osparc.dashboard.SearchBarFilterExtended", {
209210
}, this);
210211

211212
resetButton.addListener("tap", () => {
213+
this.fireEvent("resetButtonPressed");
212214
this.exclude();
213215
});
214216
},

β€Žservices/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.jsβ€Ž

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
10811081
this._searchBarFilter.set({
10821082
showFilterMenu: false,
10831083
});
1084+
this._searchBarFilter.addListener("resetButtonPressed", () => this.__filterChanged());
10841085
const searchBarTextField = this._searchBarFilter.getChildControl("text-field");
10851086
searchBarTextField.set({
10861087
cursor: "pointer",
@@ -1246,57 +1247,61 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
12461247

12471248
this._searchBarFilter.addListener("filterChanged", e => {
12481249
const filterData = e.getData();
1249-
let searchContext = null;
1250-
let backToContext = null;
1251-
switch (this.getCurrentContext()) {
1252-
case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS:
1253-
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS:
1254-
case osparc.dashboard.StudyBrowser.CONTEXT.TRASH:
1255-
if (filterData.text) {
1256-
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS;
1257-
} else {
1258-
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS;
1259-
}
1260-
break;
1261-
case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES:
1262-
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES:
1263-
if (filterData.text) {
1264-
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES;
1265-
} else {
1266-
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES;
1267-
}
1268-
break;
1269-
case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES:
1270-
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES:
1271-
if (filterData.text) {
1272-
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES;
1273-
} else {
1274-
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES;
1275-
}
1276-
break;
1277-
case osparc.dashboard.StudyBrowser.CONTEXT.FUNCTIONS:
1278-
// functions are not searchable yet
1279-
searchContext = null;
1280-
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.FUNCTIONS;
1281-
break;
1282-
default:
1283-
if (filterData.text) {
1284-
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS;
1285-
} else {
1286-
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS;
1287-
}
1288-
break;
1289-
}
1290-
if (searchContext) {
1291-
this._changeContext(searchContext);
1292-
} else if (backToContext) {
1293-
const workspaceId = this.getCurrentWorkspaceId();
1294-
const folderId = this.getCurrentFolderId();
1295-
this._changeContext(backToContext, workspaceId, folderId);
1296-
}
1250+
this.__filterChanged(filterData);
12971251
});
12981252
},
12991253

1254+
__filterChanged: function(filterData) {
1255+
let searchContext = null;
1256+
let backToContext = null;
1257+
switch (this.getCurrentContext()) {
1258+
case osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS:
1259+
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS:
1260+
case osparc.dashboard.StudyBrowser.CONTEXT.TRASH:
1261+
if (filterData && filterData.text) {
1262+
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS;
1263+
} else {
1264+
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS;
1265+
}
1266+
break;
1267+
case osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES:
1268+
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES:
1269+
if (filterData && filterData.text) {
1270+
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_TEMPLATES;
1271+
} else {
1272+
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.TEMPLATES;
1273+
}
1274+
break;
1275+
case osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES:
1276+
case osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES:
1277+
if (filterData && filterData.text) {
1278+
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES;
1279+
} else {
1280+
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES;
1281+
}
1282+
break;
1283+
case osparc.dashboard.StudyBrowser.CONTEXT.FUNCTIONS:
1284+
// functions are not searchable yet
1285+
searchContext = null;
1286+
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.FUNCTIONS;
1287+
break;
1288+
default:
1289+
if (filterData && filterData.text) {
1290+
searchContext = osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PROJECTS;
1291+
} else {
1292+
backToContext = osparc.dashboard.StudyBrowser.CONTEXT.PROJECTS;
1293+
}
1294+
break;
1295+
}
1296+
if (searchContext) {
1297+
this._changeContext(searchContext);
1298+
} else if (backToContext) {
1299+
const workspaceId = this.getCurrentWorkspaceId();
1300+
const folderId = this.getCurrentFolderId();
1301+
this._changeContext(backToContext, workspaceId, folderId);
1302+
}
1303+
},
1304+
13001305
_changeContext: function(context, workspaceId = null, folderId = null) {
13011306
if (
13021307
!context.includes("search") && // load projects if search string changed

β€Žservices/static-webserver/client/source/class/osparc/jobs/JobsButton.jsβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ qx.Class.define("osparc.jobs.JobsButton", {
109109
},
110110

111111
__updateJobsButton: function(isActive) {
112-
isActive = true;
113112
this.getChildControl("icon");
114113
[
115114
this.getChildControl("is-active-icon-outline"),

β€Žservices/static-webserver/client/source/class/osparc/notification/NotificationsButton.jsβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ qx.Class.define("osparc.notification.NotificationsButton", {
101101
notifications.forEach(notification => notification.addListener("changeRead", () => this.__updateButton(), this));
102102

103103
let nUnreadNotifications = notifications.filter(notification => notification.getRead() === false).length;
104-
nUnreadNotifications = 5;
105104
[
106105
this.getChildControl("is-active-icon-outline"),
107106
this.getChildControl("is-active-icon"),

0 commit comments

Comments
Β (0)