Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Cache NPM dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"serve-staging": "ng serve --configuration=staging -o",
"watch": "ng build --watch --configuration development",
"test": "ng test --browsers ChromiumNoSandbox",
"test-headless-ci-only": "ng test --browsers ChromiumNoSandbox",
"test-headless-ci-only": "ng test --no-watch --browsers ChromiumNoSandbox",
"lint": "ng lint",
"pretty": "pretty-quick",
"pretty-all": "prettier --write \"src/**/*.ts\" \"src/**/*.html\" \"src/**/*.scss\" \"src/**/*.json\" \"e2e/**/*.ts\" \"tools/**/*.ts\" \"*.json\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="my-5 container">
<div class="card">
<div class="card-body form-container">
<div class="card-body p-lg-5 p-3">
<div class="mb-5 mt-1">
<div class="mb-1 text-muted small fst-italic">
Для того, чтобы просматривать график зарплат, вам нужно сначала внести
Expand Down Expand Up @@ -289,6 +289,29 @@
></app-field-error>
</div>

<div class="mb-3" *ngIf="addSalaryForm.getInvalidFields().length > 0">
<div class="alert alert-warning">
<div class="mb-2">
<strong>Внимание!</strong> Следующие поля не заполнены:
</div>
<div
class="mb-2"
*ngFor="
let field of addSalaryForm.getInvalidFields();
let i = index
"
>
<div>{{ i + 1 }}. Страница {{ field.page }}</div>
<div
class="ms-3"
*ngFor="let control of field.fields; let j = index"
>
{{ i + 1 }}.{{ j + 1 }}. {{ control }}
</div>
</div>
</div>
</div>
Comment on lines +292 to +313
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing validation summary for the first step.

The validation summary alert is only implemented for the third step of the form. According to the AI summary, it should be present on both the first and third steps to provide consistent feedback.

Add the same validation summary block to the first step of the form (around line 145, before the "Далее" button):

+          <div class="mb-3" *ngIf="addSalaryForm.getInvalidFields().length > 0">
+            <div class="alert alert-warning">
+              <div class="mb-2">
+                <strong>Внимание!</strong> Следующие поля не заполнены:
+              </div>
+              <div
+                class="mb-2"
+                *ngFor="
+                  let field of addSalaryForm.getInvalidFields();
+                  let i = index
+                "
+              >
+                <div>{{ i + 1 }}. Страница {{ field.page }}</div>
+                <div
+                  class="ms-3"
+                  *ngFor="let control of field.fields; let j = index"
+                >
+                  {{ i + 1 }}.{{ j + 1 }}. {{ control }}
+                </div>
+              </div>
+            </div>
+          </div>
+
           <div class="row mt-5">
             <div class="col-6"></div>
             <div class="col-6">


<div class="row mt-5">
<div class="col-6">
<button
Expand Down
105 changes: 105 additions & 0 deletions src/app/modules/salaries/components/add-salary/edit-salary-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ import {
} from "@services/user-salaries.service";
import { FormatAsMoneyPipe } from "@shared/directives/format-as-money.pipe";

interface InvalidFieldsGroupedByPage {
page: number;
fields: string[];
}

interface InvalidField {
page: number;
controlName: string;
field: string;
}

export class EditSalaryForm extends FormGroup {
static readonly digitsPattern = "^[0-9]*$";

private _invalidFields: InvalidField[] = [];

constructor(
salarytoBeEditedOrNull: UserSalary | null,
hasIndustries: boolean = false,
Expand Down Expand Up @@ -144,6 +157,19 @@ export class EditSalaryForm extends FormGroup {
};
}

this._invalidFields = [];
const controls = this.controls;
for (const name in controls) {
const control = this.controls[name];
if (control.invalid) {
this._invalidFields.push({
page: this.getPageForField(name),
controlName: name,
field: this.getControlNameLable(name),
});
}
}

this.markAllAsTouched();
return null;
}
Expand Down Expand Up @@ -193,4 +219,83 @@ export class EditSalaryForm extends FormGroup {
this.markAllAsTouched();
return null;
}

getInvalidFields(): InvalidFieldsGroupedByPage[] {
if (this._invalidFields.length === 0) {
return [];
}

const groupedByPage: InvalidFieldsGroupedByPage[] = [
{
page: 1,
fields: [],
},
{
page: 2,
fields: [],
},
{
page: 3,
fields: [],
},
];

for (const invalidField of this._invalidFields) {
const page = invalidField.page;
groupedByPage[page - 1].fields.push(invalidField.field);
}

return groupedByPage;
}

private getControlNameLable(name: string): string {
switch (name) {
case "value":
return "Зарплата, NET";
case "quarter":
return "Квартал";
case "company":
return "Казахстанская / Удаленная компания";
case "profession":
return "Ваша специализация";
case "grade":
return "Ваш грейд";
case "workIndustryId":
return "Сфера деятельности компании";
case "city":
return "Город, в котором вы живете";
case "yearOfStartingWork":
return "Год старта вашей карьеры";
case "gender":
return "Пол";
case "age":
return "Сколько вам полных лет?";

default:
return "";
}
}

private getPageForField(name: string): number {
switch (name) {
case "value":
case "quarter":
case "company":
case "profession":
return 1;

case "grade":
case "workIndustryId":
case "city":
return 2;

case "yearOfStartingWork":
case "gender":
case "age":
return 3;

default:
return 0;
}
}
}
1 change: 1 addition & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ window.onbeforeunload = jasmine.createSpy();

// Then we find all the tests.
const context = require.context("./", true, /\.spec\.ts$/);

// And load the modules.
context.keys().map(context);