Skip to content

Commit 03b0519

Browse files
committed
#3 search active projects in view timeClockIn
1 parent 9505c1b commit 03b0519

File tree

8 files changed

+23
-40
lines changed

8 files changed

+23
-40
lines changed

src/app/modules/project-management/components/project-list/project-list.component.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { ProjectListComponent } from './project-list.component';
4+
import { FilterProjectPipe } from 'src/app/modules/shared/pipes/filter-project/filter-project.pipe';
45

56
describe('ProjectListComponent', () => {
67
let component: ProjectListComponent;
78
let fixture: ComponentFixture<ProjectListComponent>;
89

910
beforeEach(async(() => {
1011
TestBed.configureTestingModule({
11-
declarations: [ ProjectListComponent ]
12+
declarations: [ProjectListComponent, FilterProjectPipe]
1213
})
13-
.compileComponents();
14+
.compileComponents();
1415
}));
1516

1617
beforeEach(() => {

src/app/modules/project-management/pages/project-management.component.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { CreateProjectComponent, ProjectListComponent } from '../components';
66
import { Project } from '../../shared/models';
77
import { ProjectManagementComponent } from './project-management.component';
88
import { ProjectService } from '../services/project.service';
9+
import { FilterProjectPipe } from '../../shared/pipes/filter-project/filter-project.pipe';
910

1011
describe('ProjectManagementComponent', () => {
1112
let component: ProjectManagementComponent;
@@ -44,14 +45,14 @@ describe('ProjectManagementComponent', () => {
4445

4546
beforeEach(async(() => {
4647
TestBed.configureTestingModule({
47-
declarations: [ ProjectManagementComponent, CreateProjectComponent, ProjectListComponent ],
48-
providers: [ { provide: ProjectService, useValue: projectServiceStub }],
48+
declarations: [ProjectManagementComponent, CreateProjectComponent, ProjectListComponent, FilterProjectPipe],
49+
providers: [{ provide: ProjectService, useValue: projectServiceStub }],
4950
imports: [
5051
FormsModule,
5152
ReactiveFormsModule
5253
]
5354
})
54-
.compileComponents();
55+
.compileComponents();
5556
}));
5657

5758
beforeEach(() => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div class="form-group">
2-
<input (keyup)="changeFilterValue()" type="text" class="form-control" placeholder="&#xF002; Search active projects..." name="filterProject" [(ngModel)]="filterProject" style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome">
2+
<input (keyup)="changeFilterValue()" type="text" class="form-control" placeholder="&#xF002; Search projects..." name="filterProject" [(ngModel)]="filterProject" style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome">
33
</div>

src/app/modules/shared/pipes/filter-project/filter-project.pipe.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,13 @@ import { Project } from 'src/app/modules/shared/models/project.model';
77
export class FilterProjectPipe implements PipeTransform {
88

99
transform(value: Project[] = [], arg: string): string[] {
10-
1110
const restultProjects = [];
1211
// tslint:disable-next-line: prefer-for-of
1312
for (let i = 0; i < value.length; i++) {
1413
if (value[i].name.toLowerCase().indexOf(arg.toLowerCase()) > -1) {
15-
if (arg.length < 1) {
16-
restultProjects.push(value[i]);
17-
} else if (value[i].status === 'Active') {
18-
restultProjects.push(value[i]);
19-
}
14+
restultProjects.push(value[i]);
2015
}
2116
}
22-
console.log(restultProjects.length);
2317
return restultProjects;
2418
}
2519

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1+
<app-search-project (changeFilterProject)="filterProjects = $event"></app-search-project>
12
<ul class="list-group content-projects">
2-
<li
3-
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"
4-
*ngFor="let item of projects; let i = index"
5-
(mouseenter)="showButton = i"
6-
(mouseleave)="showButton = -1"
7-
(click)="clockIn(item.id)"
8-
[ngClass]="{ active: selectedId === item.id }"
9-
>
3+
<li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center" *ngFor="let item of projects | filterProject:filterProjects; let i = index" (mouseenter)="showButton = i" (mouseleave)="showButton = -1" (click)="clockIn(item.id)" [ngClass]="{ active: selectedId === item.id }">
104
{{ item.name }}
11-
<span
12-
*ngIf="showButton === i && selectedId !== item.id"
13-
class="badge badge-light"
14-
>Clock In</span
15-
>
5+
<span *ngIf="showButton === i && selectedId !== item.id" class="badge badge-light">Clock In</span>
166
</li>
17-
</ul>
7+
</ul>

src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { ProjectListHoverComponent } from './project-list-hover.component';
4+
import { FilterProjectPipe } from 'src/app/modules/shared/pipes/filter-project/filter-project.pipe';
45

56
describe('ProjectListHoverComponent', () => {
67
let component: ProjectListHoverComponent;
78
let fixture: ComponentFixture<ProjectListHoverComponent>;
89

910
beforeEach(async(() => {
1011
TestBed.configureTestingModule({
11-
declarations: [ProjectListHoverComponent]
12+
declarations: [ProjectListHoverComponent, FilterProjectPipe]
1213
}).compileComponents();
1314
}));
1415

src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ export class ProjectListHoverComponent implements OnInit {
1212
selectedId: string;
1313
showButton: number;
1414

15+
filterProjects: string = '';
16+
1517
constructor() {
1618
this.showButton = -1;
1719
}
1820

19-
ngOnInit(): void {}
21+
ngOnInit(): void { }
2022

2123
clockIn(id: string) {
2224
this.selectedId = id;

src/app/modules/time-clock/pages/time-clock.component.html

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
</div>
1212
</div>
1313
<div class="card-body">
14-
<p *ngIf="!isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong
15-
class="text-success">in</strong> at
14+
<p *ngIf="!isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong class="text-success">in</strong> at
1615
<strong>{{ hour | number: '2.0-2' }}:{{ minute | number: '2.0-2' }}:{{ seconds | number: '2.0-2' }}</strong></p>
17-
<p *ngIf="isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong
18-
class="text-danger">out</strong> at
16+
<p *ngIf="isClockIn" class="card-title text-left"><strong>{{ username }}</strong> clocked <strong class="text-danger">out</strong> at
1917
<strong>{{ hour | number: '2.0-2' }}:{{ minute | number: '2.0-2' }}:{{ seconds | number: '2.0-2' }}</strong></p>
2018
<h6 class="text-left"><strong>Totals</strong></h6>
2119
<hr>
@@ -36,7 +34,6 @@ <h3>00:00</h3>
3634
</div>
3735
</div>
3836
<h6 class="text-left"><strong>Projects</strong></h6>
39-
<p class="text-left"><i class="fas fa-folder"></i><strong> Top</strong></p>
4037
<ul class="list-group">
4138
<app-project-list-hover [projects]="projects" (showFields)="setShowFields($event)"></app-project-list-hover>
4239
</ul>
@@ -57,10 +54,8 @@ <h6 class="text-left"><strong>Projects</strong></h6>
5754
<div class="form-group row">
5855
<label for="inputTechnology" class="col-sm-2 col-form-label text-center"><strong>Technology</strong></label>
5956
<div class="col-sm-10">
60-
<input *ngIf="!showAlertEnterTecnology" #data type="text" (keyup)="enterTechnology(data.value)"
61-
class="form-control">
62-
<input *ngIf="showAlertEnterTecnology" #data type="text" (keyup)="enterTechnology(data.value)"
63-
class="form-control border-danger">
57+
<input *ngIf="!showAlertEnterTecnology" #data type="text" (keyup)="enterTechnology(data.value)" class="form-control">
58+
<input *ngIf="showAlertEnterTecnology" #data type="text" (keyup)="enterTechnology(data.value)" class="form-control border-danger">
6459
<div>
6560
<h6 *ngIf="showAlertEnterTecnology" class="text-danger text-left">Technology field is required. Enter this
6661
field to clock out.</h6>
@@ -72,8 +67,7 @@ <h6 *ngIf="showAlertEnterTecnology" class="text-danger text-left">Technology fie
7267
<div class="container">
7368
<div class="row">
7469
<div class="col text-left" id="optionsContainer">
75-
<button class="btn btn-light btn-sm dropdown-toggle" type="button" data-toggle="dropdown"
76-
aria-haspopup="true" aria-expanded="false">
70+
<button class="btn btn-light btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
7771
Options
7872
</button>
7973
</div>

0 commit comments

Comments
 (0)