Skip to content

Commit 03e8fa1

Browse files
committed
Merge branch 'master' of https://github.com/ioet/time-tracker-ui into Time_Clock-Clock-In
2 parents c34f9fa + ddfad12 commit 03e8fa1

13 files changed

+249
-18
lines changed

src/app/app.module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CommonModule } from '@angular/common';
12
import { BrowserModule } from '@angular/platform-browser';
23
import { NgModule } from '@angular/core';
34
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -13,6 +14,9 @@ import { TimeClockComponent } from './components/options-sidebar/time-clock/time
1314
import { ProjectManagementComponent } from './components/options-sidebar/project-management/project-management.component';
1415
import { ProjectListComponent } from './components/shared/project-list/project-list.component';
1516
import { CreateProjectComponent } from './components/shared/create-project/create-project.component';
17+
import { DetailsFieldsComponent } from './components/shared/details-fields/details-fields.component';
18+
import { ProjectListHoverComponent } from './components/shared/project-list-hover/project-list-hover.component';
19+
1620

1721
@NgModule({
1822
declarations: [
@@ -24,9 +28,13 @@ import { CreateProjectComponent } from './components/shared/create-project/creat
2428
TimeClockComponent,
2529
ProjectManagementComponent,
2630
ProjectListComponent,
27-
CreateProjectComponent
31+
CreateProjectComponent,
32+
TimeClockComponent,
33+
DetailsFieldsComponent,
34+
ProjectListHoverComponent,
2835
],
2936
imports: [
37+
CommonModule,
3038
BrowserModule,
3139
AppRoutingModule,
3240
FormsModule,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.content-ClockIn {
2+
padding: 2.1rem 1rem;
3+
}
4+
5+
.timer {
6+
align-items: center;
7+
display: flex;
8+
height: 100%;
9+
justify-content: center;
10+
}

src/app/components/options-sidebar/time-clock/time-clock.component.html

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,13 @@ <h6 class="text-left"><strong>Projects</strong></h6>
4242
</form>
4343
<p class="text-left"><i class="fas fa-folder"></i><strong> Top</strong></p>
4444
<ul class="list-group">
45-
<li class="list-group-item d-flex justify-content-between align-items-center">
46-
Customer › ernst-and-young
47-
<button type="button" class="btn btn-success btn-sm">Clock In</button>
48-
</li>
49-
<li class="list-group-item d-flex justify-content-between align-items-center">
50-
Customer
51-
<i class="fas fa-chevron-right"></i>
5245

53-
</li>
54-
<li class="list-group-item d-flex justify-content-between align-items-center">
55-
Training
56-
<i class="fas fa-chevron-right"></i>
57-
</li>
46+
<app-project-list-hover [projects]="projects" (showFields)="setShowFields($event)"></app-project-list-hover>
47+
48+
5849
</ul>
5950
<br>
60-
<form *ngIf="!isClockIn">
51+
<form *ngIf="!isClockIn || showFields ">
6152
<div class="form-group row">
6253
<label for="inputActivity" class="col-sm-2 col-form-label text-center"><strong>Activity</strong></label>
6354
<div class="col-sm-10">

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { By } from '@angular/platform-browser';
3+
import { DebugElement } from '@angular/core';
24

35
import { TimeClockComponent } from './time-clock.component';
6+
import { ProjectListHoverComponent } from '../../shared/project-list-hover/project-list-hover.component';
47

58
describe('TimeClockComponent', () => {
69
let component: TimeClockComponent;
710
let fixture: ComponentFixture<TimeClockComponent>;
11+
let de: DebugElement;
812

913
function setup() {
1014
// tslint:disable-next-line: no-shadowed-variable
@@ -15,14 +19,14 @@ describe('TimeClockComponent', () => {
1519

1620
beforeEach(async(() => {
1721
TestBed.configureTestingModule({
18-
declarations: [ TimeClockComponent ]
19-
})
20-
.compileComponents();
22+
declarations: [TimeClockComponent, ProjectListHoverComponent]
23+
}).compileComponents();
2124
}));
2225

2326
beforeEach(() => {
2427
fixture = TestBed.createComponent(TimeClockComponent);
2528
component = fixture.componentInstance;
29+
de = fixture.debugElement;
2630
fixture.detectChanges();
2731
});
2832

@@ -37,6 +41,28 @@ describe('TimeClockComponent', () => {
3741
const compile = fixture.debugElement.nativeElement;
3842
const ptag = compile.querySelector('p');
3943
expect(ptag.textContent).toBe('Dario clocked out at hh:mm:ss');
44+
4045
}));
4146

47+
it('should set showfileds as true', () => {
48+
const show = true;
49+
component.setShowFields(show);
50+
expect(component.showFields).toBe(true);
51+
});
52+
53+
it('should be called the setShowFields event #1', () => {
54+
spyOn(component, 'setShowFields');
55+
const showFields = de.query(By.directive(ProjectListHoverComponent));
56+
const cmp = showFields.componentInstance;
57+
cmp.showFields.emit(true);
58+
expect(component.setShowFields).toHaveBeenCalledWith(true);
59+
});
60+
61+
it('should be called the setShowFields event #2', () => {
62+
spyOn(component, 'setShowFields');
63+
const showFields = de.query(By.directive(ProjectListHoverComponent));
64+
const li = showFields.query(By.css('li'));
65+
li.nativeElement.click();
66+
expect(component.setShowFields).toHaveBeenCalledWith(true);
67+
});
4268
});

src/app/components/options-sidebar/time-clock/time-clock.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { Component, OnInit } from '@angular/core';
55
templateUrl: './time-clock.component.html',
66
styleUrls: ['./time-clock.component.css']
77
})
8-
export class TimeClockComponent {
8+
export class TimeClockComponent implements OnInit {
9+
projects = [
10+
{ id: 'P1', name: 'Project 1' },
11+
{ id: 'P2', name: 'Project 2' },
12+
{ id: 'P3', name: 'Project 3' },
13+
{ id: 'P4', name: 'Project 4' }
14+
];
15+
16+
showFields: boolean;
917

1018
username = 'Dario';
1119
clockInUsername = 'hh:mm:ss';
@@ -43,4 +51,10 @@ export class TimeClockComponent {
4351
this.isEnterTechnology = false;
4452
}
4553
}
54+
55+
setShowFields(show: boolean) {
56+
this.showFields = show;
57+
}
58+
59+
ngOnInit(): void {}
4660
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.span-width {
2+
width: 6rem;
3+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<form>
2+
<div class="input-group input-group-sm mb-3">
3+
<div class="input-group-prepend">
4+
<label class="input-group-text span-width" for="inputGroupSelect01">Activity</label>
5+
</div>
6+
<select class="custom-select" id="inputGroupSelect01">
7+
<option selected>Choose...</option>
8+
<option value="1">One</option>
9+
<option value="2">Two</option>
10+
<option value="3">Three</option>
11+
</select>
12+
</div>
13+
<div class="input-group input-group-sm mb-3">
14+
<div class="input-group-prepend">
15+
<span class="input-group-text span-width" id="inputGroup-sizing-sm"
16+
>Jira Ticket</span
17+
>
18+
</div>
19+
<input
20+
type="text"
21+
class="form-control"
22+
aria-label="Small"
23+
aria-describedby="inputGroup-sizing-sm"
24+
/>
25+
</div>
26+
<div class="input-group input-group-sm mb-3">
27+
<div class="input-group-prepend">
28+
<span class="input-group-text span-width" id="inputGroup-sizing-sm">Technology</span>
29+
</div>
30+
<input
31+
type="text"
32+
class="form-control"
33+
aria-label="Small"
34+
aria-describedby="inputGroup-sizing-sm"
35+
/>
36+
</div>
37+
<div class="form-group">
38+
<label for="NotesTextarea">Notes</label>
39+
<textarea class="form-control" id="NotesTextarea" rows="3"></textarea>
40+
</div>
41+
</form>
42+
<button class="btn btn-danger btn-sm">
43+
Clock Out
44+
</button>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { DetailsFieldsComponent } from './details-fields.component';
4+
5+
describe('DetailsFieldsComponent', () => {
6+
let component: DetailsFieldsComponent;
7+
let fixture: ComponentFixture<DetailsFieldsComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ DetailsFieldsComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(DetailsFieldsComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-details-fields',
5+
templateUrl: './details-fields.component.html',
6+
styleUrls: ['./details-fields.component.css']
7+
})
8+
export class DetailsFieldsComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit(): void {
13+
}
14+
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.content-projects {
2+
max-height: 10rem;
3+
overflow-x: auto;
4+
}
5+
6+
.content-projects > li {
7+
cursor: pointer;
8+
font-size: 0.8rem;
9+
padding: 0.5rem 0.8rem;
10+
}
11+
12+
.button-clockIn {
13+
font-size: 0.7rem;
14+
padding: 0 0.3rem;
15+
}

0 commit comments

Comments
 (0)