+
+
+
+
+
График показывает соотношение ответов на вопрос "Насколько ожидаемой
оказалась статистика?". Вариантов было три: "Выше ожиданий", "Ожидаемая",
"Ниже ожиданий". На графике ответы построены в столбик, высотка столбика -
100%. Каждый столбик - ответы респондентов одного грейда: Junior, Middle,
Senior, Lead.
-
-
-
Ожидания по статистике у тех, кто работает на удаленке
-
+
+
+
+
+
График показывает соотношение ответов на вопрос "Насколько ожидаемой
оказалась статистика?". Вариантов было три: "Выше ожиданий", "Ожидаемая",
"Ниже ожиданий". На графике ответы построены в столбик, высотка столбика -
100%. Каждый столбик - ответы респондентов одного грейда: Junior, Middle,
Senior, Lead.
-
-
-
diff --git a/src/app/modules/salaries/components/people-by-gender-chart/people-by-gender-chart.component.html b/src/app/modules/salaries/components/people-by-gender-chart/people-by-gender-chart.component.html
index 47921dc0..86d89aee 100644
--- a/src/app/modules/salaries/components/people-by-gender-chart/people-by-gender-chart.component.html
+++ b/src/app/modules/salaries/components/people-by-gender-chart/people-by-gender-chart.component.html
@@ -16,12 +16,12 @@
| {{ item.label }} |
- {{ item.value }} |
- {{ item.part | number : "1.3" }}% |
+ {{ item.value | formatAsMoney : 0 }} |
+ {{ item.part | formatAsMoney : 3 }}% |
| Всего |
- {{ totalCountLocal }} |
+ {{ totalCountLocal | formatAsMoney : 0 }} |
|
diff --git a/src/app/modules/salaries/components/salaries-chart/salaries-by-grade/salaries-by-grade-block.component.ts b/src/app/modules/salaries/components/salaries-chart/salaries-by-grade/salaries-by-grade-block.component.ts
index f001c4d1..f6f6d841 100644
--- a/src/app/modules/salaries/components/salaries-chart/salaries-by-grade/salaries-by-grade-block.component.ts
+++ b/src/app/modules/salaries/components/salaries-chart/salaries-by-grade/salaries-by-grade-block.component.ts
@@ -5,6 +5,7 @@ import { SalariesChart } from "../salaries-chart";
import { formatNumber } from "@angular/common";
import { untilDestroyed } from "@shared/subscriptions/until-destroyed";
import { CurrencyType } from "@services/admin-tools.service";
+import { FormatAsMoneyPipe } from "@shared/directives/format-as-money.pipe";
interface Item extends SalariesByGrade {
gradeAsString: string;
@@ -69,11 +70,11 @@ export class SalariesByGradeBlockComponent implements OnInit, OnDestroy {
medianSalary: x.medianSalary,
medianSalaryAsString:
x.medianSalary != null
- ? formatNumber(x.medianSalary, "en-US", "1.0-2")
+ ? FormatAsMoneyPipe.formatNumber(x.medianSalary)
: "",
averageSalaryAsString:
x.averageSalary != null
- ? formatNumber(x.averageSalary, "en-US", "1.0-2")
+ ? FormatAsMoneyPipe.formatNumber(x.averageSalary)
: "",
};
});
diff --git a/src/app/modules/salaries/components/salaries-chart/salaries-chart.component.html b/src/app/modules/salaries/components/salaries-chart/salaries-chart.component.html
index 4bf091d3..75d31182 100644
--- a/src/app/modules/salaries/components/salaries-chart/salaries-chart.component.html
+++ b/src/app/modules/salaries/components/salaries-chart/salaries-chart.component.html
@@ -278,7 +278,7 @@
-
- Тенденция измненения зарплат
-
diff --git a/src/app/modules/salaries/components/salaries-chart/salary-block-remote-value/salary-block-remote-value.component.ts b/src/app/modules/salaries/components/salaries-chart/salary-block-remote-value/salary-block-remote-value.component.ts
index 1f5af376..51ee4c7b 100644
--- a/src/app/modules/salaries/components/salaries-chart/salary-block-remote-value/salary-block-remote-value.component.ts
+++ b/src/app/modules/salaries/components/salaries-chart/salary-block-remote-value/salary-block-remote-value.component.ts
@@ -1,6 +1,7 @@
import { Component, Input } from "@angular/core";
import { SalariesChart } from "../salaries-chart";
import { formatNumber } from "@angular/common";
+import { FormatAsMoneyPipe } from "@shared/directives/format-as-money.pipe";
@Component({
selector: "app-salary-block-remote-value",
@@ -12,22 +13,14 @@ export class SalaryBlockRemoteValueComponent {
source: SalariesChart | null = null;
get median(): string {
- return SalaryBlockRemoteValueComponent.formatNumber(
+ return FormatAsMoneyPipe.formatNumber(
this.source?.medianRemoteSalary
);
}
get average(): string {
- return SalaryBlockRemoteValueComponent.formatNumber(
+ return FormatAsMoneyPipe.formatNumber(
this.source?.averageRemoteSalary
);
}
-
- private static formatNumber(value: number | null | undefined): string {
- if (value == null) {
- return "";
- }
-
- return formatNumber(value, "en-US", "1.0-2");
- }
}
diff --git a/src/app/modules/salaries/components/salaries-chart/salary-block-value/salary-block-value.component.ts b/src/app/modules/salaries/components/salaries-chart/salary-block-value/salary-block-value.component.ts
index 2b05ccab..c4bdb469 100644
--- a/src/app/modules/salaries/components/salaries-chart/salary-block-value/salary-block-value.component.ts
+++ b/src/app/modules/salaries/components/salaries-chart/salary-block-value/salary-block-value.component.ts
@@ -2,6 +2,7 @@ import { Component, Input, OnInit, OnDestroy } from "@angular/core";
import { SalariesChart } from "../salaries-chart";
import { formatNumber } from "@angular/common";
import { untilDestroyed } from "@shared/subscriptions/until-destroyed";
+import { FormatAsMoneyPipe } from "@shared/directives/format-as-money.pipe";
@Component({
selector: "app-salary-block-value",
@@ -37,26 +38,18 @@ export class SalaryBlockValueComponent implements OnInit, OnDestroy {
return;
}
- this.median = SalaryBlockValueComponent.formatNumber(
+ this.median = FormatAsMoneyPipe.formatNumber(
this.source.medianSalary
);
- this.average = SalaryBlockValueComponent.formatNumber(
+ this.average = FormatAsMoneyPipe.formatNumber(
this.source.averageSalary
);
- this.medianRemote = SalaryBlockValueComponent.formatNumber(
+ this.medianRemote = FormatAsMoneyPipe.formatNumber(
this.source.medianRemoteSalary
);
- this.averageRemote = SalaryBlockValueComponent.formatNumber(
+ this.averageRemote = FormatAsMoneyPipe.formatNumber(
this.source.averageRemoteSalary
);
this.currentCurrencyLabel = this.source.getCurrentCurrencyLabel();
}
-
- private static formatNumber(value: number | null | undefined): string {
- if (value == null) {
- return "";
- }
-
- return formatNumber(value, "en-US", "1.0-2");
- }
}
diff --git a/src/app/modules/salaries/components/salaries-paginated-table/salaries-paginated-table.component.html b/src/app/modules/salaries/components/salaries-paginated-table/salaries-paginated-table.component.html
index 27319019..e74c3c39 100644
--- a/src/app/modules/salaries/components/salaries-paginated-table/salaries-paginated-table.component.html
+++ b/src/app/modules/salaries/components/salaries-paginated-table/salaries-paginated-table.component.html
@@ -20,7 +20,7 @@
- | {{ item.value | number : "1.0-0" }} |
+ {{ item.value | formatAsMoney }} |
{{ item.quarter }}.{{ item.year }} |
{{ item.age }} |
{{ item.gender }} |
diff --git a/src/app/shared/directives/format-as-money.pipe.spec.ts b/src/app/shared/directives/format-as-money.pipe.spec.ts
new file mode 100644
index 00000000..59180f23
--- /dev/null
+++ b/src/app/shared/directives/format-as-money.pipe.spec.ts
@@ -0,0 +1,45 @@
+import { FormatAsMoneyPipe } from "./format-as-money.pipe";
+
+describe("FormatAsMoneyPipe", () => {
+ it("return value less than 100", () => {
+ const target = new FormatAsMoneyPipe();
+
+ var result = target.transform(99.99);
+ expect(result).toBe("99.99");
+ });
+
+ it("return value greater than 100", () => {
+ const target = new FormatAsMoneyPipe();
+
+ var result = target.transform(105.05);
+ expect(result).toBe("105.05");
+ });
+
+ it("return value greater than 1000", () => {
+ const target = new FormatAsMoneyPipe();
+
+ var result = target.transform(1050.05);
+ expect(result).toBe("1 050.05");
+ });
+
+ it("return value greater than 10000", () => {
+ const target = new FormatAsMoneyPipe();
+
+ var result = target.transform(10500.05);
+ expect(result).toBe("10 500.05");
+ });
+
+ it("return value greater than 100000", () => {
+ const target = new FormatAsMoneyPipe();
+
+ var result = target.transform(100500.05);
+ expect(result).toBe("100 500.05");
+ });
+
+ it("return value greater than 1000000", () => {
+ const target = new FormatAsMoneyPipe();
+
+ var result = target.transform(1000500.05);
+ expect(result).toBe("1 000 500.05");
+ });
+});
diff --git a/src/app/shared/directives/format-as-money.pipe.ts b/src/app/shared/directives/format-as-money.pipe.ts
new file mode 100644
index 00000000..bae35094
--- /dev/null
+++ b/src/app/shared/directives/format-as-money.pipe.ts
@@ -0,0 +1,18 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({
+ name: 'formatAsMoney'
+})
+export class FormatAsMoneyPipe implements PipeTransform {
+ transform(value: number | null, fractionSize: number = 2): string {
+ return FormatAsMoneyPipe.formatNumber(value, fractionSize);
+ }
+
+ public static formatNumber(value: number | null | undefined, fractionSize: number = 2): string {
+ if (value == null) {
+ return '';
+ }
+
+ return value.toFixed(fractionSize).replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
+ }
+}
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index 7fdaeb8c..55b56792 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -38,6 +38,7 @@ import { ShareButtonComponent } from "./components/share-button/share-button.com
import { LabelsNgSelectComponent } from "./components/labels-ng-select/labels-ng-select.component";
import { NgSelectModule } from "@ng-select/ng-select";
import { WednesdayFrogComponent } from "./components/wednesday-frog/wednesday-frog.component";
+import { FormatAsMoneyPipe } from "./directives/format-as-money.pipe";
const componentsToDeclareAndExport = [
AlertComponent,
@@ -71,6 +72,7 @@ const componentsToDeclareAndExport = [
ShareButtonComponent,
LabelsNgSelectComponent,
WednesdayFrogComponent,
+ FormatAsMoneyPipe,
];
@NgModule({