@@ -8,6 +8,7 @@ import { ErrorMessagesService } from '../../../_messages/error-messages.service'
88import { ProgressSpinnerService } from '../../../_messages/progress-spinner.service' ;
99import { ReferenceComponent } from '../../infra/reference/reference.component' ;
1010import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component' ;
11+ import { BannerService } from '../../../_services/banner.service' ;
1112
1213function getRefreshProps ( refreshConditions ) {
1314 // refreshConditions cuurently supports only "Changes" event
@@ -37,7 +38,6 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
3738 @Input ( ) isCreateStage$ : boolean ;
3839 @Input ( ) updateToken$ : number ;
3940 @Input ( ) isInModal$ = false ;
40- @Input ( ) banners ;
4141
4242 // For interaction with AngularPConnect
4343 angularPConnectData : AngularPConnectData = { } ;
@@ -75,12 +75,15 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
7575 localeCategory = 'Assignment' ;
7676 localeReference ;
7777
78+ snackBarRef ;
79+
7880 constructor (
7981 private angularPConnect : AngularPConnectService ,
8082 private psService : ProgressSpinnerService ,
8183 private erService : ErrorMessagesService ,
8284 private ngZone : NgZone ,
83- private snackBar : MatSnackBar
85+ private snackBar : MatSnackBar ,
86+ public bannerService : BannerService
8487 ) { }
8588
8689 ngOnInit ( ) : void {
@@ -111,6 +114,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
111114 // Should always check the bridge to see if the component should update itself (re-render)
112115 const bUpdateSelf = this . angularPConnect . shouldComponentUpdate ( this ) ;
113116
117+ this . bannerService . updateBanners ( this . itemKey$ ) ;
118+
114119 // ONLY call updateSelf when the component should update
115120 // AND removing the "gate" that was put there since shouldComponentUpdate
116121 // should be the real "gate"
@@ -300,6 +305,10 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
300305 }
301306
302307 buttonClick ( sAction , sButtonType ) {
308+ this . snackBarRef ?. dismiss ( ) ;
309+ this . bannerService . clearBanners ( ) ;
310+ // @ts -ignore
311+ PCore . getPubSubUtils ( ) . publish ( 'clearBannerMessages' ) ;
303312 // right now, done on an individual basis, setting bReInit to true
304313 // upon the next flow container state change, will cause the flow container
305314 // to re-initialize
@@ -335,7 +344,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
335344 } )
336345 . catch ( ( ) => {
337346 this . psService . sendMessage ( false ) ;
338- this . snackBar . open ( `${ this . localizedVal ( 'Navigation failed!' , this . localeCategory ) } ` , 'Ok' ) ;
347+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Navigation failed!' , this . localeCategory ) } ` , 'Ok' ) ;
339348 } ) ;
340349 }
341350 break ;
@@ -354,7 +363,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
354363 } )
355364 . catch ( ( ) => {
356365 this . psService . sendMessage ( false ) ;
357- this . snackBar . open ( `${ this . localizedVal ( 'Save failed' , this . localeCategory ) } ` , 'Ok' ) ;
366+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Save failed' , this . localeCategory ) } ` , 'Ok' ) ;
358367 } ) ;
359368
360369 break ;
@@ -381,7 +390,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
381390 } )
382391 . catch ( ( ) => {
383392 this . psService . sendMessage ( false ) ;
384- this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
393+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
385394 } ) ;
386395 } else {
387396 this . psService . sendMessage ( true ) ;
@@ -400,7 +409,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
400409 } )
401410 . catch ( ( ) => {
402411 this . psService . sendMessage ( false ) ;
403- this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
412+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
404413 } ) ;
405414 }
406415 break ;
@@ -413,23 +422,18 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
413422 switch ( sAction ) {
414423 case 'finishAssignment' :
415424 this . erService . sendMessage ( 'publish' , '' ) ;
416- if ( this . formValid ( ) ) {
417- this . bReInit = true ;
418- this . psService . sendMessage ( true ) ;
419- const finishPromise = this . finishAssignment ( this . itemKey$ ) ; // JA - was itemID but Nebula/Constellation uses itemKey
420- finishPromise
421- . then ( ( ) => {
422- this . psService . sendMessage ( false ) ;
423- this . updateChanges ( ) ;
424- } )
425- . catch ( ( ) => {
426- this . psService . sendMessage ( false ) ;
427- this . snackBar . open ( `${ this . localizedVal ( 'Submit failed!' , this . localeCategory ) } ` , 'Ok' ) ;
428- } ) ;
429- } else {
430- // let snackBarRef = this.snackBar.open("Please fix errors on form.", "Ok");
431- this . erService . sendMessage ( 'show' , this . localizedVal ( 'Please fix errors on form.' , this . localeCategory ) ) ;
432- }
425+ this . bReInit = true ;
426+ this . psService . sendMessage ( true ) ;
427+ const finishPromise = this . finishAssignment ( this . itemKey$ ) ; // JA - was itemID but Nebula/Constellation uses itemKey
428+ finishPromise
429+ . then ( ( ) => {
430+ this . psService . sendMessage ( false ) ;
431+ this . updateChanges ( ) ;
432+ } )
433+ . catch ( ( ) => {
434+ this . psService . sendMessage ( false ) ;
435+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Submit failed!' , this . localeCategory ) } ` , 'Ok' ) ;
436+ } ) ;
433437 break ;
434438 default :
435439 break ;
0 commit comments