Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
TT-39 fix:load entries of modified year
  • Loading branch information
Guido Quezada committed Dec 30, 2020
commit 4b433532f31862e8840880314c3201811e52e72a
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
11 changes: 6 additions & 5 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
canMarkEntryAsWIP = true;
timeEntriesDataSource$: Observable<DataSource<Entry>>;
selectedYearAsText: string;
selectedMonthIndex: number;
selectedMonth: number;
selectedYear: number;
selectedMonthAsText: string;

constructor(private store: Store<EntryState>, private toastrService: ToastrService, private actionsSubject$: ActionsSubject) {
Expand All @@ -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(
Expand All @@ -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));
});
}

Expand Down Expand Up @@ -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) {
Expand Down