|
|
@ -1,5 +1,6 @@ |
|
|
|
import { Component, OnInit } from "@angular/core"; |
|
|
|
import { Component, Inject, OnInit } from "@angular/core"; |
|
|
|
import { ActivatedRoute } from "@angular/router"; |
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; |
|
|
|
|
|
|
|
import { ActivatedRoute, Router } from "@angular/router"; |
|
|
|
import { DetailsNoteDTO, NotesService } from "@shared/api-swagger"; |
|
|
|
import { DetailsNoteDTO, NotesService } from "@shared/api-swagger"; |
|
|
|
import { Subscription } from "rxjs"; |
|
|
|
import { Subscription } from "rxjs"; |
|
|
|
|
|
|
|
|
|
|
@ -14,7 +15,7 @@ export class DetailsNoteComponent implements OnInit{ |
|
|
|
|
|
|
|
|
|
|
|
noteSubscription: Subscription; |
|
|
|
noteSubscription: Subscription; |
|
|
|
|
|
|
|
|
|
|
|
constructor(private noteService: NotesService, private activatedRoute: ActivatedRoute) {} |
|
|
|
constructor(private dialog: MatDialog, private noteService: NotesService, private activatedRoute: ActivatedRoute) {} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
ngOnInit() { |
|
|
|
const id: any = this.activatedRoute.snapshot.paramMap.get("id"); |
|
|
|
const id: any = this.activatedRoute.snapshot.paramMap.get("id"); |
|
|
@ -25,4 +26,35 @@ export class DetailsNoteComponent implements OnInit{ |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
supprimerNote() { |
|
|
|
|
|
|
|
this.dialog.open(DialogSuppressionNoteComponent, { data: this.note}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
|
|
|
selector: "dialog-supprimer-note", |
|
|
|
|
|
|
|
templateUrl: "./dialog-suppression-note.html" |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
export class DialogSuppressionNoteComponent { |
|
|
|
|
|
|
|
noteSubcription: Subscription; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private dialogRef: MatDialogRef<DialogSuppressionNoteComponent>,@Inject(MAT_DIALOG_DATA) public data: DetailsNoteDTO, private noteService: NotesService, private router: Router) {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fermer() {
|
|
|
|
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
supprimer() { |
|
|
|
|
|
|
|
this.noteSubcription = this.noteService.deleteNote(this.data.id).subscribe( |
|
|
|
|
|
|
|
() => {
|
|
|
|
|
|
|
|
this.router.navigate(["/notes"]); |
|
|
|
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
err => console.log(err) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |