1717 variant ="outline-dark" )
1818 icon( name ="arrow-left" )
1919 b-select.px-2 ( :value ="periodLength" , :options ="['day', 'week', 'month']" ,
20- @change ="(periodLength) => setDate(date , periodLength)" )
20+ @change ="(periodLength) => setDate(_date , periodLength)" )
2121 b-input-group-append
2222 b-button.px-2 ( :to ="link_prefix + '/' + nextPeriod() + '/' + subview" ,
2323 :disabled ="nextPeriod() > today" , variant ="outline-dark" )
2424 icon( name ="arrow-right" )
2525
2626 div.mx-2 ( v-if ="periodLength === 'day'" )
27- input.form-control.px-2 ( id ="date" type ="date" : value= "date " : max= "today"
27+ input.form-control.px-2 ( id ="date" type ="date" : value= "_date " : max= "today"
2828 @change ="setDate($event.target.value, periodLength)" )
2929
3030 div.ml-auto
@@ -116,7 +116,11 @@ export default {
116116 host: String ,
117117 date: {
118118 type: String ,
119- default: get_today (),
119+ // NOTE: This does not work as you'd might expect since the default is set on
120+ // initialization, which would lead to the same date always being returned,
121+ // even if the day has changed.
122+ // Instead, use the computed _date.
123+ // default: get_today(),
120124 },
121125 periodLength: {
122126 type: String ,
@@ -130,6 +134,9 @@ export default {
130134 };
131135 },
132136 computed: {
137+ _date : function () {
138+ return this .date || get_today ();
139+ },
133140 subview : function () {
134141 return this .$route .meta .subview ;
135142 },
@@ -144,7 +151,6 @@ export default {
144151 ].concat (entries);
145152 },
146153 filterCategories : function () {
147- // TODO: Also return all child categories
148154 if (this .filterCategory ) {
149155 const cats = this .$store .getters [' settings/all_categories' ];
150156 const isChild = p => c => c .length > p .length && _ .isEqual (p, c .slice (0 , p .length ));
@@ -161,8 +167,7 @@ export default {
161167 return this .$store .getters [' activity/getActiveHistoryAroundTimeperiod' ](this .timeperiod );
162168 },
163169 timeperiod : function () {
164- // TODO: Get start of day/week/month (depending on periodLength) with offset
165- return { start: get_day_start_with_offset (this .date ), length: [1 , this .periodLength ] };
170+ return { start: get_day_start_with_offset (this ._date ), length: [1 , this .periodLength ] };
166171 },
167172 dateformat : function () {
168173 if (this .periodLength === ' day' ) {
@@ -200,12 +205,12 @@ export default {
200205
201206 methods: {
202207 previousPeriod : function () {
203- return moment (this .date )
208+ return moment (this ._date )
204209 .subtract (1 , ` ${ this .periodLength } s` )
205210 .format (' YYYY-MM-DD' );
206211 },
207212 nextPeriod : function () {
208- return moment (this .date )
213+ return moment (this ._date )
209214 .add (1 , ` ${ this .periodLength } s` )
210215 .format (' YYYY-MM-DD' );
211216 },
0 commit comments