Skip to content

Commit 26554fb

Browse files
committed
added validations in form
1 parent e0ed4b8 commit 26554fb

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<div class="text-center mt-3">
2+
<div *ngIf="showAlertEnterTecnology" class="alert alert-danger" role="alert">
3+
Field technology is requiered. Enter this field for clock out.
4+
</div>
5+
26
<div class="card">
37
<div class="card-header">
48
<div class="row">
@@ -12,7 +16,8 @@
1216
</div>
1317

1418
<div class="card-body">
15-
<p class="card-title text-left"><strong>Dario</strong> clocked out at <strong>hh:mm:ss</strong></p>
19+
<p *ngIf="!isClockIn" class="card-title text-left"><strong>Dario</strong> clocked <strong class="text-success">in</strong> at <strong>hh:mm:ss</strong></p>
20+
<p *ngIf="isClockIn" class="card-title text-left"><strong>Dario</strong> clocked <strong class="text-danger">out</strong> at <strong>hh:mm:ss</strong></p>
1621
<h6 class="text-left"><strong>Totals</strong></h6>
1722
<hr>
1823
<div class="row">
@@ -68,7 +73,7 @@ <h6 class="text-left"><strong>Projects</strong></h6>
6873
<div class="form-group row">
6974
<label for="inputTechnology" class="col-sm-2 col-form-label text-center"><strong>Technology</strong></label>
7075
<div class="col-sm-10">
71-
<input type="text" class="form-control">
76+
<input #data type="text" (keyup)="enterTechnology(data.value)" class="form-control">
7277
</div>
7378
</div>
7479
</form>
@@ -82,7 +87,7 @@ <h6 class="text-left"><strong>Projects</strong></h6>
8287
</div>
8388
<div class="col text-right">
8489
<button *ngIf="isClockIn" class="btn btn-success btn-sm" type="button" (click)="employeClockIn()">Clock In</button>
85-
<button *ngIf="!isClockIn" class="btn btn-danger btn-sm" type="button" (click)="employeClockIn()">Clock Out</button>
90+
<button *ngIf="!isClockIn" class="btn btn-danger btn-sm" type="button" (click)="employeClockOut()">Clock Out</button>
8691
</div>
8792
</div>
8893
</div>

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,34 @@ import { Component, OnInit } from '@angular/core';
88
export class TimeClockComponent {
99

1010
isClockIn: boolean;
11+
isEnterTechnology: boolean;
12+
showAlertEnterTecnology: boolean;
1113

1214
constructor() {
1315
this.isClockIn = true;
16+
this.isEnterTechnology = false;
1417
}
1518

1619
employeClockIn(): boolean {
1720
this.isClockIn = !this.isClockIn;
18-
console.log('valor es' + this.isClockIn);
1921
return this.isClockIn;
2022
}
23+
24+
employeClockOut() {
25+
if ( this.isEnterTechnology === false ) {
26+
this.isClockIn = false;
27+
this.showAlertEnterTecnology = true;
28+
} else {
29+
this.isClockIn = true;
30+
this.showAlertEnterTecnology = false;
31+
}
32+
}
33+
34+
enterTechnology(data: string) {
35+
if ( data.length > 0 ) {
36+
this.isEnterTechnology = true;
37+
} else {
38+
this.isEnterTechnology = false;
39+
}
40+
}
2141
}

0 commit comments

Comments
 (0)