diff --git a/src/app/modules/time-entries/pages/time-entries.component.spec.ts b/src/app/modules/time-entries/pages/time-entries.component.spec.ts index 05168742e..e6ae43f6f 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.spec.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.spec.ts @@ -142,7 +142,6 @@ describe('TimeEntriesComponent', () => { component.saveEntry(entryToSave); expect(store.dispatch).toHaveBeenCalledWith(new entryActions.CreateEntry(entryToSave.entry)); - expect(store.dispatch).toHaveBeenCalledWith(new entryActions.LoadEntries(currentMonth, year)); }); it('when creating a new entry, then entryId should be null', () => { diff --git a/src/app/modules/time-entries/pages/time-entries.component.ts b/src/app/modules/time-entries/pages/time-entries.component.ts index 6e86b6067..3c2ef721f 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.ts @@ -28,7 +28,8 @@ export class TimeEntriesComponent implements OnInit, OnDestroy { canMarkEntryAsWIP = true; timeEntriesDataSource$: Observable>; selectedYearAsText: string; - selectedMonthIndex: number; + selectedMonth: number; + selectedYear: number; selectedMonthAsText: string; constructor(private store: Store, private toastrService: ToastrService, private actionsSubject$: ActionsSubject) { @@ -40,7 +41,6 @@ export class TimeEntriesComponent implements OnInit, OnDestroy { } ngOnInit(): void { - this.store.dispatch(new entryActions.LoadEntries(new Date().getMonth() + 1, new Date().getFullYear())); this.loadActiveEntry(); this.entriesSubscription = this.actionsSubject$.pipe( @@ -52,7 +52,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy { ) ).subscribe((action) => { this.loadActiveEntry(); - this.store.dispatch(new entryActions.LoadEntries(this.selectedMonthIndex, new Date().getFullYear())); + this.store.dispatch(new entryActions.LoadEntries(this.selectedMonth, this.selectedYear)); }); } @@ -166,10 +166,11 @@ export class TimeEntriesComponent implements OnInit, OnDestroy { } dateSelected(event: { monthIndex: number; year: number }) { + this.selectedYear = event.year; this.selectedYearAsText = event.year.toString(); - this.selectedMonthIndex = event.monthIndex + 1; + this.selectedMonth = event.monthIndex + 1; this.selectedMonthAsText = moment().month(event.monthIndex).format('MMMM'); - this.store.dispatch(new entryActions.LoadEntries(this.selectedMonthIndex, event.year)); + this.store.dispatch(new entryActions.LoadEntries(this.selectedMonth, this.selectedYear)); } openModal(item: any) {