From 46e3362b628f92887426320992cfb3f40af8d5d7 Mon Sep 17 00:00:00 2001 From: Diego Tinitana Date: Thu, 21 May 2020 15:58:54 -0500 Subject: [PATCH] fix: #278 Include_time-entry_running_on_time-entries_list --- .../details-fields.component.html | 12 +++++---- .../details-fields.component.ts | 25 +++++++++++-------- .../pages/time-entries.component.spec.ts | 2 +- .../pages/time-entries.component.ts | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.html b/src/app/modules/shared/components/details-fields/details-fields.component.html index e5b3c4f11..07c17f7d3 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.html +++ b/src/app/modules/shared/components/details-fields/details-fields.component.html @@ -1,8 +1,8 @@
@@ -35,7 +35,7 @@ class="custom-select" formControlName="activity_id" > - +
End/Date
diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 60903cdc1..7ebc03e63 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -9,19 +9,19 @@ import { ElementRef, Renderer2, } from '@angular/core'; -import {FormBuilder, FormGroup} from '@angular/forms'; -import {Store, select} from '@ngrx/store'; -import {formatDate} from '@angular/common'; - -import {Project, Activity} from '../../models'; -import {ProjectState} from '../../../customer-management/components/projects/components/store/project.reducer'; -import {TechnologyState} from '../../store/technology.reducers'; -import {LoadActivities, ActivityState, allActivities} from '../../../activities-management/store'; -import {getProjects} from '../../../customer-management/components/projects/components/store/project.selectors'; +import { FormBuilder, FormGroup } from '@angular/forms'; +import { Store, select } from '@ngrx/store'; +import { formatDate } from '@angular/common'; + +import { Project, Activity } from '../../models'; +import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer'; +import { TechnologyState } from '../../store/technology.reducers'; +import { LoadActivities, ActivityState, allActivities } from '../../../activities-management/store'; +import { getProjects } from '../../../customer-management/components/projects/components/store/project.selectors'; import * as projectActions from '../../../customer-management/components/projects/components/store/project.actions'; -import {EntryState} from '../../../time-clock/store/entry.reducer'; +import { EntryState } from '../../../time-clock/store/entry.reducer'; import * as entryActions from '../../../time-clock/store/entry.actions'; -import {getUpdateError, getCreateError} from 'src/app/modules/time-clock/store/entry.selectors'; +import { getUpdateError, getCreateError } from 'src/app/modules/time-clock/store/entry.selectors'; type Merged = TechnologyState & ProjectState & ActivityState & EntryState; @Component({ @@ -42,6 +42,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { keyword = 'name'; showlist: boolean; errorDate: boolean; + errorEndDate: boolean; constructor(private formBuilder: FormBuilder, private store: Store, private renderer: Renderer2) { this.entryForm = this.formBuilder.group({ @@ -89,6 +90,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { ngOnChanges(): void { if (this.entryToEdit) { this.selectedTechnologies = this.entryToEdit.technologies; + this.errorEndDate = this.entryToEdit.end_date ? false : true; this.entryForm.setValue({ project_id: this.entryToEdit.project_id, activity_id: this.entryToEdit.activity_id, @@ -156,6 +158,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { close() { this.entryForm.reset(); this.errorDate = false; + this.errorEndDate = false; this.cleanForm(); } 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 98d23604a..a089a2a80 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 @@ -131,7 +131,7 @@ describe('TimeEntriesComponent', () => { }; mockEntriesSelector = store.overrideSelector(allEntries, [newEntry]); component.ngOnInit(); - expect(component.dataByMonth.length).toEqual(0); + expect(component.dataByMonth.length).toEqual(1); })); it('should call dataByMonth without new date in ngOnInit()', async(() => { 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 58d89a25a..a14842949 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.ts @@ -24,7 +24,7 @@ export class TimeEntriesComponent implements OnInit { dataByMonth$.subscribe((response) => { this.entryList = response; this.dataByMonth = this.entryList.reduce((acc: any, entry: any) => { - if (new Date(entry.start_date).getMonth() === new Date().getMonth() && entry.end_date) { + if (new Date(entry.start_date).getMonth() === new Date().getMonth()) { const item = { ...entry }; return [...acc, item]; }