Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
feat: #333 Refreshing data when creating/updating time entries
  • Loading branch information
Juan Gabriel Guzman committed Jun 11, 2020
commit a3907c69be1e206b49cefec12072790292d578f2
16 changes: 8 additions & 8 deletions src/app/modules/time-clock/store/entry.effects.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY} from './../../shared/messages';
import {Injectable} from '@angular/core';
import {ofType, Actions, Effect} from '@ngrx/effects';
import {Action} from '@ngrx/store';
import {of, Observable} from 'rxjs';
import {ToastrService} from 'ngx-toastr';
import {catchError, map, mergeMap} from 'rxjs/operators';
import {EntryService} from '../services/entry.service';
import { INFO_DELETE_SUCCESSFULLY, INFO_SAVED_SUCCESSFULLY } from './../../shared/messages';
import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable, of } from 'rxjs';
import { ToastrService } from 'ngx-toastr';
import { catchError, map, mergeMap } from 'rxjs/operators';
import { EntryService } from '../services/entry.service';
import * as actions from './entry.actions';

@Injectable()
Expand Down
13 changes: 13 additions & 0 deletions src/app/modules/time-entries/pages/time-entries.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,17 @@ describe('TimeEntriesComponent', () => {

expect(component.doSave).toHaveBeenCalledWith(entryToSave);
}));

it('when saving time entries, the time entries should be queried', () => {
const currentMonth = new Date().getMonth() + 1;
const entryToSave = {
project_id: 'project-id'
};
component.activeTimeEntry = null;
spyOn(store, 'dispatch');

component.saveEntry(entryToSave);

expect(store.dispatch).toHaveBeenCalledWith(new entryActions.LoadEntries(currentMonth));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class TimeEntriesComponent implements OnInit {
} else {
this.store.dispatch(new entryActions.CreateEntry(entry));
}
this.store.dispatch(new entryActions.LoadEntries(new Date().getMonth() + 1));
}

removeEntry(entryId: string) {
Expand Down