2020-01-15 17:55:22 +01:00
|
|
|
import {Component, OnInit} from '@angular/core';
|
|
|
|
import {BaseComponent} from "../base-page/base.component";
|
|
|
|
import {ConfigService} from "../../services/config.service";
|
2020-01-20 14:36:26 +01:00
|
|
|
import {mockPoll3} from "../../config/mocks/mock-poll3";
|
|
|
|
import {mockComments} from "../../config/mocks/mock-comments";
|
2020-01-20 15:50:09 +01:00
|
|
|
import {ActivatedRoute} from "@angular/router";
|
2020-01-15 17:55:22 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'framadate-poll-display',
|
|
|
|
templateUrl: './poll-display.component.html',
|
|
|
|
styleUrls: ['./poll-display.component.scss']
|
|
|
|
})
|
|
|
|
export class PollDisplayComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
private pollConfigFetched = mockPoll3;
|
2020-01-16 10:20:15 +01:00
|
|
|
private comments = mockComments;
|
|
|
|
|
2020-01-20 15:50:09 +01:00
|
|
|
constructor(public config: ConfigService,
|
|
|
|
public activeRoute: ActivatedRoute) {
|
2020-01-15 17:55:22 +01:00
|
|
|
super(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
// fetch poll with its ID or slug.
|
2020-01-20 15:50:09 +01:00
|
|
|
const id = this.activeRoute.snapshot.params.poll;
|
|
|
|
if (id) {
|
|
|
|
this.config.pollId = id;
|
|
|
|
// store it in the poll property here
|
|
|
|
this.config.getPollById(id).subscribe(
|
|
|
|
(res: any) => {
|
|
|
|
this.pollConfigFetched = res;
|
|
|
|
}, (e) => {
|
|
|
|
// handle need for a password
|
|
|
|
this.config.handleError(e)
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-15 17:55:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|