Skip to content

Commit eefd758

Browse files
committed
fix: TT-20 Calculate Difference
1 parent aeec0f7 commit eefd758

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@
137137
</div>
138138
</div>
139139

140-
<div class="form-group row">
140+
<div class="form-group row" *ngIf="!goingToWorkOnThis">
141141
<label class="col-12 col-sm-2">Total Hours:</label>
142142
<div class="col-12 col-sm-4">
143-
<span>
144-
143+
<span class="border-tag"
144+
[class.border-tag--disabled]="!(project_id.value && project_name.value)"
145+
>
146+
{{ this.getTimeDifference() }}
145147
</span>
146148
</div>
147149
</div>

src/app/modules/shared/components/details-fields/details-fields.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,10 @@ input[type="date"]::-webkit-clear-button {
108108
background-color: #e9ecef;
109109
opacity: 1;
110110
}
111+
112+
.border-tag {
113+
border: 1px solid $primary;
114+
padding: 10px;
115+
border-radius: 5px;
116+
margin-top: 10px;
117+
}

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,23 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
129129
}
130130

131131
getTimeDifference(){
132-
const horainico = this.start_hour.value;
133-
const horafinal = this.end_hour.value;
134-
console.log(horainico + ' ' + horafinal);
135-
const ab = moment(horainico, 'HH:mm');
136-
const ac = moment(horafinal, 'HH:mm');
137-
console.error(moment.duration(ab.diff(ac)).humanize());
138-
const diff = [moment.duration(ab.diff(ac)).humanize()];
139-
return diff;
132+
moment.locale('es');
133+
const hourStart = this.start_hour.value;
134+
const hourEnd = this.end_hour.value;
135+
const ab = moment(hourStart, 'HH:mm');
136+
const ac = moment(hourEnd, 'HH:mm');
137+
if (hourStart === '00:00') {
138+
const hourTotal = '00:00';
139+
return hourTotal;
140+
}
141+
if (hourEnd === '00:00') {
142+
const hourTotal = '00:00';
143+
return hourTotal;
144+
}else {
145+
const hourTotal = [moment.duration(ab.diff(ac))];
146+
return hourTotal;
147+
}
148+
140149
}
141150

142151
ngOnChanges(): void {

0 commit comments

Comments
 (0)