Remove old error panel to use notifications.
This commit is contained in:
@@ -67,7 +67,7 @@ export class CreateUpdatePostComponent implements OnInit {
|
||||
this.listCategories = [];
|
||||
this.activatedTab = Tabs.EDITION;
|
||||
this.createUpdatePostService.getCategories().subscribe(listCategories => {
|
||||
this.listCategories = listCategories.filter(category => !category.listSubCategories.length);
|
||||
this.listCategories = listCategories.filter(category => !category.listSubCategories);
|
||||
});
|
||||
|
||||
const postKey = this.activatedRoute.snapshot.paramMap.get('postKey');
|
||||
@@ -166,6 +166,7 @@ export class CreateUpdatePostComponent implements OnInit {
|
||||
});
|
||||
} else {
|
||||
this.createUpdatePostService.addPost(this.model).subscribe(post => {
|
||||
NotificationsComponent.success('Article enregistré');
|
||||
this.router.navigate([`/posts/update/${post.key}`]);
|
||||
}, error => {
|
||||
console.log(error);
|
||||
|
||||
@@ -43,9 +43,6 @@
|
||||
<div class="modal-body">
|
||||
<div class="text-center">
|
||||
<p>Êtes vous sûr de vouloir supprimer cet article ?</p>
|
||||
<p *ngIf="postDeletionFailed" class="red-text">
|
||||
Une erreur est survenue lors de la suppression de l'article.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { NotificationsComponent } from 'src/app/core/notifications/notifications.component';
|
||||
import { Component, OnInit, SecurityContext, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
@@ -38,9 +39,7 @@ export class PostComponent implements OnInit {
|
||||
notFound: boolean;
|
||||
owned: boolean;
|
||||
|
||||
@ViewChild('alertDelete', {static: true}) alertDelete;
|
||||
|
||||
postDeletionFailed: boolean;
|
||||
@ViewChild('alertDelete', {static: false}) alertDelete;
|
||||
|
||||
constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
@@ -51,7 +50,6 @@ export class PostComponent implements OnInit {
|
||||
) {
|
||||
this.loaded = false;
|
||||
this.owned = false;
|
||||
this.postDeletionFailed = false;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -91,16 +89,13 @@ export class PostComponent implements OnInit {
|
||||
}
|
||||
|
||||
deletePost(): void {
|
||||
this.postDeletionFailed = false;
|
||||
|
||||
this.postService.deletePost(this.post).subscribe(() => {
|
||||
NotificationsComponent.success('Article supprimé.');
|
||||
this.alertDelete.hide();
|
||||
this.router.navigate(['/myPosts']);
|
||||
}, error => {
|
||||
this.postDeletionFailed = true;
|
||||
setTimeout(() => {
|
||||
this.postDeletionFailed = false;
|
||||
}, 3500);
|
||||
console.error(error);
|
||||
NotificationsComponent.error('Une erreur est survenue lors de la suppression de l\'article.');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user