File

src/app/pages/poll-display/poll-display.component.ts

Extends

BaseComponent

Implements

OnInit

Metadata

selector framadate-poll-display
styleUrls ./poll-display.component.scss
templateUrl ./poll-display.component.html

Index

Properties
Methods

Constructor

constructor(config: ConfigService, router: Router, activeRoute: ActivatedRoute)
Parameters :
Name Type Optional
config ConfigService No
router Router No
activeRoute ActivatedRoute No

Methods

fetchPoll
fetchPoll()
Returns : void
ngOnInit
ngOnInit()
Returns : void
checkValidity
checkValidity()
Inherited from BaseComponent
Defined in BaseComponent:21
Returns : boolean
displayErrorMessage
displayErrorMessage()
Inherited from BaseComponent
Defined in BaseComponent:27
Returns : boolean
ngOnInit
ngOnInit()
Inherited from BaseComponent
Defined in BaseComponent:17
Returns : void

Properties

Public activeRoute
Type : ActivatedRoute
comments
Default value : mockComments
Public config
Type : ConfigService
Public config
Type : ConfigService
Inherited from BaseComponent
Defined in BaseComponent:14
import {Component, OnInit} from '@angular/core';
import {BaseComponent} from "../base-page/base.component";
import {ConfigService} from "../../services/config.service";
import {mockComments} from "../../config/mocks/mock-comments";
import {ActivatedRoute, Router} from "@angular/router";
import {environment} from "../../../environments/environment";
import {mockPoll3} from "../../config/mocks/mock-poll3";

@Component({
    selector: 'framadate-poll-display',
    templateUrl: './poll-display.component.html',
    styleUrls: ['./poll-display.component.scss']
})
export class PollDisplayComponent extends BaseComponent implements OnInit {

    comments = mockComments;

    constructor(public config: ConfigService,
                private router: Router,
                public activeRoute: ActivatedRoute) {
        super(config);
        this.activeRoute.paramMap.subscribe(params => {
            console.log('params', params);
            this.config.pollId = params.get('poll');
            this.config.pollSlug = params.get('pollSlug');
            if (!this.config.loading) {
                this.fetchPoll();
            }
        });
    }

    ngOnInit() {

    }


    // fetch poll with its ID or slug.
    fetchPoll() {
        const id = this.activeRoute.snapshot.params.poll;
        const pollSlug = this.activeRoute.snapshot.params.pollSlug;

        if (!environment.production) {
            console.log('mockPoll3', mockPoll3);
            this.config.currentPoll = mockPoll3;
            return;
        }
        if (id) {
            this.config.loading = true;
            // store it in the poll property here
            this.config.getPollById(id).subscribe(
                (res: any) => {
                    console.log('res', res);
                    this.config.updateCurrentPollFromResponse(res);
                    this.config.loading = false;
                }, (e) => {
                    // handle need for a password
                    console.log('e', e);
                    this.config.handleError(e)
                }
            );
        } else if (pollSlug) {
            this.config.loading = true;
            this.config.getPollByURL(pollSlug).subscribe(
                (res: any) => {
                    this.config.loading = false;
                    this.config.updateCurrentPollFromResponse(res);
                }, (e) => {
                    // handle need for a password
                    this.config.handleError(e)
                }
            );
        }

    }

}
<div
    class="poll"
>
    <div
        class='loading'
        *ngIf='config.loading' >
        <i class='fa fa-refresh fa-spin' ></i >
    </div >
    <div
        class='loaded-poll'
        *ngIf='!config.loading && config.currentPoll' >

        <div id='choices' >

            <framadate-choices-list ></framadate-choices-list >
        </div >
        <div id='table' >
            <!--        <framadate-voting-navigation ></framadate-voting-navigation >-->
            <framadate-voting-summary ></framadate-voting-summary >
        </div >
        <div id='poll_comments' >
            <framadate-comments-list ></framadate-comments-list >
        </div >
        <div id='graph' >
            <!--<framadate-voting-graph ></framadate-voting-graph >-->
        </div >
        <div id='export_and_share' >

            <div
                class="sharing"
                *ngIf='config.currentPoll' >
                <h3 class="margin-top-x8" >Partager le sondage

                    <i class='fa fa-share' ></i ></h3 >
                <p
                    class="nobold text-14"
                    for="copyLink" >Pour partager le sondage, vous pouvez diffuser ce lien :
                    <a href='{{config.currentPoll.urlPublic}}' >
                        {{config.currentPoll.urlPublic}}
                    </a >
                </p >

                <framadate-copy-text [textToCopy]='config.currentPoll.urlPublic' ></framadate-copy-text >
                <h3 class="margin-top-x6 margin-btm-x3" >
                    Exporter/Imprimer
                </h3 >
                <input
                    type="submit"
                    name="export"
                    class="margin-btm-x3 btn btn--primary btn--outline"
                    value="Exporter en .csv"
                    (click)="config.exportCSV()" >
                <input
                    type="submit"
                    name="copy-link"
                    class="btn btn--primary btn--outline"
                    value="Imprimer le sondage"
                    (click)="config.print()" >
            </div >

        </div >
    </div >
    <div
        class='badly-loaded'
        *ngIf='config.loading && !config.currentPoll' >
        <div class='well is-warning' >

            No current poll available
        </div >
    </div >

</div >

./poll-display.component.scss

@import "../../../assets/scss/variables";


Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""