Skip to content

Commit 1f3ab38

Browse files
committed
add styles for erro icons & fix goal logic to save
1 parent 6508799 commit 1f3ab38

9 files changed

Lines changed: 52 additions & 11 deletions

File tree

projects/social_platform/src/app/office/projects/edit/edit.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,20 @@ <h1 class="project__title">редактировать проект</h1>
8686
"
8787
>
8888
<div class="project__warning-modal">
89-
<h3 class="text-bold-body-16">📢 Внимание!</h3>
89+
<h3 class="text-bold-body-16">📢 внимание!</h3>
9090
<p class="text-body-14">
91-
Для публикации проекта, нужно заполнить все <strong>обязательные поля</strong> (они будут
91+
для публикации проекта, нужно заполнить все <strong>обязательные поля</strong> (они будут
9292
<strong>подсвечены&nbsp;<span>красным</span></strong
9393
>). Если вы пока не знаете что написать, можно сохранить черновик проекта и заполнить поля
9494
позже :&#41;
9595
</p>
96-
<app-button (click)="closeWarningModal()">Понятно</app-button>
96+
<app-button
97+
size="medium"
98+
customTypographyClass="text-body-12"
99+
appearance="outline"
100+
(click)="closeWarningModal()"
101+
>понятно</app-button
102+
>
97103
</div>
98104
</app-modal>
99105
</main>

projects/social_platform/src/app/office/projects/edit/edit.component.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ import { ProjectService } from "@services/project.service";
2323
import { ButtonComponent, IconComponent, SelectComponent } from "@ui/components";
2424
import { ModalComponent } from "@ui/components/modal/modal.component";
2525
import { ValidationService } from "projects/core";
26-
import { Subscription, distinctUntilChanged, forkJoin, map, of, switchMap } from "rxjs";
26+
import {
27+
Observable,
28+
Subscription,
29+
distinctUntilChanged,
30+
forkJoin,
31+
map,
32+
of,
33+
switchMap,
34+
tap,
35+
} from "rxjs";
2736
import { CommonModule, AsyncPipe } from "@angular/common";
2837
import { ProjectNavigationComponent } from "./shared/project-navigation/project-navigation.component";
2938
import { EditStep, ProjectStepService } from "./services/project-step.service";
@@ -446,12 +455,30 @@ export class ProjectEditComponent implements OnInit, AfterViewInit, OnDestroy {
446455
}
447456

448457
private saveOrEditGoals(projectId: number) {
449-
const goals = this.goals.value;
450-
const hasExistingGoals = goals.some((g: Goal) => g.id);
458+
const goals = this.goals.value as Goal[];
459+
460+
const newGoals = goals.filter(g => !g.id);
461+
const existingGoals = goals.filter(g => g.id);
462+
463+
const requests: Observable<any>[] = [];
464+
465+
if (newGoals.length > 0) {
466+
requests.push(this.projectGoalService.saveGoals(projectId, newGoals));
467+
}
468+
469+
if (existingGoals.length > 0) {
470+
requests.push(this.projectGoalService.editGoals(projectId, existingGoals));
471+
}
472+
473+
if (requests.length === 0) {
474+
return of(null);
475+
}
451476

452-
return hasExistingGoals
453-
? this.projectGoalService.editGoals(projectId)
454-
: this.projectGoalService.saveGoals(projectId);
477+
return forkJoin(requests).pipe(
478+
tap(() => {
479+
this.projectGoalService.syncGoalItems(this.projectGoalService.goals);
480+
})
481+
);
455482
}
456483

457484
private savePartners(projectId: number) {
@@ -491,18 +518,20 @@ export class ProjectEditComponent implements OnInit, AfterViewInit, OnDestroy {
491518
private validateAdditionalFields(): boolean {
492519
const partnerProgramFields = this.projectAdditionalService.getPartnerProgramFields();
493520

521+
// Если нет дополнительных полей - пропускаем валидацию
494522
if (!partnerProgramFields?.length) {
495523
return false;
496524
}
497525

526+
// Проверяем только обязательные поля
498527
const hasInvalid = this.projectAdditionalService.validateRequiredFields();
499528

500529
if (hasInvalid) {
501530
this.cdRef.markForCheck();
502531
return true;
503532
}
504533

505-
// Подготавливаем поля для отправки
534+
// Подготавливаем поля для отправки (убираем валидаторы с заполненных полей)
506535
this.projectAdditionalService.prepareFieldsForSubmit();
507536
return false;
508537
}

projects/social_platform/src/app/office/projects/edit/shared/project-achievement-step/project-achievement-step.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@
7777
i {
7878
color: var(--red) !important;
7979
}
80+
8081
color: var(--red) !important;
8182
}

projects/social_platform/src/app/office/projects/edit/shared/project-additional-step/project-additional-step.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,6 @@
165165
i {
166166
color: var(--red) !important;
167167
}
168+
168169
color: var(--red) !important;
169170
}

projects/social_platform/src/app/office/projects/edit/shared/project-main-step/project-main-step.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
i {
139139
color: var(--red) !important;
140140
}
141+
141142
color: var(--red) !important;
142143
}
143144

projects/social_platform/src/app/office/projects/edit/shared/project-partner-resources-step/project-partner-resources-step.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@
6262
i {
6363
color: var(--red) !important;
6464
}
65+
6566
color: var(--red) !important;
6667
}

projects/social_platform/src/app/office/projects/edit/shared/project-team-step/project-team-step.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
i {
133133
color: var(--red) !important;
134134
}
135+
135136
color: var(--red) !important;
136137
}
137138

projects/social_platform/src/app/office/projects/edit/shared/project-vacancy-step/project-vacancy-step.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
i {
9898
color: var(--red) !important;
9999
}
100+
100101
color: var(--red) !important;
101102
}
102103

projects/social_platform/src/app/ui/components/textarea/textarea.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
display: flex;
5151
align-items: center;
5252
justify-content: center;
53-
transform: translateY(-50%);
5453
color: var(--red) !important;
54+
transform: translateY(-50%);
5555

5656
i {
5757
color: var(--red) !important;

0 commit comments

Comments
 (0)