Skip to content

Commit b806c19

Browse files
Merge 047f7b8 into d617e1d
2 parents d617e1d + 047f7b8 commit b806c19

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe('Reports Page', () => {
190190

191191
it('Should populate the users with the payload from the action executed', () => {
192192
const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject;
193-
const usersArray = []
193+
const usersArray = [];
194194
const action = {
195195
type: UserActionTypes.LOAD_USERS_SUCCESS,
196196
payload: usersArray
@@ -201,10 +201,10 @@ describe('Reports Page', () => {
201201

202202
expect(component.users).toEqual(usersArray);
203203
});
204-
204+
205205
it('The sum of the data dates is equal to {"hours": 3, "minutes":20,"seconds":0}', () => {
206-
let {hours,minutes,seconds}: TotalHours = component.sumDates(timeEntryList);
207-
expect({hours, minutes, seconds}).toEqual({hours:3,minutes:20,seconds:0});
206+
const {hours, minutes, seconds}: TotalHours = component.sumDates(timeEntryList);
207+
expect({hours, minutes, seconds}).toEqual({hours: 3, minutes: 20, seconds: 0});
208208
});
209209

210210
afterEach(() => {

src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
127127
const durationColumnIndex = 3;
128128
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
129129
}
130-
130+
131131
sumDates(arrayData: Entry[]): TotalHours{
132132
this.resultSum = new TotalHours();
133-
let arrayDurations= new Array();
134-
arrayData.forEach(entry =>{
135-
let start = moment(entry.end_date).diff(moment(entry.start_date));
136-
arrayDurations.push(moment.utc(start).format("HH:mm:ss"));
133+
const arrayDurations = new Array();
134+
arrayData.forEach(entry => {
135+
const start = moment(entry.end_date).diff(moment(entry.start_date));
136+
arrayDurations.push(moment.utc(start).format('HH:mm:ss'));
137137
});
138-
139-
let totalDurations = arrayDurations.slice(1)
138+
139+
const totalDurations = arrayDurations.slice(1)
140140
.reduce((prev, cur) => {
141141
return prev.add(cur);
142142
},
143143
moment.duration(arrayDurations[0]));
144-
let daysInHours = totalDurations.days() * 24;
145-
this.resultSum.hours=totalDurations.hours() + daysInHours;
144+
const daysInHours = totalDurations.days() * 24;
145+
this.resultSum.hours = totalDurations.hours() + daysInHours;
146146
this.resultSum.minutes = totalDurations.minutes();
147147
this.resultSum.seconds = totalDurations.seconds();
148148
return this.resultSum;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export class TotalHours {
2-
2+
33
hours: number;
44
minutes: number;
55
seconds: number;
@@ -9,4 +9,5 @@ export class TotalHours {
99
this.minutes = 0;
1010
this.seconds = 0;
1111
}
12-
}
12+
}
13+

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
361361

362362
const isStartDateInTheFuture = moment(startDateToSubmit).isAfter(moment());
363363
const isEndDateInTheFuture = moment(endDateToSubmit).isAfter(moment());
364-
const timeEntryIsInTheFuture = isStartDateInTheFuture || isEndDateInTheFuture;
364+
const timeEntryIsInTheFuture = isStartDateInTheFuture || (isEndDateInTheFuture && !this.goingToWorkOnThis);
365365

366366
if (timeEntryIsInTheFuture) {
367367
this.toastrService.error('You cannot start a time-entry in the future');

src/app/modules/shared/formatters/parse-date-time-offset/parse-date-time-offset.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import * as moment from 'moment';
22

33
export class ParseDateTimeOffset {
44

5-
parseDateTimeOffset(date:string, offset): string{
6-
if(date == null || date == undefined || date == '') return 'In progress';
7-
return moment.utc(date).utcOffset(-1*offset).format("HH:mm");
5+
parseDateTimeOffset(date: string, offset): string {
6+
if (date === null || date === undefined || date === '') {
7+
return 'In progress';
8+
}
9+
return moment.utc(date).utcOffset(-1 * offset).format('HH:mm');
810
}
911
}

0 commit comments

Comments
 (0)