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