-
-
Notifications
You must be signed in to change notification settings - Fork 746
/
note.component.ts
62 lines (52 loc) · 1.7 KB
/
note.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { ChangeDetectionStrategy, Component, Input, OnInit, ViewChild } from '@angular/core';
import { Note } from '../note.model';
import { NoteService } from '../note.service';
import { MatDialog } from '@angular/material';
import { DialogAddNoteReminderComponent } from '../dialog-add-note-reminder/dialog-add-note-reminder.component';
import { ReminderService } from '../../reminder/reminder.service';
import { SnackService } from '../../core/snack/snack.service';
@Component({
selector: 'note',
templateUrl: './note.component.html',
styleUrls: ['./note.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class NoteComponent implements OnInit {
@Input() note: Note;
@Input() isFocus: boolean;
@ViewChild('markdownEl') markdownEl: HTMLElement;
constructor(
private readonly _matDialog: MatDialog,
private readonly _noteService: NoteService,
private readonly _snackService: SnackService,
private readonly _reminderService: ReminderService,
) {
}
ngOnInit() {
}
toggleLock() {
this._noteService.update(this.note.id, {isLock: !this.note.isLock});
}
updateContent(newVal) {
this._noteService.update(this.note.id, {content: newVal.newVal});
}
removeNote() {
this._noteService.remove(this.note.id);
}
editReminder() {
this._matDialog.open(DialogAddNoteReminderComponent, {
data: {
note: this.note,
}
});
}
removeReminder() {
this._reminderService.removeReminder(this.note.reminderId);
this._noteService.update(this.note.id, {reminderId: null});
this._snackService.open({
type: 'SUCCESS',
message: `Deleted reminder ${this.note.reminderId} for note`,
icon: 'schedule',
});
}
}