1- import { Component , ElementRef , OnInit , ViewChild } from '@angular/core' ;
1+ import { Component , ElementRef , OnDestroy , OnInit , ViewChild } from '@angular/core' ;
22import { ActivatedRoute , Router } from '@angular/router' ;
33import { isNullOrUndefined , isUndefined } from '@shared/functions' ;
44import {
@@ -56,14 +56,16 @@ const NOTIFICATION_COPY_MANNSCHAFT = 'mannschaft_detail_copy';
5656const NOTIFICATION_DELETE_MANNSCHAFT_SUCCESS = 'mannschaft_detail_delete_success' ;
5757const NOTIFICATION_DELETE_MANNSCHAFT_FAILURE = 'mannschaft_detail_delete_failure' ;
5858const NOTIFICATION_NO_LICENSE = 'no_license_found' ;
59+ const NOTIFICATION_ENTITY_CONFLICT_ERROR = 'ENTITY_CONFLICT_ERROR' ;
60+ const NOTIFICATION_DATABASE_ERROR = 'DATABASE_ERROR' ;
5961const PLATZHALTER_ID = 99 ;
6062
6163@Component ( {
6264 selector : 'bla-verein-detail' ,
6365 templateUrl : './verein-detail.component.html' ,
6466 styleUrls : [ './verein-detail.component.scss' ]
6567} )
66- export class VereinDetailComponent extends CommonComponentDirective implements OnInit {
68+ export class VereinDetailComponent extends CommonComponentDirective implements OnInit , OnDestroy {
6769 public regionType = 'KREIS' ;
6870 public config = VEREIN_DETAIL_CONFIG ;
6971 public config_table = VEREIN_DETAIL_TABLE_CONFIG ;
@@ -80,6 +82,7 @@ export class VereinDetailComponent extends CommonComponentDirective implements O
8082
8183
8284 private sessionHandling : SessionHandling ;
85+ private saveErrorNotificationSubscriptions = [ ] ;
8386
8487 @ViewChild ( 'downloadLink' )
8588 private aElementRef : ElementRef ;
@@ -103,9 +106,15 @@ export class VereinDetailComponent extends CommonComponentDirective implements O
103106 ngOnInit ( ) {
104107 this . loading = true ;
105108 this . notificationService . discardNotification ( ) ;
109+ this . registerSaveErrorReset ( NOTIFICATION_ENTITY_CONFLICT_ERROR ) ;
110+ this . registerSaveErrorReset ( NOTIFICATION_DATABASE_ERROR ) ;
106111 this . loadRegions ( this . regionType ) ; // Request all regions from the backend
107112 }
108113
114+ ngOnDestroy ( ) {
115+ this . saveErrorNotificationSubscriptions . forEach ( ( subscription ) => subscription . unsubscribe ( ) ) ;
116+ }
117+
109118 /** When a MouseOver-Event is triggered, it will call this inMouseOver-function.
110119 * This function calls the checkSessionExpired-function in the sessionHandling class and get a boolean value back.
111120 * If the boolean value is true, then the page will be reloaded and due to the expired session, the user will
@@ -136,6 +145,7 @@ export class VereinDetailComponent extends CommonComponentDirective implements O
136145 }
137146
138147 public onSave ( ignore : any ) : void {
148+ this . notificationService . discardNotification ( ) ;
139149 this . saveLoading = true ;
140150
141151 // persist
@@ -186,6 +196,7 @@ export class VereinDetailComponent extends CommonComponentDirective implements O
186196 }
187197
188198 public onUpdate ( ignore : any ) : void {
199+ this . notificationService . discardNotification ( ) ;
189200 this . saveLoading = true ;
190201
191202 // persist
@@ -618,6 +629,18 @@ export class VereinDetailComponent extends CommonComponentDirective implements O
618629 this . loading = false ;
619630 }
620631
632+ private registerSaveErrorReset ( notificationId : string ) : void {
633+ const subscription = this . notificationService . observeNotification ( notificationId )
634+ . subscribe ( ( notification ) => {
635+ if ( notification . userAction === NotificationUserAction . ACCEPTED
636+ || notification . userAction === NotificationUserAction . DECLINED ) {
637+ this . saveLoading = false ;
638+ }
639+ } ) ;
640+
641+ this . saveErrorNotificationSubscriptions . push ( subscription ) ;
642+ }
643+
621644 private loadMannschaften ( ) {
622645 this . loading = true ;
623646 this . mannschaftsDataProvider . findAllByVereinsId ( this . currentVerein . id )
0 commit comments