Skip to content

Commit 0e6e299

Browse files
committed
add button for project adding to program
1 parent c7cd1ae commit 0e6e299

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ <h1 class="info__title">{{ program.name }}</h1>
3333
</div>
3434
</div>
3535
<div class="info__actions">
36+
@if (program.isUserMember || program.isUserManager) {
37+
<app-button (click)="addProject()" customTypographyClass="text-body-12 bar__add-project">
38+
<span class="bar__add-project-text">Добавить проект</span>
39+
<i appIcon icon="plus" appSquare="10"></i>
40+
</app-button>
41+
}
42+
3643
<a
3744
class="info__presentation"
3845
[href]="program.presentationAddress"

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@
9292
}
9393
}
9494

95+
.bar__add-project {
96+
display: flex;
97+
align-items: center;
98+
cursor: pointer;
99+
100+
i {
101+
display: block;
102+
margin-left: 6px;
103+
}
104+
}
105+
106+
.bar__add-project-text {
107+
display: inline;
108+
}
109+
95110
.about {
96111
&__head {
97112
display: flex;

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
ViewChild,
1111
} from "@angular/core";
1212
import { ProgramService } from "@office/program/services/program.service";
13-
import { ActivatedRoute, RouterLink } from "@angular/router";
13+
import { ActivatedRoute, Router, RouterLink } from "@angular/router";
1414
import { concatMap, fromEvent, map, noop, of, Subscription, tap, throttleTime } from "rxjs";
1515
import { Program } from "@office/program/models/program.model";
1616
import { ProgramNewsService } from "@office/program/services/program-news.service";
@@ -24,6 +24,7 @@ import { AvatarComponent } from "@ui/components/avatar/avatar.component";
2424
import { ApiPagination } from "@models/api-pagination.model";
2525
import { TagComponent } from "@ui/components/tag/tag.component";
2626
import { NewsFormComponent } from "@office/shared/news-form/news-form.component";
27+
import { ProjectService } from "@office/services/project.service";
2728

2829
/**
2930
* Главный компонент детальной страницы программы
@@ -91,6 +92,8 @@ export class ProgramDetailMainComponent implements OnInit, OnDestroy {
9192
constructor(
9293
private readonly programService: ProgramService,
9394
private readonly programNewsService: ProgramNewsService,
95+
private readonly projectService: ProjectService,
96+
private readonly router: Router,
9497
private readonly route: ActivatedRoute,
9598
private readonly cdRef: ChangeDetectorRef
9699
) {}
@@ -252,6 +255,19 @@ export class ProgramDetailMainComponent implements OnInit, OnDestroy {
252255
this.readFullDescription = !isExpanded;
253256
}
254257

258+
addProject(): void {
259+
this.projectService.create().subscribe(project => {
260+
this.projectService.projectsCount.next({
261+
...this.projectService.projectsCount.getValue(),
262+
my: this.projectService.projectsCount.getValue().my + 1,
263+
});
264+
265+
this.router
266+
.navigateByUrl(`/office/projects/${project.id}/edit?editingStep=main`)
267+
.then(() => console.debug("Route change from ProjectsComponent"));
268+
});
269+
}
270+
255271
program?: Program;
256272
registerDateExpired!: boolean;
257273
descriptionExpandable!: boolean;

0 commit comments

Comments
 (0)