diff --git a/src/scheduler/scheduleEditModal.component.ts b/src/scheduler/scheduleEditModal.component.ts index d099c6c..c46a3a1 100644 --- a/src/scheduler/scheduleEditModal.component.ts +++ b/src/scheduler/scheduleEditModal.component.ts @@ -1,5 +1,6 @@ // vim: set tw=80 ts=2 sw=2 sts=2: -import { Component, Input, ViewChild } from '@angular/core'; +import { Component, Inject, ViewChild } from '@angular/core'; +import { MdDialogRef, MD_DIALOG_DATA } from '@angular/material'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; @@ -9,32 +10,33 @@ import { ScheduleFormComponent } from './scheduleForm.component'; @Component({ selector: 'schedule-edit-modal', template: ` - +

{{ title() }}

- + - + ` }) export class ScheduleEditModalComponent { - @Input() schedule: Schedule; + private schedule: Schedule; @ViewChild('scheduleForm') scheduleForm: ScheduleFormComponent; - valid: boolean = false; - - constructor(private activeModal: NgbActiveModal) {} + constructor( + @Inject(MD_DIALOG_DATA) public data: any, + public dialogRef: MdDialogRef, + ) { + this.schedule = data.schedule; + } title(): string { if(this.schedule.id) { @@ -57,10 +59,6 @@ export class ScheduleEditModalComponent { schedule.value = formModel.value; schedule.category = formModel.category; - this.activeModal.close(schedule); - } - - cancel(): void { - this.activeModal.dismiss("closed"); + this.dialogRef.close(schedule); } } diff --git a/src/scheduler/scheduleList.component.ts b/src/scheduler/scheduleList.component.ts index 910e286..b5ca17f 100644 --- a/src/scheduler/scheduleList.component.ts +++ b/src/scheduler/scheduleList.component.ts @@ -142,14 +142,16 @@ export class ScheduleListComponent implements OnInit { }; modify(schedule: Schedule) { - const modal = this.ngbModal.open(ScheduleEditModalComponent, { - size: 'lg' + let dialogRef = this.mdDialog.open(ScheduleEditModalComponent, { + data: { + schedule: schedule, + } }); - modal.componentInstance.schedule = schedule; - - modal.result.then((schedule: Schedule) => { - this.save(schedule); + dialogRef.afterClosed().subscribe((schedule: Schedule) => { + if(schedule) { + this.save(schedule); + } }, (reason) => function(reason) { }); }