Skip to content

Commit ab2c4f6

Browse files
committed
filter and sort buttons
1 parent 32eff5f commit ab2c4f6

File tree

3 files changed

+121
-1
lines changed

3 files changed

+121
-1
lines changed

services/static-webserver/client/source/class/osparc/dashboard/SortedByMenuButton.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ qx.Class.define("osparc.dashboard.SortedByMenuButton", {
6565
field: "last_change_date",
6666
direction: "desc"
6767
},
68+
6869
getSortByOptions: function() {
6970
return [{
7071
id: "name",
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2022 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
qx.Class.define("osparc.vipStore.SortModelsButtons", {
19+
extend: qx.ui.form.MenuButton,
20+
21+
construct: function() {
22+
this.base(arguments, this.tr("Sort"), "@FontAwesome5Solid/chevron-down/10");
23+
24+
this.set({
25+
iconPosition: "left",
26+
marginRight: 8
27+
});
28+
29+
const sortByMenu = new qx.ui.menu.Menu().set({
30+
font: "text-14"
31+
});
32+
this.setMenu(sortByMenu);
33+
34+
const nameAsc = new qx.ui.menu.Button().set({
35+
label: this.tr("Name"),
36+
icon: "@FontAwesome5Solid/sort-alpha-down/14"
37+
});
38+
nameAsc["sortBy"] = "name";
39+
nameAsc["orderBy"] = "down";
40+
const nameDesc = new qx.ui.menu.Button().set({
41+
label: this.tr("Name"),
42+
icon: "@FontAwesome5Solid/sort-alpha-up/14"
43+
});
44+
nameDesc["sortBy"] = "name";
45+
nameDesc["orderBy"] = "up";
46+
47+
const dateDesc = new qx.ui.menu.Button().set({
48+
label: this.tr("Date"),
49+
icon: "@FontAwesome5Solid/arrow-down/14"
50+
});
51+
dateDesc["sortBy"] = "date";
52+
dateDesc["orderBy"] = "down";
53+
const dateAsc = new qx.ui.menu.Button().set({
54+
label: this.tr("Date"),
55+
icon: "@FontAwesome5Solid/arrow-up/14"
56+
});
57+
dateAsc["sortBy"] = "date";
58+
dateAsc["orderBy"] = "down";
59+
60+
[
61+
nameAsc,
62+
nameDesc,
63+
dateDesc,
64+
dateAsc,
65+
].forEach((btn, idx) => {
66+
sortByMenu.add(btn);
67+
68+
btn.addListener("execute", () => this.__buttonExecuted(btn));
69+
70+
if (idx === 0) {
71+
btn.execute();
72+
}
73+
});
74+
},
75+
76+
events: {
77+
"sortBy": "qx.event.type.Data"
78+
},
79+
80+
statics: {
81+
DefaultSorting: {
82+
"sort": "name",
83+
"order": "down"
84+
}
85+
},
86+
87+
members: {
88+
__buttonExecuted: function(btn) {
89+
this.set({
90+
label: btn.getLabel(),
91+
icon: btn.getIcon()
92+
});
93+
94+
const data = {
95+
"sort": btn["sortBy"],
96+
"order": btn["orderBy"]
97+
};
98+
this.fireDataEvent("sortBy", data);
99+
}
100+
}
101+
});

services/static-webserver/client/source/class/osparc/vipStore/VIPStore.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,25 @@ qx.Class.define("osparc.vipStore.VIPStore", {
5959

6060
__buildLayout: async function() {
6161
const toolbarLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10)).set({
62-
maxHeight: 30
62+
alignY: "middle",
63+
// maxHeight: 30
6364
});
6465
this._add(toolbarLayout);
6566

67+
const sortModelsButtons = new osparc.vipStore.SortModelsButtons().set({
68+
alignY: "bottom",
69+
maxHeight: 27,
70+
});
71+
toolbarLayout.add(sortModelsButtons);
72+
73+
const filter = new osparc.filter.TextFilter("name", "vipModels").set({
74+
alignY: "middle",
75+
allowGrowY: false,
76+
minWidth: 200,
77+
});
78+
this.addListener("appear", () => filter.getChildControl("textfield").focus());
79+
toolbarLayout.add(filter);
80+
6681
const modelsLayout = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
6782
this._add(modelsLayout, {
6883
flex: 1
@@ -86,6 +101,9 @@ qx.Class.define("osparc.vipStore.VIPStore", {
86101
ctrl.bindProperty("name", "name", null, item, id);
87102
ctrl.bindProperty("date", "date", null, item, id);
88103
},
104+
configureItem: item => {
105+
item.subscribeToFilterGroup("vipModels");
106+
},
89107
});
90108

91109
const loadingModel = {

0 commit comments

Comments
 (0)