Skip to content

Commit 35fece7

Browse files
wobravoscastillo-jp
authored andcommitted
fix: TT-20 Calculate Difference
1 parent 5770f8c commit 35fece7

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
@@ -131,14 +131,23 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
131131
}
132132

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

144153
ngOnChanges(): void {

0 commit comments

Comments
 (0)