@@ -10,7 +10,7 @@ import {
1010 ViewChild ,
1111} from "@angular/core" ;
1212import { ProgramService } from "@office/program/services/program.service" ;
13- import { ActivatedRoute , RouterLink } from "@angular/router" ;
13+ import { ActivatedRoute , Router , RouterLink } from "@angular/router" ;
1414import { concatMap , fromEvent , map , noop , of , Subscription , tap , throttleTime } from "rxjs" ;
1515import { Program } from "@office/program/models/program.model" ;
1616import { ProgramNewsService } from "@office/program/services/program-news.service" ;
@@ -24,6 +24,7 @@ import { AvatarComponent } from "@ui/components/avatar/avatar.component";
2424import { ApiPagination } from "@models/api-pagination.model" ;
2525import { TagComponent } from "@ui/components/tag/tag.component" ;
2626import { 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