From 6cb32cb2e19276e28ee3d6c5bc7777a00edfc8ea Mon Sep 17 00:00:00 2001 From: Tykayn Date: Wed, 21 Apr 2021 12:43:05 +0200 Subject: [PATCH] manage consultation path --- .../core/components/home/home.component.html | 22 ++++++ .../consultation-routing.module.ts | 3 +- .../consultation/consultation.component.html | 70 ++++++++++--------- .../consultation/consultation.component.ts | 47 +++++++++---- src/app/routes-framadate.ts | 2 +- 5 files changed, 94 insertions(+), 50 deletions(-) diff --git a/src/app/core/components/home/home.component.html b/src/app/core/components/home/home.component.html index 7e973eba..afa9dbef 100644 --- a/src/app/core/components/home/home.component.html +++ b/src/app/core/components/home/home.component.html @@ -13,6 +13,28 @@ | translate }} +
+ Environnement de développement: voici des liens de démonstration issus des fixtures Doctrine de + date-poll-api. + + +
image WIP
diff --git a/src/app/features/consultation/consultation-routing.module.ts b/src/app/features/consultation/consultation-routing.module.ts index 9dd3e546..ceeb4b99 100644 --- a/src/app/features/consultation/consultation-routing.module.ts +++ b/src/app/features/consultation/consultation-routing.module.ts @@ -4,7 +4,8 @@ import { RouterModule, Routes } from '@angular/router'; import { ConsultationComponent } from './consultation.component'; const routes: Routes = [ - { path: '', component: ConsultationComponent } + { path: '', component: ConsultationComponent }, + { path: '/:hash', component: ConsultationComponent }, ]; @NgModule({ diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index 7991312b..e7d6eb8c 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -1,45 +1,47 @@
-

Consultation

+

Consultation de {{ pollSlug }}

- -
-
-
-
-

{{ poll.title }}

- -
-
-
-

{{ poll.description }}

-
- - +
+
+
+
+
+
+

{{ poll.title }}

+ +
+
+
+

{{ poll.description }}

+
+ + +
+ +
- -
+
-
-
-
-
- +
+
+ +
-
+ diff --git a/src/app/features/consultation/consultation.component.ts b/src/app/features/consultation/consultation.component.ts index 96925142..34daa626 100644 --- a/src/app/features/consultation/consultation.component.ts +++ b/src/app/features/consultation/consultation.component.ts @@ -1,12 +1,9 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Subscription } from 'rxjs'; - -import { PollConfiguration } from '../../core/models/configuration.model'; import { Poll } from '../../core/models/poll.model'; import { ModalService } from '../../core/services/modal.service'; -import { UserService } from '../../core/services/user.service'; -import { SettingsComponent } from '../../shared/components/settings/settings.component'; +import { PollService } from '../../core/services/poll.service'; @Component({ selector: 'app-consultation', @@ -16,28 +13,50 @@ import { SettingsComponent } from '../../shared/components/settings/settings.com export class ConsultationComponent implements OnInit, OnDestroy { public isCompactMode = true; public poll: Poll; + public pollSlug: string; + public passHash: string; + public fetching: boolean = true; public isArchived: boolean; private routeSubscription: Subscription; constructor( private router: Router, - private activatedRoute: ActivatedRoute, - private userService: UserService, + private _Activatedroute: ActivatedRoute, + public pollService: PollService, private modalService: ModalService ) {} ngOnInit(): void { - if (!this.userService.isCurrentUserIdentifiable()) { - this.modalService.openModal(SettingsComponent); - } - this.routeSubscription = this.activatedRoute.data.subscribe((data: { poll: Poll }) => { - if (data.poll) { - this.poll = data.poll; - this.isArchived = PollConfiguration.isArchived(data.poll.configuration); + console.log('constultation de poll'); + this.pollService.poll.subscribe((newpoll: Poll) => { + this.poll = newpoll; + }); + + this._Activatedroute.paramMap.subscribe((params) => { + console.log('params', params); + this.pollSlug = params.get('slug'); + this.passHash = params.get('hash'); + if (this.passHash) { + this.pollService.loadPollBySlugWithPasswordHash(this.pollSlug, this.passHash); } else { - this.router.navigate(['/page-not-found']); + this.pollService.loadPollBySlug(this.pollSlug).then((resp) => { + console.log('resp', resp); + this.fetching = false; + }); } }); + + // if (!this.userService.isCurrentUserIdentifiable()) { + // this.modalService.openModal(SettingsComponent); + // } + // this.routeSubscription = this.activatedRoute.data.subscribe((data: { poll: Poll }) => { + // if (data.poll) { + // this.poll = data.poll; + // this.isArchived = PollConfiguration.isArchived(data.poll.configuration); + // } else { + // this.router.navigate(['/page-not-found']); + // } + // }); } ngOnDestroy(): void { diff --git a/src/app/routes-framadate.ts b/src/app/routes-framadate.ts index 8c95dacf..05c20a5f 100644 --- a/src/app/routes-framadate.ts +++ b/src/app/routes-framadate.ts @@ -30,7 +30,7 @@ export const routes: Routes = [ { path: 'poll/:slug/consultation', loadChildren: () => import('./features/consultation/consultation.module').then((m) => m.ConsultationModule), - resolve: { poll: PollService }, + // resolve: { poll: PollService }, }, { path: 'poll/:slug/participation',