Skip to content

Commit 3e614fd

Browse files
LuisMS7codigodehoy
andauthored
TT-582 Improve the summary section of the time-clock page and the clock out button (#824)
* style: TT-582 improve the summary section with a new row with information of actual clock in register and clock out button * fix: TT-582 add missing unit test to confirm that clockout function in TimeEntriesSummaryComponent emits an event * style: TT-582 add a border radius to current elapsed time box Co-authored-by: David Cadena <[email protected]>
1 parent 482bfb1 commit 3e614fd

File tree

5 files changed

+73
-17
lines changed

5 files changed

+73
-17
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.current-elapsed-time-box{
2+
border-color: #FF5E0A;
3+
border-width: 2px;
4+
background-color: #FF5E0A;
5+
color: white;
6+
border-radius: .25rem;
7+
}
8+
9+
.clock-out{
10+
text-align: center;
11+
}
12+
13+
.bt-clock-out{
14+
background: #00baee;
15+
color: #fff;
16+
padding: 7px 20px;
17+
}
18+
19+
.bt-clock-out:hover{
20+
background: #10a5ce;
21+
box-shadow: 0px 1px 5px 2px rgba(0,0,0,0.56);
22+
-webkit-box-shadow: 0px 1px 5px 2px rgba(0,0,0,0.56);
23+
-moz-box-shadow: 0px 1px 5px 2px rgba(0,0,0,0.56);
24+
color: #fff;
25+
}
Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
1+
<div *ngIf="areFieldsVisible" class="row pb-4">
2+
<div class="col-2 d-flex align-items-center">
3+
<p class="card-title text-left" style="margin: 0; padding: 0;">
4+
You clocked in at
5+
<strong>{{ activeTimeEntry?.start_date | date:'shortTime' }}</strong>
6+
</p>
7+
</div>
8+
<div class="col-2 col-sm-3">
9+
<div class="current-elapsed-time-box d-flex flex-column justify-content-center align-items-center" style="width: 50%">
10+
<h6>Current</h6>
11+
<h3>{{ currentWorkingTime }}</h3>
12+
</div>
13+
</div>
14+
<div class="col-7 clock-out">
15+
<button
16+
class="btn bt-clock-out"
17+
type="button"
18+
(click)="clockOut()">
19+
Clock Out
20+
</button>
21+
</div>
22+
</div>
23+
124
<h6 class="text-left"><strong>Summary</strong></h6>
225
<hr class="mb-4" />
326
<div class ="container px-0">
27+
428
<div class="row pb-4">
5-
<div class="col-12 col-sm-3">
6-
<h6>Current</h6>
7-
<h3>{{ currentWorkingTime }}</h3>
8-
</div>
9-
<div class="col-12 col-sm-3">
29+
<div class="col-12 col-sm-4">
1030
<h6>Day</h6>
1131
<h3>{{ timeEntriesSummary?.day | timeDetails }}</h3>
1232
</div>
13-
<div class="col-12 col-sm-3">
33+
<div class="col-12 col-sm-4">
1434
<h6>Week</h6>
1535
<h3>{{ timeEntriesSummary?.week | timeDetails }}</h3>
1636
</div>
17-
<div class="col-12 col-sm-3">
37+
<div class="col-12 col-sm-4">
1838
<h6>Month</h6>
1939
<h3>{{ timeEntriesSummary?.month | timeDetails }}</h3>
2040
</div>
2141
</div>
42+
2243
</div>

src/app/modules/time-clock/components/time-entries-summary/time-entries-summary.component.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,11 @@ describe('TimeEntriesSummaryComponent', () => {
148148
discardPeriodicTasks();
149149
}));
150150

151+
it('clockOut should emits event', () => {
152+
spyOn(component.clockoutEvent, 'emit');
153+
component.clockOut();
154+
155+
expect(component.clockoutEvent.emit).toHaveBeenCalled();
156+
});
157+
151158
});

src/app/modules/time-clock/components/time-entries-summary/time-entries-summary.component.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { Entry } from './../../../shared/models/entry.model';
55
import { TimeEntriesSummary } from '../../models/time.entry.summary';
66
import { LoadEntriesSummary, LoadActiveEntry, EntryActionTypes } from './../../store/entry.actions';
77
import { EntryState } from './../../store/entry.reducer';
8-
import { Store, ActionsSubject } from '@ngrx/store';
9-
import { Component, OnInit, OnDestroy } from '@angular/core';
8+
import { Store, ActionsSubject, select } from '@ngrx/store';
9+
import { Component, OnInit, OnDestroy, Output, EventEmitter, Input } from '@angular/core';
1010
import * as moment from 'moment';
11+
import { getActiveTimeEntry } from '../../store/entry.selectors';
1112

1213
@Component({
1314
selector: 'app-time-entries-summary',
@@ -16,6 +17,10 @@ import * as moment from 'moment';
1617
})
1718
export class TimeEntriesSummaryComponent implements OnInit, OnDestroy {
1819

20+
@Input() activeTimeEntry: Entry;
21+
@Input() areFieldsVisible = false;
22+
@Output() clockoutEvent = new EventEmitter<void>();
23+
1924
timeEntriesSummary: TimeEntriesSummary;
2025
currentWorkingTime: string;
2126
destroyed$ = new Subject<boolean>();
@@ -103,4 +108,9 @@ export class TimeEntriesSummaryComponent implements OnInit, OnDestroy {
103108
});
104109
}
105110
}
111+
112+
clockOut(): void {
113+
this.clockoutEvent.emit();
114+
}
115+
106116
}
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
<app-time-entries-summary></app-time-entries-summary>
1+
<app-time-entries-summary (clockoutEvent)="clockOut()" [activeTimeEntry]="activeTimeEntry" [areFieldsVisible]="areFieldsVisible"></app-time-entries-summary>
22

33
<div class="col-12 col-md-9 px-0">
44

55
<div class="row pb-4">
66
<div class="col-12">
7-
<p *ngIf="areFieldsVisible" class="card-title text-left">
8-
You clocked in at
9-
<strong>{{ activeTimeEntry?.start_date | date:'shortTime' }}</strong>
10-
</p>
117
<p *ngIf="!areFieldsVisible" class="card-title text-left">
128
Hi <strong>{{ username }}</strong>, please select a project to clock-in.
139
</p>
@@ -19,7 +15,4 @@
1915
<app-entry-fields></app-entry-fields>
2016
</div>
2117

22-
<div class="form-group">
23-
<button *ngIf="areFieldsVisible" class="btn btn-primary btn-block" type="button" (click)="clockOut()">Clock Out</button>
24-
</div>
2518
</div>

0 commit comments

Comments
 (0)