-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pmp-web): display proper maxWaitingTime
Add time ago and resolve hours pipes. Hide Constraints tab. Hide Login by gitlab.
- Loading branch information
1 parent
6f78d19
commit 7dea623
Showing
10 changed files
with
106 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
libs/pmp-web/shared/util/src/lib/pipes/resolve-hours/resolve-hours.pipe.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ResolveHoursPipe } from './resolve-hourse.pipe'; | ||
import { TimeUnit } from '@pimp-my-pr/shared/domain'; | ||
|
||
describe('ResolveHours', () => { | ||
let pipe: ResolveHoursPipe; | ||
|
||
beforeEach(() => { | ||
pipe = new ResolveHoursPipe(); | ||
}); | ||
it('should handle 0', () => { | ||
expect(pipe.transform(0)).toBe(`-`); | ||
}); | ||
it('should handle null', () => { | ||
expect(pipe.transform(null)).toBe(`-`); | ||
}); | ||
it('should handle singular', () => { | ||
expect(pipe.transform(1)).toBe(`1 hour`); | ||
}); | ||
it('should handle plural', () => { | ||
expect(pipe.transform(2)).toBe(`2 hours`); | ||
}); | ||
it('handle days', () => { | ||
expect(pipe.transform(48)).toBe(`2 days`); | ||
}); | ||
it('should handle exactly values', () => { | ||
expect(pipe.transform(49)).toBe(`49 hours`); | ||
}); | ||
it('10 days', () => { | ||
expect(pipe.transform(10 * +TimeUnit.Day)).toBe(`10 days`); | ||
}); | ||
it('2 months', () => { | ||
expect(pipe.transform(2 * +TimeUnit.Month)).toBe(`2 months`); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
libs/pmp-web/shared/util/src/lib/pipes/resolve-hours/resolve-hourse.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { TimeUnit } from '@pimp-my-pr/shared/domain'; | ||
|
||
@Pipe({ | ||
name: 'resolveHours' | ||
}) | ||
export class ResolveHoursPipe implements PipeTransform { | ||
transform(value: number): string { | ||
const timeValues: { hrsInThatPeriod: number; name: string }[] = [ | ||
{ hrsInThatPeriod: +TimeUnit.Year, name: 'year' }, | ||
{ hrsInThatPeriod: +TimeUnit.Month, name: 'month' }, | ||
{ hrsInThatPeriod: +TimeUnit.Week, name: 'week' }, | ||
{ hrsInThatPeriod: +TimeUnit.Day, name: 'day' }, | ||
{ hrsInThatPeriod: +TimeUnit.Hour, name: 'hour' } | ||
]; | ||
|
||
if (!value) { | ||
return '-'; | ||
} | ||
let timeLabel: string, | ||
incr = 0; | ||
|
||
while (!timeLabel) { | ||
if (!timeValues[incr]) break; | ||
|
||
if (value % timeValues[incr].hrsInThatPeriod === 0) { | ||
const valueInTheUnit = value / timeValues[incr].hrsInThatPeriod; | ||
if (valueInTheUnit > 1) { | ||
timeLabel = `${valueInTheUnit} ${timeValues[incr].name}s`; | ||
} else { | ||
timeLabel = `${valueInTheUnit} ${timeValues[incr].name}`; | ||
} | ||
break; | ||
} | ||
|
||
incr++; | ||
} | ||
|
||
return timeLabel; | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
.../src/lib/pipes/resolve-hours.pipe.spec.ts → .../lib/pipes/time-ago/time-ago.pipe.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
.../util/src/lib/pipes/resolve-hours.pipe.ts → ...l/src/lib/pipes/time-ago/time-ago.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
libs/pmp-web/shared/util/src/lib/pmp-web-shared-util.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { ResolveHoursPipe } from './pipes/resolve-hours.pipe'; | ||
import { TimeAgoPipe } from './pipes/time-ago/time-ago.pipe'; | ||
import { ResolveHoursPipe } from './pipes/resolve-hours/resolve-hourse.pipe'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
declarations: [ResolveHoursPipe], | ||
exports: [ResolveHoursPipe] | ||
declarations: [TimeAgoPipe, ResolveHoursPipe], | ||
exports: [TimeAgoPipe, ResolveHoursPipe] | ||
}) | ||
export class PmpWebSharedUtilModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,7 @@ | |
export enum TimeUnit { | ||
Hour = '1', | ||
Day = '24', | ||
Week = '168' | ||
Week = '168', | ||
Month = '720', | ||
Year = '8760' | ||
} |