@@ -21,11 +21,25 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
2121 members : {
2222 _buildLayout ( ) {
2323 this . _removeAll ( ) ;
24- const defaultFrom = new Date ( )
25- defaultFrom . setMonth ( defaultFrom . getMonth ( ) - 1 )
26- // Range defaults to previous month
24+
25+ // Range defaults: today
26+ const defaultFrom = new Date ( ) ;
27+ const defaultTo = new Date ( ) ;
28+
2729 this . __from = this . __addDateInput ( "From" , defaultFrom ) ;
28- this . __until = this . __addDateInput ( "Until" ) ;
30+ this . __until = this . __addDateInput ( "Until" , defaultTo ) ;
31+
32+ const todayBtn = new qx . ui . form . Button ( "Today" ) . set ( {
33+ allowStretchY : false ,
34+ alignY : "bottom"
35+ } ) ;
36+ todayBtn . addListener ( "execute" , ( ) => {
37+ const today = new Date ( ) ;
38+ this . __from . setValue ( today ) ;
39+ this . __until . setValue ( today ) ;
40+ } ) ;
41+ this . _add ( todayBtn ) ;
42+
2943 const lastWeekBtn = new qx . ui . form . Button ( "Last week" ) . set ( {
3044 allowStretchY : false ,
3145 alignY : "bottom"
@@ -38,6 +52,7 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
3852 this . __until . setValue ( today ) ;
3953 } ) ;
4054 this . _add ( lastWeekBtn ) ;
55+
4156 const lastMonthBtn = new qx . ui . form . Button ( "Last month" ) . set ( {
4257 allowStretchY : false ,
4358 alignY : "bottom"
@@ -50,6 +65,7 @@ qx.Class.define("osparc.desktop.credits.DateFilters", {
5065 this . __until . setValue ( today ) ;
5166 } ) ;
5267 this . _add ( lastMonthBtn ) ;
68+
5369 const lastYearBtn = new qx . ui . form . Button ( "Last year" ) . set ( {
5470 allowStretchY : false ,
5571 alignY : "bottom"
0 commit comments