import { Component , OnInit , OnDestroy } from '@angular/core' ; import { select , Store } from '@ngrx/store' ; import { AutoUnsubscribe } from 'shared-library/shared/decorators' ; import { Subscription } from 'rxjs' ; import { bulkState } from '../../../bulk/store' ; import * as bulkActions from '../../../bulk/store/actions' ; import { AppState } from '../../../store' ; @ Component ( { selector : 'app-bulk' , templateUrl : './bulk.component.html' , styleUrls : [ './bulk.component.scss' ] } ) @ AutoUnsubscribe ( { 'arrayName' : 'subscriptions' } ) export class BulkComponent implements OnInit , OnDestroy { public bulkSummaryDetailPath = 'admin/' ; public bulkSummaryTitle : string ; public showSummaryTable = true ; isArchive : boolean ; isArchiveBtnClicked : boolean ; toggleValue : boolean ; subscriptions : Subscription [ ] = [ ] ; constructor ( private store ) { this . subscriptions . push ( this . store . select ( bulkState ) . pipe ( select ( s => s . getArchiveToggleState ) ) . subscribe ( ( state ) => { if ( state != null ) { this . toggleValue = state ; } else { this . toggleValue = false ; } } ) ) ; this . subscriptions . push ( this . store . select ( bulkState ) . pipe ( select ( s => s . getArchiveList ) ) . subscribe ( ( list ) => { if ( list . length > 0 ) { this . isArchive = true ; } else { this . isArchive = false ; this . isArchiveBtnClicked = false ; } } ) ) ; } ngOnInit ( ) { this . setDefaultTitle ( ) ; } changeTableHeading ( heading ) { if ( heading ) { this . bulkSummaryTitle = heading ; this . showSummaryTable = false ; } } setDefaultTitle ( ) { this . bulkSummaryTitle = 'Bulk Upload Summary' ; } backToSummary ( ) { this . showSummaryTable = true ; this . setDefaultTitle ( ) ; } tapped ( value ) { this . toggleValue = value ; this . store . dispatch ( new bulkActions . SaveArchiveToggleState ( { toggle_state : this . toggleValue } ) ) ; } archiveData ( ) { this . isArchiveBtnClicked = true ; } ngOnDestroy ( ) { } }