aboutsummaryrefslogtreecommitdiff
path: root/app/components/plan-list/plan-list.ts
blob: 888e2e280b1d3817c6914a0298e22fb862b05ad6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {Component, OnInit} from 'angular2/core';
import {ROUTER_DIRECTIVES} from 'angular2/router';

import {IPlan} from '../../interfaces/iplan';
import {PlanService} from '../../services/plan-service';
import {PlanNew} from '../plan-new/plan-new';

import {MomentDatePipe} from '../../pipes';

@Component({
    selector: 'plan-list',
    templateUrl: './components/plan-list/plan-list.html',
    providers: [PlanService],
    directives: [ROUTER_DIRECTIVES, PlanNew],
    pipes: [MomentDatePipe]
})
export class PlanList {
    plans: Array<IPlan>;
    newPlanName: string;
    newPlanContent: any;
    newPlanId: string;
    openDialog: boolean = false;

    constructor(private _planService: PlanService) { }

    ngOnInit() {
        this.plans = this._planService.getPlans();
    }

    requestDelete() {
        this.openDialog = true;
    }

    deletePlan(plan) {
        this.openDialog = false;
        this._planService.deletePlan(plan);
        this.plans = this._planService.getPlans();
    }

    cancelDelete() {
        this.openDialog = false;
    }

    deleteAllPlans() {
        this._planService.deleteAllPlans();
    }
}