Skip to content

Commit

Permalink
fix(schedule): fix times when same work
Browse files Browse the repository at this point in the history
  • Loading branch information
abalad committed Nov 13, 2020
1 parent 045e4a0 commit d9e51cf
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,10 @@ export class ViewDayComponent implements OnInit, AfterViewInit, OnChanges, OnDes
const beforeHourScale = this.reduceBeforeScale( orderedScales );
const afterHourScale = this.reduceAfterScale( orderedScales );
return this.sortScaleByStart(
this.removeSameStartAndEndSacalesTime(
notExpansedScales.concat(afterHourScale).concat(beforeHourScale)
this.removeNextSameStartAndEndSacalesTime(
this.removeSameStartAndEndSacalesTime(
notExpansedScales.concat(afterHourScale).concat(beforeHourScale)
)
)
);
}
Expand All @@ -196,6 +198,15 @@ export class ViewDayComponent implements OnInit, AfterViewInit, OnChanges, OnDes
return scales.filter( (value => value.start !== value.end ));
}

private removeNextSameStartAndEndSacalesTime(scales: WorkScaleType[]) {
return scales.filter( (value, index, array ) => {
if ( array[index - 1] ) {
return value.start !== array[index - 1].start && value.end !== array[index - 1].end;
}
return true;
});
}

private reduceBeforeScale( scales: WorkScaleType[] ) {
return scales.reduce( (previous, current) => {
const cStart = this.workScaleService.transformHourToMileseconds(current.start);
Expand Down

0 comments on commit d9e51cf

Please sign in to comment.