Skip to content

Commit 8477849

Browse files
committed
fix edit button & expert ui
1 parent 765d77a commit 8477849

3 files changed

Lines changed: 26 additions & 50 deletions

File tree

projects/social_platform/src/app/office/features/project-rating/project-rating.component.html

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,6 @@
2929
placeholder="Небольшой комментарий, если необходимо"
3030
></app-textarea>
3131
</div>
32-
} }<!-- @format -->
33-
<form [formGroup]="form" class="rating">
34-
<section class="rating__columns">
35-
@for (criterion of criteria; track $index) { @if (criterion.type === "int") {
36-
<div class="rating__field">
37-
<app-range-criterion-input
38-
class="rating__input"
39-
[max]="criterion.maxValue!"
40-
[formControlName]="criterion.id"
41-
></app-range-criterion-input>
42-
<label class="text-body-10">{{ criterion.name }}</label>
43-
</div>
44-
} @if (criterion.type === "bool") {
45-
<div class="rating__field">
46-
<app-boolean-criterion
47-
class="rating__input"
48-
[formControlName]="criterion.id"
49-
></app-boolean-criterion>
50-
<label class="text-body-10">{{ criterion.name }}</label>
51-
</div>
52-
} }
53-
</section>
54-
<section>
55-
@for (criterion of criteria; track $index) { @if (criterion.type === "str") {
56-
<div class="rating__comment">
57-
<app-textarea
58-
size="big"
59-
[formControlName]="criterion.id"
60-
placeholder="Небольшой комментарий, если необходимо"
61-
></app-textarea>
62-
</div>
63-
} }
64-
</section>
65-
</form>
32+
} }
6633
</section>
6734
</form>

projects/social_platform/src/app/office/program/shared/rating-card/rating-card.component.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@
7575
}
7676
</div>
7777

78-
@if (showRatingForm || showRatedWithEdit || showConfirmedState) {
78+
@if (showRatingForm || showRatedStatus || showConfirmedState) {
7979
<div class="card__rated">
8080
<app-button
8181
style="flex-grow: 1"
8282
customTypographyClass="text-body-12"
8383
size="big"
8484
[loader]="submitLoading() || confirmLoading()"
85-
[color]="showRatedWithEdit ? 'green' : 'primary'"
85+
[color]="showRatedStatus ? 'green' : 'primary'"
8686
[disabled]="programDateFinished()"
8787
[appearance]="programDateFinished() ? 'outline' : 'inline'"
8888
[style.opacity]="showConfirmedState ? '0.5' : '1'"
89-
(click)="showRatingForm ? confirmRateProject() : null"
89+
(click)="showRatingForm ? showConfirmRateModal.set(true) : null"
9090
>
9191
{{
9292
programDateFinished()
@@ -97,7 +97,7 @@
9797
}}
9898
</app-button>
9999

100-
@if (showRatedWithEdit && !programDateFinished()) {
100+
@if (showEditButton) {
101101
<app-button
102102
appearance="outline"
103103
size="small"
@@ -126,11 +126,13 @@
126126
</div>
127127

128128
<div class="cancel__criterias">
129+
@if (showConfirmRateModal()) {
129130
<app-project-rating
130131
[criteria]="project.criterias"
131132
[formControl]="form"
132133
[disabled]="(projectRated() || projectConfirmed()) && !programDateFinished()"
133134
></app-project-rating>
135+
}
134136
</div>
135137

136138
<div class="cancel__buttons">

projects/social_platform/src/app/office/program/shared/rating-card/rating-card.component.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
142142

143143
showConfirmRateModal = signal(false);
144144

145+
locallyRatedByCurrentUser = signal(false);
146+
145147
isProjectCriterias = signal(0);
146148

147149
programDateFinished = signal(false);
@@ -225,20 +227,18 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
225227
.pipe(finalize(() => this.submitLoading.set(false)))
226228
.subscribe({
227229
next: () => {
228-
if (this.showConfirmRateModal()) {
229-
this.projectConfirmed.set(true);
230-
this.showConfirmRateModal.set(false);
231-
} else {
232-
this.projectRated.set(true);
233-
this.showConfirmRateModal.set(true);
234-
}
230+
this.locallyRatedByCurrentUser.set(true);
231+
this.projectRated.set(true);
232+
this.projectConfirmed.set(true);
233+
this.showConfirmRateModal.set(false);
235234
},
236235
});
237236
}
238237

239238
redoRating(): void {
240239
this.projectRated.set(false);
241240
this.projectConfirmed.set(false);
241+
this.locallyRatedByCurrentUser.set(false);
242242
}
243243

244244
get canEdit(): boolean {
@@ -251,17 +251,24 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
251251

252252
if (!currentProfile || !project) return false;
253253

254-
return project.scored && project.scoredExpertId === currentProfile.id;
254+
const isExpertFromBackend =
255+
!!project.scoredExpertId && project.scoredExpertId === currentProfile.id;
256+
257+
const isExpertLocally = this.locallyRatedByCurrentUser();
258+
259+
return isExpertFromBackend || isExpertLocally;
255260
}
256261

257262
get showRatingForm(): boolean {
258263
return !this.projectRated() && this.canEdit;
259264
}
260265

261-
get showRatedWithEdit(): boolean {
262-
return (
263-
(this.projectRated() || this.projectConfirmed()) && this.canEdit && this.isCurrentUserExpert
264-
);
266+
get showRatedStatus(): boolean {
267+
return this.projectRated() || this.projectConfirmed();
268+
}
269+
270+
get showEditButton(): boolean {
271+
return this.showRatedStatus && this.canEdit && this.isCurrentUserExpert;
265272
}
266273

267274
get showConfirmedState(): boolean {

0 commit comments

Comments
 (0)