@@ -6,6 +6,7 @@ import { FormGroup } from '@angular/forms';
66import { AngularPConnectData , AngularPConnectService } from '../../../_bridge/angular-pconnect' ;
77import { ErrorMessagesService } from '../../../_messages/error-messages.service' ;
88import { ProgressSpinnerService } from '../../../_messages/progress-spinner.service' ;
9+ import { BannerService } from '../../../_services/banner.service' ;
910import { ReferenceComponent } from '../../infra/reference/reference.component' ;
1011import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component' ;
1112
@@ -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 = { } ;
@@ -77,12 +77,15 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
7777 localeCategory = 'Assignment' ;
7878 localeReference ;
7979
80+ snackBarRef ;
81+
8082 constructor (
8183 private angularPConnect : AngularPConnectService ,
8284 private psService : ProgressSpinnerService ,
8385 private erService : ErrorMessagesService ,
8486 private ngZone : NgZone ,
85- private snackBar : MatSnackBar
87+ private snackBar : MatSnackBar ,
88+ public bannerService : BannerService
8689 ) { }
8790
8891 ngOnInit ( ) : void {
@@ -113,6 +116,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
113116 // Should always check the bridge to see if the component should update itself (re-render)
114117 const bUpdateSelf = this . angularPConnect . shouldComponentUpdate ( this ) ;
115118
119+ this . bannerService . updateBanners ( this . itemKey$ ) ;
120+
116121 // ONLY call updateSelf when the component should update
117122 // AND removing the "gate" that was put there since shouldComponentUpdate
118123 // should be the real "gate"
@@ -295,6 +300,9 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
295300 }
296301
297302 buttonClick ( sAction , sButtonType ) {
303+ this . snackBarRef ?. dismiss ( ) ;
304+ this . bannerService . clearBanners ( ) ;
305+ PCore . getPubSubUtils ( ) . publish ( 'clearBannerMessages' ) ;
298306 // right now, done on an individual basis, setting bReInit to true
299307 // upon the next flow container state change, will cause the flow container
300308 // to re-initialize
@@ -318,21 +326,21 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
318326 switch ( sAction ) {
319327 case 'navigateToStep' :
320328 this . erService . sendMessage ( 'publish' , '' ) ;
321- if ( this . formValid ( ) ) {
322- this . bReInit = true ;
323- this . psService . sendMessage ( true ) ;
324329
325- const navigatePromise = this . navigateToStep ( 'previous' , this . itemKey$ ) ;
326- navigatePromise
327- . then ( ( ) => {
328- this . updateChanges ( ) ;
329- this . psService . sendMessage ( false ) ;
330- } )
331- . catch ( ( ) => {
332- this . psService . sendMessage ( false ) ;
333- this . snackBar . open ( `${ this . localizedVal ( 'Navigation failed!' , this . localeCategory ) } ` , 'Ok' ) ;
334- } ) ;
335- }
330+ this . bReInit = true ;
331+ this . psService . sendMessage ( true ) ;
332+
333+ const navigatePromise = this . navigateToStep ( 'previous' , this . itemKey$ ) ;
334+ navigatePromise
335+ . then ( ( ) => {
336+ this . updateChanges ( ) ;
337+ this . psService . sendMessage ( false ) ;
338+ } )
339+ . catch ( ( ) => {
340+ this . psService . sendMessage ( false ) ;
341+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Navigation failed!' , this . localeCategory ) } ` , 'Ok' ) ;
342+ } ) ;
343+
336344 break ;
337345
338346 case 'saveAssignment' : {
@@ -348,7 +356,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
348356 } )
349357 . catch ( ( ) => {
350358 this . psService . sendMessage ( false ) ;
351- this . snackBar . open ( `${ this . localizedVal ( 'Save failed' , this . localeCategory ) } ` , 'Ok' ) ;
359+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Save failed' , this . localeCategory ) } ` , 'Ok' ) ;
352360 } ) ;
353361
354362 break ;
@@ -372,7 +380,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
372380 } )
373381 . catch ( ( ) => {
374382 this . psService . sendMessage ( false ) ;
375- this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
383+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
376384 } ) ;
377385 } else {
378386 this . psService . sendMessage ( true ) ;
@@ -389,7 +397,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
389397 } )
390398 . catch ( ( ) => {
391399 this . psService . sendMessage ( false ) ;
392- this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
400+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Cancel failed!' , this . localeCategory ) } ` , 'Ok' ) ;
393401 } ) ;
394402 }
395403 break ;
@@ -401,7 +409,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
401409 . then ( ( ) => { } )
402410 . catch ( ( ) => {
403411 this . psService . sendMessage ( false ) ;
404- this . snackBar . open ( `${ this . localizedVal ( 'Rejection failed!' , this . localeCategory ) } ` , 'Ok' ) ;
412+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Rejection failed!' , this . localeCategory ) } ` , 'Ok' ) ;
405413 } ) ;
406414
407415 break ;
@@ -414,23 +422,18 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
414422 switch ( sAction ) {
415423 case 'finishAssignment' :
416424 this . erService . sendMessage ( 'publish' , '' ) ;
417- if ( this . formValid ( ) ) {
418- this . bReInit = true ;
419- this . psService . sendMessage ( true ) ;
420- const finishPromise = this . finishAssignment ( this . itemKey$ ) ; // JA - was itemID but Nebula/Constellation uses itemKey
421- finishPromise
422- . then ( ( ) => {
423- this . psService . sendMessage ( false ) ;
424- this . updateChanges ( ) ;
425- } )
426- . catch ( ( ) => {
427- this . psService . sendMessage ( false ) ;
428- this . snackBar . open ( `${ this . localizedVal ( 'Submit failed!' , this . localeCategory ) } ` , 'Ok' ) ;
429- } ) ;
430- } else {
431- // let snackBarRef = this.snackBar.open("Please fix errors on form.", "Ok");
432- this . erService . sendMessage ( 'show' , this . localizedVal ( 'Please fix errors on form.' , this . localeCategory ) ) ;
433- }
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+ } ) ;
434437 break ;
435438
436439 case 'approveCase' : {
@@ -440,7 +443,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
440443 . then ( ( ) => { } )
441444 . catch ( ( ) => {
442445 this . psService . sendMessage ( false ) ;
443- this . snackBar . open ( `${ this . localizedVal ( 'Approve failed!' , this . localeCategory ) } ` , 'Ok' ) ;
446+ this . snackBarRef = this . snackBar . open ( `${ this . localizedVal ( 'Approve failed!' , this . localeCategory ) } ` , 'Ok' ) ;
444447 } ) ;
445448
446449 break ;
0 commit comments