-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadd-edit.component.ts
47 lines (42 loc) · 1.16 KB
/
add-edit.component.ts
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 { ITask } from './../../models/task';
import { Component, OnInit, Input, ViewChild, Output, EventEmitter, AfterViewInit } from '@angular/core';
@Component({
selector: 'app-add-edit',
templateUrl: './add-edit.component.html',
styleUrls: ['./add-edit.component.css']
})
export class AddEditComponent implements OnInit, AfterViewInit {
@Input() task;
@Output() saveEvent = new EventEmitter();
@Output() modalClose = new EventEmitter();
@ViewChild('bottomSheetModal') modal: any;
modalHeader: string = "Add Task";
currentTask = null;
selectOptions = ['Pending', 'Done'];
constructor() { }
ngOnInit() {
this.initModalContent()
}
ngAfterViewInit() {
this.openModal();
}
initModalContent(){
this.currentTask = Object.assign({}, this.task);
if(this.currentTask.title){
this.modalHeader = "Edit Task";
return;
}
this.currentTask.status = this.selectOptions[0];
}
openModal() {
this.modal.open();
}
closeModal() {
this.modal.close();
this.modalClose.emit();
}
saveData() {
this.closeModal();
this.saveEvent.emit(this.currentTask);
}
}