@@ -54,19 +54,8 @@ qx.Class.define("osparc.dashboard.SortedByMenuButton", {
5454 } ) ;
5555 } ) ;
5656
57- this . addListener ( "changeSortField" , e => {
58- const sort = {
59- field : e . getData ( ) ,
60- direction : true
61- }
62- this . __handelSortEvent ( sort )
63- } , this ) ;
64-
65- this . addListener ( "changeSortDirection" , e => {
66- const sort = {
67- field : this . getSortField ( ) ,
68- direction : e . getData ( )
69- }
57+ this . addListener ( "changeSort" , e => {
58+ const sort = e . getData ( ) ;
7059 this . __handelSortEvent ( sort )
7160 } , this ) ;
7261 } ,
@@ -98,19 +87,15 @@ qx.Class.define("osparc.dashboard.SortedByMenuButton", {
9887 } ,
9988
10089 properties : {
101- sortField : {
102- check : "String" ,
103- init : "last_change_date" ,
104- nullable : true ,
105- event : "changeSortField" ,
106- apply : "__applySortField"
107- } ,
108- sortDirection : {
109- check : "Boolean" ,
110- init : true ,
111- nullable : true ,
112- event : "changeSortDirection" ,
113- apply : "__applySortDirection"
90+ sort : {
91+ check : "Object" ,
92+ init : {
93+ field : "last_change_date" ,
94+ direction : true
95+ } ,
96+ nullable : false ,
97+ event : "changeSort" ,
98+ apply : "__applySort"
11499 }
115100 } ,
116101
@@ -133,28 +118,31 @@ qx.Class.define("osparc.dashboard.SortedByMenuButton", {
133118 } ,
134119
135120 __handelSort : function ( field ) {
136- if ( field === this . getSortField ( ) ) {
137- const direction = ! this . getSortDirection ( ) ;
138- this . setSortDirection ( direction )
121+ if ( field === this . getSort ( ) . field ) {
122+ const { direction } = this . getSort ( ) ;
123+ this . setSort ( {
124+ field,
125+ direction : ! direction
126+ } )
139127 return ;
140128 }
141- this . setSortField ( field )
129+ this . setSort ( {
130+ field,
131+ direction : true
132+ } )
142133 } ,
143134
144135 __handelSortEvent : function ( { field, direction} ) {
145136 this . __menuButton . setIcon ( direction ? "@FontAwesome5Solid/arrow-down/14" : "@FontAwesome5Solid/arrow-up/14" )
137+ this . setIcon ( direction ? "@FontAwesome5Solid/arrow-down/14" : "@FontAwesome5Solid/arrow-up/14" )
146138 const sort = {
147139 field : field ,
148140 direction : direction ? "desc" : "asc"
149141 } ;
150142 this . fireDataEvent ( "sortByChanged" , sort ) ;
151143 } ,
152144
153- __applySortField : function ( value , old ) {
154-
155- } ,
156-
157- __applySortDirection : function ( value , old ) {
145+ __applySort : function ( value , old ) {
158146
159147 }
160148 }
0 commit comments