Skip to content

Commit

Permalink
feat(reminders): remove directly from note context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Nov 25, 2018
1 parent 75d8703 commit 069a5ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/note/note/note.component.html
Expand Up @@ -22,6 +22,12 @@
<mat-icon>schedule</mat-icon>
{{note.reminderId ? 'Edit' : 'Add'}} reminder
</button>
<button mat-menu-item
*ngIf="note.reminderId"
(click)="removeReminder()">
<mat-icon style="color:#e15d63;">schedule</mat-icon>
Remove reminder
</button>
<button mat-menu-item
(click)="toggleLock()">
<mat-icon *ngIf="note.isLock">lock</mat-icon>
Expand Down
17 changes: 16 additions & 1 deletion src/app/note/note/note.component.ts
Expand Up @@ -3,6 +3,8 @@ 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',
Expand All @@ -18,7 +20,9 @@ export class NoteComponent implements OnInit {

constructor(
private readonly _matDialog: MatDialog,
private readonly _noteService: NoteService
private readonly _noteService: NoteService,
private readonly _snackService: SnackService,
private readonly _reminderService: ReminderService,
) {
}

Expand All @@ -44,4 +48,15 @@ export class NoteComponent implements OnInit {
}
});
}

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',
});

}
}

0 comments on commit 069a5ed

Please sign in to comment.