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
fix: #278 Include_time-entry_running_on_time-entries_list
  • Loading branch information
DiegoTinitana committed May 21, 2020
commit 46e3362b628f92887426320992cfb3f40af8d5d7
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<form [formGroup]="entryForm" (ngSubmit)="onSubmit()">
<script>
$( function() {
$( document ).tooltip();
} );
$(function () {
$(document).tooltip();
});
</script>
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
Expand Down Expand Up @@ -35,7 +35,7 @@
class="custom-select"
formControlName="activity_id"
>
<option value="" selected="selected"></option>
<option value="" selected="selected"></option>
<option *ngFor="let activity of activities" value="{{ activity.id }}">{{ activity.name }}</option>
</select>
<div
Expand Down Expand Up @@ -93,12 +93,14 @@
<span class="input-group-text span-width" id="inputGroup-sizing-sm">End/Date</span>
</div>
<input
data-toggle="tooltip"
title="{{ (end_date.invalid && end_date.touched) || errorEndDate ? 'End hour is required' : '' }}"
formControlName="end_date"
id="end_date"
type="date"
class="form-control"
aria-label="Small"
[class.is-invalid]="end_date.invalid && end_date.touched"
[class.is-invalid]="(end_date.invalid && end_date.touched) || errorEndDate"
required
aria-describedby="inputGroup-sizing-sm"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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<Merged>, private renderer: Renderer2) {
this.entryForm = this.formBuilder.group({
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -156,6 +158,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
close() {
this.entryForm.reset();
this.errorDate = false;
this.errorEndDate = false;
this.cleanForm();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down