Skip to content

Commit bf5469e

Browse files
committed
fix services of program & project to signals, add service for kanban on signals, dto's for project
1 parent c3c458c commit bf5469e

36 files changed

Lines changed: 587 additions & 510 deletions

projects/social_platform/src/app/office/features/detail/detail.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
} } @if (isUserMember && !isUserManager && !isUserExpert) {
8787
<app-button
8888
size="medium"
89-
[style.opacity]="registerDateExpired || isProjectAssigned ? '0.5' : '1'"
90-
[disabled]="!!registerDateExpired || isProjectAssigned"
89+
[style.opacity]="registerDateExpired() || isProjectAssigned ? '0.5' : '1'"
90+
[disabled]="registerDateExpired() || isProjectAssigned"
9191
[appearance]="isProjectAssigned ? 'outline' : 'inline'"
9292
(click)="toggleSubmitProjectModal()"
9393
customTypographyClass="text-body-12 bar__add-project"

projects/social_platform/src/app/office/features/detail/detail.component.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
/** @format */
22

33
import { CommonModule, Location } from "@angular/common";
4-
import { ChangeDetectorRef, Component, inject, OnDestroy, OnInit, signal } from "@angular/core";
4+
import {
5+
ChangeDetectorRef,
6+
Component,
7+
computed,
8+
inject,
9+
OnDestroy,
10+
OnInit,
11+
signal,
12+
} from "@angular/core";
513
import { ButtonComponent, InputComponent } from "@ui/components";
614
import { BackComponent, IconComponent } from "@uilib";
715
import { ModalComponent } from "@ui/components/modal/modal.component";
@@ -64,6 +72,8 @@ export class DeatilComponent implements OnInit, OnDestroy {
6472
private readonly cdRef = inject(ChangeDetectorRef);
6573

6674
// Основные данные(типы данных, данные)
75+
readonly registerDateExpired = this.programDataService.registerDateExpired;
76+
6777
info = signal<any | undefined>(undefined);
6878
profile?: User;
6979
listType: "project" | "program" | "profile" = "project";
@@ -88,7 +98,6 @@ export class DeatilComponent implements OnInit, OnDestroy {
8898

8999
// Сторонние переменные для работы с роутингом или доп проверок
90100
backPath?: string;
91-
registerDateExpired?: boolean;
92101
isInProject?: boolean;
93102

94103
isSended = false;
@@ -422,31 +431,15 @@ export class DeatilComponent implements OnInit, OnDestroy {
422431

423432
private initializeInfo() {
424433
if (this.listType === "project") {
425-
const projectSub$ = this.projectDataService.project$
426-
.pipe(filter(project => !!project))
427-
.subscribe(project => {
428-
this.info.set(project);
429-
430-
if (project?.partnerProgram) {
431-
this.isEditDisable = project.partnerProgram?.isSubmitted;
432-
}
433-
});
434+
const project = this.projectDataService.project;
435+
this.info = project;
434436

435-
this.isInProfileInfo();
437+
this.isEditDisable = this.info()?.partnerProgram?.isSubmitted ?? false;
436438

437-
this.subscriptions.push(projectSub$);
439+
this.isInProfileInfo();
438440
} else if (this.listType === "program") {
439-
const program$ = this.programDataService.program$
440-
.pipe(
441-
filter(program => !!program),
442-
tap(program => {
443-
if (program) {
444-
this.info.set(program);
445-
this.registerDateExpired = Date.now() > Date.parse(program.datetimeRegistrationEnds);
446-
}
447-
})
448-
)
449-
.subscribe();
441+
const program = this.programDataService.program;
442+
this.info = program;
450443

451444
const profileDataSub$ = this.authService.profile.pipe(filter(user => !!user)).subscribe({
452445
next: user => {
@@ -462,7 +455,6 @@ export class DeatilComponent implements OnInit, OnDestroy {
462455
},
463456
});
464457

465-
this.subscriptions.push(program$);
466458
this.subscriptions.push(memeberProjects$);
467459
this.subscriptions.push(profileDataSub$);
468460
} else {

projects/social_platform/src/app/office/models/goals.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ResponsibleInfo {
1717
avatar!: string | null;
1818
}
1919

20-
export class GoalPostForm {
20+
export class GoalDto {
2121
id?: number;
2222
title!: string;
2323
completionDate!: string;

projects/social_platform/src/app/office/models/partner.model.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ interface Company {
66
inn: string;
77
}
88

9-
export interface Partner {
10-
id: number;
11-
projecId: number;
12-
company: Company;
13-
contribution: string;
14-
decisionMaker: number;
9+
export class Partner {
10+
id!: number;
11+
projecId!: number;
12+
company!: Company;
13+
contribution!: string;
14+
decisionMaker!: number;
1515
}
1616

17-
export interface PartnerPostForm {
17+
export interface PartnerDto {
1818
name: string;
1919
inn: string;
2020
contribution: string;

projects/social_platform/src/app/office/models/resource.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface Resource {
88
partnerCompany: number;
99
}
1010

11-
export interface ResourcePostForm {
11+
export interface ResourceDto {
1212
projectId: number;
1313
type: string;
1414
description: string;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @format */
22

3-
export interface Tag {
4-
id: number;
5-
name: string;
6-
color: string;
3+
export class Tag {
4+
id!: number;
5+
name!: string;
6+
color!: string;
77
}

projects/social_platform/src/app/office/program/detail/main/main.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import { AsyncPipe } from "@angular/common";
4141
import { AvatarComponent } from "@uilib";
4242
import { NewsCardComponent } from "@office/features/news-card/news-card.component";
4343
import { TruncatePipe } from "projects/core/src/lib/pipes/truncate.pipe";
44-
import { NewsCardComponent } from "@office/features/news-card/news-card.component";
4544

4645
@Component({
4746
selector: "app-main",
@@ -227,7 +226,7 @@ export class ProgramDetailMainComponent implements OnInit, OnDestroy {
227226
}
228227

229228
@ViewChild(NewsFormComponent) newsFormComponent?: NewsFormComponent;
230-
@ViewChild(ProgramNewsCardComponent) ProgramNewsCardComponent?: ProgramNewsCardComponent;
229+
@ViewChild(NewsCardComponent) ProgramNewsCardComponent?: NewsCardComponent;
231230
@ViewChild("descEl") descEl?: ElementRef;
232231

233232
onNewsInVew(entries: IntersectionObserverEntry[]): void {
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
/** @format */
22

3-
import { Injectable } from "@angular/core";
4-
import { BehaviorSubject } from "rxjs";
3+
import { computed, Injectable, signal } from "@angular/core";
54
import { Program } from "../models/program.model";
65

76
@Injectable({
87
providedIn: "root",
98
})
109
export class ProgramDataService {
11-
private programSubject$ = new BehaviorSubject<Program | undefined>(undefined);
12-
program$ = this.programSubject$.asObservable();
10+
program = signal<Program | undefined>(undefined);
1311

1412
setProgram(program: Program): void {
15-
return this.programSubject$.next(program);
13+
return this.program.set(program);
1614
}
15+
16+
programDateFinished = computed(() => {
17+
const program = this.program();
18+
return program?.datetimeFinished ? Date.now() > Date.parse(program.datetimeFinished) : false;
19+
});
20+
21+
registerDateExpired = computed(() => {
22+
const program = this.program();
23+
return program?.datetimeRegistrationEnds
24+
? Date.now() > Date.parse(program.datetimeRegistrationEnds)
25+
: false;
26+
});
1727
}

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
146146

147147
isProjectCriterias = signal(0);
148148

149-
programDateFinished = signal(false);
149+
readonly programDateFinished = this.programDataService.programDateFinished;
150+
readonly program = this.programDataService.program;
150151

151152
desktopMode$: Observable<boolean> = this.breakpointObserver
152153
.observe("(min-width: 920px)")
@@ -161,19 +162,6 @@ export class RatingCardComponent implements OnInit, AfterViewInit, OnDestroy {
161162
this.projectRated.set(isScored);
162163
}
163164

164-
const program$ = this.programDataService.program$
165-
.pipe(
166-
filter(program => !!program),
167-
tap(program => {
168-
if (program && program.datetimeFinished) {
169-
this.programDateFinished.set(Date.now() > Date.parse(program.datetimeFinished));
170-
}
171-
})
172-
)
173-
.subscribe();
174-
175-
this.subscriptions$().push(program$);
176-
177165
const profileId$ = this.authService.profile.subscribe({
178166
next: profile => {
179167
this.profile.set(profile);

projects/social_platform/src/app/office/projects/detail/chat/chat.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- @format -->
2-
@if (project) {
2+
@if (project()) {
33
<div class="chat-page">
44
<div class="chat-page__main main">
55
@if (!messages.length) {
@@ -30,7 +30,7 @@ <h2 class="info__title text-body-12">участники</h2>
3030
<i appIcon icon="team" appSquare="12"></i>
3131
</header>
3232
<ul class="info__list">
33-
@for (member of project.collaborators; track member.userId) {
33+
@for (member of project()?.collaborators; track member.userId) {
3434
<li class="info__item">
3535
<a class="member" [routerLink]="['/office/profile', member.userId]">
3636
<app-avatar class="member__avatar" [url]="member.avatar" [size]="30"></app-avatar>

0 commit comments

Comments
 (0)