Skip to content

Commit b87d6fb

Browse files
committed
Fix id type to string
1 parent 1997bb0 commit b87d6fb

17 files changed

+204
-183
lines changed

src/app/app.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { BrowserModule } from '@angular/platform-browser';
33
import { NgModule } from '@angular/core';
44
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
55
import { HttpClientModule } from '@angular/common/http';
6-
import { AppRoutingModule } from './app-routing.module';
76

7+
import { AppRoutingModule } from './app-routing.module';
88
import { AppComponent } from './app.component';
99
import { NavbarComponent } from './components/shared/navbar/navbar.component';
1010
import { UserComponent } from './components/shared/user/user.component';
1111
import { SidebarComponent } from './components/shared/sidebar/sidebar.component';
1212
import { ClockComponent } from './components/shared/clock/clock.component';
1313
import { TimeClockComponent } from './components/options-sidebar/time-clock/time-clock.component';
1414
import { ProjectManagementComponent } from './components/options-sidebar/project-management/project-management.component';
15-
import { TimeEntriesComponent } from "./components/options-sidebar/time-entries/time-entries.component";
15+
import { TimeEntriesComponent } from './components/options-sidebar/time-entries/time-entries.component';
1616
import { ProjectListComponent } from './components/shared/project-list/project-list.component';
1717
import { CreateProjectComponent } from './components/shared/create-project/create-project.component';
1818
import { DetailsFieldsComponent } from './components/shared/details-fields/details-fields.component';
@@ -54,4 +54,4 @@ import { GroupByDatePipe } from './components/shared/pipes/group-by-date/group-b
5454
providers: [],
5555
bootstrap: [AppComponent]
5656
})
57-
export class AppModule {}
57+
export class AppModule { }

src/app/components/options-sidebar/project-management/project-management.component.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
2+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
3+
24
import { ProjectManagementComponent } from './project-management.component';
3-
import { Project } from '../../../interfaces/project';
5+
import { Project } from '../../../interfaces';
46
import { ProjectService } from '../../../services/project.service';
57
import { of } from 'rxjs';
68
import { CreateProjectComponent } from '../../../components/shared/create-project/create-project.component';
79
import { ProjectListComponent } from '../../../components/shared/project-list/project-list.component';
8-
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
910

1011
describe('ProjectManagementComponent', () => {
1112
let component: ProjectManagementComponent;
1213
let fixture: ComponentFixture<ProjectManagementComponent>;
1314
let projectService: ProjectService;
1415

1516
const projects: Project[] = [{
16-
id: 1,
17+
id: '1',
1718
name: 'app 1',
1819
details: 'It is a good app',
1920
status: 'inactive',
2021
completed: true
2122
},
2223
{
23-
id: 2,
24+
id: '2',
2425
name: 'app 2',
2526
details: 'It is a good app',
2627
status: 'inactive',
2728
completed: false
2829
},
2930
{
30-
id: 3,
31+
id: '3',
3132
name: 'app 3',
3233
details: 'It is a good app',
3334
status: 'active',
@@ -89,14 +90,14 @@ describe('ProjectManagementComponent', () => {
8990

9091
it('should edit a project #updateProject', () => {
9192
const project = {
92-
id: 1,
93+
id: '1',
9394
name: 'app test',
9495
details: 'It is a excelent app',
9596
status: 'inactive',
9697
completed: true
9798
};
9899

99-
component.editedProjectId = 1;
100+
component.editedProjectId = '1';
100101
component.updateProject(project);
101102
expect(component.projects.length).toEqual(3);
102103
expect(component.projects[0].name).toBe('app test');
@@ -106,14 +107,14 @@ describe('ProjectManagementComponent', () => {
106107
});
107108

108109
it('should filter the project to edit #editProject', () => {
109-
const editProjectId = 2;
110+
const editProjectId = '2';
110111
component.editProject(editProjectId);
111112
expect(component.project.name).toBe('app 2');
112113
});
113114

114115
it('should clean the project #cancelForm', () => {
115116
const project = {
116-
id: 1,
117+
id: '1',
117118
name: 'app 1',
118119
details: 'It is a good app',
119120
status: 'inactive',
@@ -149,7 +150,7 @@ describe('ProjectManagementComponent', () => {
149150
}));
150151

151152
it('should delete a project #deleteProject', () => {
152-
const projectId = 1;
153+
const projectId = '1';
153154

154155
component.deleteProject(projectId);
155156
expect(component.projects.length).toEqual(2);

src/app/components/options-sidebar/project-management/project-management.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { Project } from '../../../interfaces/project';
2+
import { Project } from '../../../interfaces';
33
import { ProjectService } from '../../../services/project.service';
44

55
@Component({
@@ -30,7 +30,7 @@ export class ProjectManagementComponent implements OnInit {
3030
this.projects[projectIndex].status = projectData.status;
3131
this.projects[projectIndex].completed = projectData.completed;
3232
} else {
33-
const newProject: Project = { id: this.projects.length + 1, name: projectData.name,
33+
const newProject: Project = { id: (this.projects.length + 1).toString(), name: projectData.name,
3434
details: projectData.details, status: projectData.status, completed: false
3535
};
3636
this.projects = this.projects.concat(newProject);
Lines changed: 83 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,91 @@
11
<div class="text-center mt-3">
22

3-
<div *ngIf="showAlertEnterTecnology" class="alert alert-danger" role="alert">
4-
Field technology is requiered. Enter this field for clock out.
5-
</div>
3+
<div *ngIf="showAlertEnterTecnology" class="alert alert-danger" role="alert">
4+
Field technology is requiered. Enter this field for clock out.
5+
</div>
66

7-
<div class="card">
8-
<div class="card-header">
9-
<div class="row">
10-
<div class="col-2 text-left">
11-
<strong>Time clock</strong>
12-
</div>
13-
<div class="col-10 text-right">
14-
<i class="far fa-question-circle"></i>
15-
</div>
16-
</div>
7+
<div class="card">
8+
<div class="card-header">
9+
<div class="row">
10+
<div class="col-2 text-left">
11+
<strong>Time clock</strong>
12+
</div>
13+
<div class="col-10 text-right">
14+
<i class="far fa-question-circle"></i>
1715
</div>
16+
</div>
17+
</div>
1818

19-
<div class="card-body">
20-
<p *ngIf="!isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong class="text-success">in</strong> at <strong>{{ clockInUsername }}</strong></p>
21-
<p *ngIf="isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong class="text-danger">out</strong> at <strong>{{ clockOutUsername }}</strong></p>
22-
<h6 class="text-left"><strong>Totals</strong></h6>
23-
<hr>
24-
<div class="row">
25-
<div class="col-4">
26-
<h6>Current</h6>
27-
<h3>{{ hour | number: '2.0-2' }}:{{ minute | number: '2.0-2' }}:{{ seconds | number: '2.0-2' }}</h3>
28-
</div>
29-
<div class="col-4">
30-
<h6>Day</h6>
31-
<h3>4:22</h3>
32-
</div>
33-
<div class="col-4">
34-
<h6>Week</h6>
35-
<h3>14:00</h3>
36-
</div>
37-
</div>
38-
<h6 class="text-left"><strong>Projects</strong></h6>
39-
<form>
40-
<div class="form-group">
41-
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="&#xF002; Search project" style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome">
42-
</div>
43-
</form>
44-
<p class="text-left"><i class="fas fa-folder"></i><strong> Top</strong></p>
45-
<ul class="list-group">
46-
<app-project-list-hover [projects]="projects" (showFields)="setShowFields($event)"></app-project-list-hover>
47-
</ul>
48-
<br>
49-
<form *ngIf="!isClockIn || showFields">
50-
<div class="form-group row">
51-
<label for="inputActivity" class="col-sm-2 col-form-label text-center"><strong>Activity</strong></label>
52-
<div class="col-sm-10">
53-
<input type="text" class="form-control">
54-
</div>
55-
</div>
56-
<div class="form-group row">
57-
<label for="inputJiraTicket" class="col-sm-2 col-form-label text-center"><strong>Jira Ticket</strong></label>
58-
<div class="col-sm-10">
59-
<input type="text" class="form-control">
60-
</div>
61-
</div>
62-
<div class="form-group row">
63-
<label for="inputTechnology" class="col-sm-2 col-form-label text-center"><strong>Technology</strong></label>
64-
<div class="col-sm-10">
65-
<input #data type="text" (keyup)="enterTechnology(data.value)" class="form-control">
66-
</div>
67-
</div>
68-
</form>
69-
<hr>
70-
<div class="container">
71-
<div class="row">
72-
<div class="col text-left">
73-
<button class="btn btn-light btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
74-
Options
75-
</button>
76-
</div>
77-
<div class="col text-right">
78-
<button *ngIf="isClockIn" class="btn btn-success btn-sm" type="button" (click)="employeClockIn()">Clock In</button>
79-
<button *ngIf="!isClockIn" class="btn btn-danger btn-sm" type="button" (click)="employeClockOut()">Clock Out</button>
80-
</div>
81-
</div>
82-
</div>
19+
<div class="card-body">
20+
<p *ngIf="!isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong
21+
class="text-success">in</strong> at <strong>{{ clockInUsername }}</strong></p>
22+
<p *ngIf="isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong
23+
class="text-danger">out</strong> at <strong>{{ clockOutUsername }}</strong></p>
24+
<h6 class="text-left"><strong>Totals</strong></h6>
25+
<hr>
26+
<div class="row">
27+
<div class="col-4">
28+
<h6>Current</h6>
29+
<h3>{{ hour | number: '2.0-2' }}:{{ minute | number: '2.0-2' }}:{{ seconds | number: '2.0-2' }}</h3>
30+
</div>
31+
<div class="col-4">
32+
<h6>Day</h6>
33+
<h3>4:22</h3>
34+
</div>
35+
<div class="col-4">
36+
<h6>Week</h6>
37+
<h3>14:00</h3>
38+
</div>
39+
</div>
40+
<h6 class="text-left"><strong>Projects</strong></h6>
41+
<form>
42+
<div class="form-group">
43+
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="&#xF002; Search project"
44+
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome">
45+
</div>
46+
</form>
47+
<p class="text-left"><i class="fas fa-folder"></i><strong> Top</strong></p>
48+
<ul class="list-group">
49+
<app-project-list-hover [projects]="projects" (showFields)="setShowFields($event)"></app-project-list-hover>
50+
</ul>
51+
<br>
52+
<form *ngIf="!isClockIn || showFields">
53+
<div class="form-group row">
54+
<label for="inputActivity" class="col-sm-2 col-form-label text-center"><strong>Activity</strong></label>
55+
<div class="col-sm-10">
56+
<input type="text" class="form-control">
57+
</div>
58+
</div>
59+
<div class="form-group row">
60+
<label for="inputJiraTicket" class="col-sm-2 col-form-label text-center"><strong>Jira Ticket</strong></label>
61+
<div class="col-sm-10">
62+
<input type="text" class="form-control">
63+
</div>
64+
</div>
65+
<div class="form-group row">
66+
<label for="inputTechnology" class="col-sm-2 col-form-label text-center"><strong>Technology</strong></label>
67+
<div class="col-sm-10">
68+
<input #data type="text" (keyup)="enterTechnology(data.value)" class="form-control">
69+
</div>
70+
</div>
71+
</form>
72+
<hr>
73+
<div class="container">
74+
<div class="row">
75+
<div class="col text-left">
76+
<button class="btn btn-light btn-sm dropdown-toggle" type="button" data-toggle="dropdown"
77+
aria-haspopup="true" aria-expanded="false">
78+
Options
79+
</button>
80+
</div>
81+
<div class="col text-right">
82+
<button *ngIf="isClockIn" class="btn btn-success btn-sm" type="button" (click)="employeClockIn()">Clock
83+
In</button>
84+
<button *ngIf="!isClockIn" class="btn btn-danger btn-sm" type="button" (click)="employeClockOut()">Clock
85+
Out</button>
86+
</div>
8387
</div>
88+
</div>
8489
</div>
90+
</div>
8591
</div>

src/app/components/options-sidebar/time-entries/time-entries.component.spec.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
23

34
import { TimeEntriesComponent } from './time-entries.component';
45
import { GroupByDatePipe } from '../../shared/pipes/group-by-date/group-by-date.pipe';
6+
import { MonthPickerComponent } from '../../shared/month-picker/month-picker.component';
7+
import { DetailsFieldsComponent } from '../../shared/details-fields/details-fields.component';
8+
import { EmptyStateComponent } from '../../shared/empty-state/empty-state.component';
9+
import { ModalComponent } from '../../shared/modal/modal.component';
510

611
describe('TimeEntriesComponent', () => {
712
let component: TimeEntriesComponent;
813
let fixture: ComponentFixture<TimeEntriesComponent>;
914
const entry = {
10-
id: "entry_1",
11-
project: "Mido - 05 de Febrero",
12-
startDate: "2020-02-05T15:36:15.887Z",
13-
endDate: "2020-02-05T18:36:15.887Z",
14-
activity: "development",
15-
technology: "Angular, TypeScript",
16-
comments: "No comments",
17-
ticket: "EY-25"
15+
id: 'entry_1',
16+
project: 'Mido - 05 de Febrero',
17+
startDate: '2020-02-05T15:36:15.887Z',
18+
endDate: '2020-02-05T18:36:15.887Z',
19+
activity: 'development',
20+
technology: 'Angular, TypeScript',
21+
comments: 'No comments',
22+
ticket: 'EY-25'
1823
};
1924

2025
function setup() {
@@ -26,7 +31,18 @@ describe('TimeEntriesComponent', () => {
2631

2732
beforeEach(async(() => {
2833
TestBed.configureTestingModule({
29-
declarations: [ TimeEntriesComponent, GroupByDatePipe ]
34+
declarations: [
35+
EmptyStateComponent,
36+
DetailsFieldsComponent,
37+
GroupByDatePipe,
38+
ModalComponent,
39+
MonthPickerComponent,
40+
TimeEntriesComponent
41+
],
42+
imports: [
43+
FormsModule,
44+
ReactiveFormsModule
45+
]
3046
})
3147
.compileComponents();
3248
}));
@@ -41,16 +57,16 @@ describe('TimeEntriesComponent', () => {
4157
expect(component).toBeTruthy();
4258
});
4359

44-
/* it('should have p tag as \'time-entries works!\'', async(() => {
60+
it('should have p tag as \'time-entries works!\'', async(() => {
4561
// tslint:disable-next-line: no-shadowed-variable
4662
const { app, fixture } = setup();
4763
fixture.detectChanges();
4864
const compile = fixture.debugElement.nativeElement;
4965
const ptag = compile.querySelector('p');
5066
expect(ptag.textContent).toBe('time-entries works!');
51-
})); */
67+
}));
5268

53-
it('should call filter entry', async(() => {
69+
it('should call dataByMonth in ngOnInit()', async(() => {
5470
component.ngOnInit();
5571
expect(component.dataByMonth.length).toEqual(3);
5672
}));

0 commit comments

Comments
 (0)