Skip to content

Commit b23f9aa

Browse files
committed
use ngPlural
1 parent 3961cb0 commit b23f9aa

File tree

8 files changed

+10
-38
lines changed

8 files changed

+10
-38
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"core-js": "^2.4.1",
4444
"jwt-decode": "^2.1.0",
4545
"lodash-es": "^4.16.6",
46-
"pluralize": "^3.0.0",
4746
"rxjs": "~5.0.1",
4847
"time-ago": "^0.1.0",
4948
"zone.js": "~0.7.6"

src/app/components/user-stats/user-stats.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ <h2 [mptStyles]="[styles.userName]">
1111
<a [routerLink]="['/users/' + user?.id]">view my profile</a>
1212
</span>
1313
<span *ngIf="!shownOnProfile" [mptStyles]="[styles.userText]">
14-
{{(user?.userStats?.micropostCnt || 0) | pluralize:'micropost'}}
14+
<span [ngPlural]="user?.userStats?.micropostCnt || 0">
15+
<template ngPluralCase="=0">No micropost</template>
16+
<template ngPluralCase="=1">1 micropost</template>
17+
<template ngPluralCase="other">{{(user?.userStats?.micropostCnt || 0)}} microposts</template>
18+
</span>
1519
</span>
1620
</section>
1721

1822
<section class="clearfix" [mptStyles]="[styles.section]">
1923
<div>
2024
<a [routerLink]="['/users/' + user?.id, 'followings']"
2125
[mptStyles]="[styles.relationshipsLeft]">
22-
<strong [mptStyles]="[styles.relationshipsNumber]">{{user?.userStats?.followingCnt || 0}}</strong>
26+
<strong [mptStyles]="[styles.relationshipsNumber]">{{user?.userStats?.followingCnt
27+
|| 0}}</strong>
2328
followings
2429
</a>
2530
<a [routerLink]="['/users/' + user?.id, 'followers']"
2631
[mptStyles]="[styles.relationshipsRight]">
27-
<strong [mptStyles]="[styles.relationshipsNumber]">{{user?.userStats?.followerCnt || 0}}</strong>
32+
<strong [mptStyles]="[styles.relationshipsNumber]">{{user?.userStats?.followerCnt
33+
|| 0}}</strong>
2834
followers
2935
</a>
3036
</div>

src/app/components/user-stats/user-stats.component.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {UserStatsModule} from "./user-stats.module";
1515
import {CoreModule} from "../../core";
1616
import {APP_TEST_HTTP_PROVIDERS} from "../../../testing";
1717
import {GravatarComponent} from "../../shared/gravatar/gravatar.component";
18-
import _ from "lodash";
1918

2019
describe('UserStatsComponent', () => {
2120

@@ -77,7 +76,6 @@ describe('UserStatsComponent', () => {
7776
expect(cmp.userId).toEqual(1);
7877
expect(cmp.user).toBeTruthy();
7978
expect(cmp.user.id).toEqual(1);
80-
expect(_.get(cmp, 'user.userStats.micropostCnt')).toEqual(2);
8179

8280
const gravatarDebugElement = cmpDebugElement.query(By.directive(GravatarComponent));
8381
expect(gravatarDebugElement).toBeTruthy();

src/app/shared/pipes/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export * from './pluralize.pipe';
21
export * from './time-ago.pipe';

src/app/shared/pipes/pluralize.pipe.spec.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/app/shared/pipes/pluralize.pipe.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/app/shared/shared.module.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {CommonModule} from "@angular/common";
22
import {NgModule} from "@angular/core/src/metadata/ng_module";
3-
import {PluralizePipe, TimeAgoPipe} from "./pipes";
3+
import {TimeAgoPipe} from "./pipes";
44
import {GravatarComponent} from "./gravatar/gravatar.component";
55
import {PagerComponent} from "./pager/pager.component";
66
import {FollowBtnModule} from "./follow-btn/follow-btn.module";
@@ -17,7 +17,6 @@ import {StylesDirective} from "./directives/styles.directive";
1717
GravatarComponent,
1818
StylesDirective,
1919

20-
PluralizePipe,
2120
TimeAgoPipe,
2221
],
2322
exports: [
@@ -26,7 +25,6 @@ import {StylesDirective} from "./directives/styles.directive";
2625
FollowBtnComponent,
2726
StylesDirective,
2827

29-
PluralizePipe,
3028
TimeAgoPipe,
3129
]
3230
})

src/vendor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import "lodash/isEmpty";
1111
import "lodash/omitBy";
1212
import "jwt-decode";
1313
import "time-ago";
14-
import "pluralize";
1514
import "aphrodite";
1615
import "bootstrap/dist/css/bootstrap.css";
1716

0 commit comments

Comments
 (0)