projects/common/lib/models/container.ts
        
Container class contains the basic functionality for containers.
Example of how to use Container
export class RegistrationContainerComponent extends Container
     implements AfterViewInit, OnDestroy {
constructor( private headerService: HeaderService,
       private pageStateService: PageStateService,
       protected  containerService: ContainerService) {
super( containerService );
this.setProgressSteps(pages);
this.pageStateService.setPages( pages, PRACTITIONER_REGISTRATION_PAGES );
this.headerService.setTitle('Practitioner Assignment to Medical Services Plan Facility for Business Cost Premium');
}
ngAfterViewInit() {
this.subscribeFormBar();
}
ngOnDestroy() {
this.unsubscribeFormBar();
}
...
}
html would be:
<common-core-breadcrumb>
<common-wizard-progress-bar center [progressSteps]="progressSteps"></common-wizard-progress-bar>
</common-core-breadcrumb>
<common-page-framework layout="blank">
<router-outlet></router-outlet>
</common-page-framework>
<common-form-action-bar (btnClick)="continue()"            <= function within Container
              [submitLabel]="submitLabel"        <= variable within Container
              [isLoading]="isLoading"            <= variable within Container
              [defaultColor]="useDefaultColor"   <= variable within Container
              widthOption='extra-width-mobile-only'></common-form-action-bar>
                        
                        Properties | 
                
                        Methods | 
                
                        
  | 
                
constructor(containerService?: ContainerService)
                     | 
                ||||||
| 
                                 Defined in projects/common/lib/models/container.ts:67 
                             | 
                        ||||||
| 
                             
                                    Parameters :
                                     
                    
  | 
                
| Private _subscriptions | 
                            Type :     Subscription[]
                         | 
                    
| 
                                     Defined in projects/common/lib/models/container.ts:67 
                             | 
                        
| isLoading | 
                            Type :         boolean
                         | 
                    
                            Default value : false
                         | 
                    
| 
                                     Defined in projects/common/lib/models/container.ts:65 
                             | 
                        
| progressSteps | 
                            Type :         WizardProgressItem[]
                         | 
                    
| 
                                     Defined in projects/common/lib/models/container.ts:60 
                             | 
                        
| 
                         Route items for the stepper  | 
                
| submitLabel | 
                            Type :         string
                         | 
                    
                            Default value : DefaultSubmitLabel
                         | 
                    
| 
                                     Defined in projects/common/lib/models/container.ts:64 
                             | 
                        
| useDefaultColor | 
                            Type :         boolean
                         | 
                    
                            Default value : true
                         | 
                    
| 
                                     Defined in projects/common/lib/models/container.ts:63 
                             | 
                        
| 
                         Observables for form bar  | 
                
| continue | 
continue()
                 | 
            
| 
                     Defined in projects/common/lib/models/container.ts:75 
                 | 
            
| 
                     Use when form bar is part of the container 
                        Returns :          
                void
                     | 
            
| convertRouteToTitle | ||||||
convertRouteToTitle(routePath: string)
                 | 
            ||||||
| 
                     Defined in projects/common/lib/models/container.ts:83 
                 | 
            ||||||
| 
                     Converts a lower case string of a route in a user readable title. e.g. "personal-info" -> "Personal Info" 
                        Parameters :
                         
                    
 
                        Returns :          
                    string
                     | 
            
| Protected setProgressSteps | ||||||
                    
                    setProgressSteps(pageRoutes: Route[])
                 | 
            ||||||
| 
                     Defined in projects/common/lib/models/container.ts:87 
                 | 
            ||||||
| 
                     
                        Parameters :
                         
                    
 
                        Returns :          
                    void
                     | 
            
| Protected subscribeFormBar | 
                    
                    subscribeFormBar()
                 | 
            
| 
                     Defined in projects/common/lib/models/container.ts:103 
                 | 
            
| 
                     Subscribe to form bar observables - Called in the AfterViewInit Use when form bar is part of the container 
                        Returns :          
                void
                     | 
            
| Protected unsubscribeFormBar | 
                    
                    unsubscribeFormBar()
                 | 
            
| 
                     Defined in projects/common/lib/models/container.ts:130 
                 | 
            
| 
                     Unsubscribe to form bar observables - Called in the onDestroy() Use when form bar is part of the container 
                        Returns :          
                void
                     | 
            
import { Route } from '@angular/router';
import { ContainerService, DefaultSubmitLabel } from '../services/container.service';
import { Subscription } from 'rxjs';
export interface WizardProgressItem {
  title: string;
  route: string;
}
/**
 * Container class contains the basic functionality for containers.
 *
 * @example
 *  Example of how to use Container
 *
 *      export class RegistrationContainerComponent extends Container
 *                   implements AfterViewInit, OnDestroy {
 *
 *        constructor( private headerService: HeaderService,
 *                     private pageStateService: PageStateService,
 *                     protected  containerService: ContainerService) {
 *          super( containerService );
 *          this.setProgressSteps(pages);
 *          this.pageStateService.setPages( pages, PRACTITIONER_REGISTRATION_PAGES );
 *          this.headerService.setTitle('Practitioner Assignment to Medical Services Plan Facility for Business Cost Premium');
 *        }
 *
 *        ngAfterViewInit() {
 *          this.subscribeFormBar();
 *        }
 *
 *        ngOnDestroy() {
 *          this.unsubscribeFormBar();
 *        }
 *        ...
 *      }
 *
 * html would be:
 *
 *    <common-core-breadcrumb>
 *      <common-wizard-progress-bar center [progressSteps]="progressSteps"></common-wizard-progress-bar>
 *    </common-core-breadcrumb>
 *    <common-page-framework layout="blank">
 *      <router-outlet></router-outlet>
 *    </common-page-framework>
 *    <common-form-action-bar (btnClick)="continue()"            <= function within Container
 *                            [submitLabel]="submitLabel"        <= variable within Container
 *                            [isLoading]="isLoading"            <= variable within Container
 *                            [defaultColor]="useDefaultColor"   <= variable within Container
 *                            widthOption='extra-width-mobile-only'></common-form-action-bar>
 *
 * @export
 *
 */
/** Base functionality for container that is used to display bread crumbs */
export class Container {
  /** Route items for the stepper */
  progressSteps: WizardProgressItem[];
  /** Observables for form bar */
  useDefaultColor: boolean = true;
  submitLabel: string = DefaultSubmitLabel;
  isLoading: boolean = false;
  private _subscriptions: Subscription[];
  constructor( protected containerService?: ContainerService ) {
  }
  /**
   * Use when form bar is part of the container
   */
  continue() {
    this.containerService.submitButtonClicked();
  }
  /**
   * Converts a lower case string of a route in a user readable title.  e.g.
   * "personal-info" -> "Personal Info"
   */
  convertRouteToTitle(routePath: string): string {
    return routePath.split('-').map(x => x[0].toUpperCase() + x.slice(1)).join(' ');
  }
  protected setProgressSteps( pageRoutes: Route[] ): void {
    // Interface for wizard progress items
    this.progressSteps = pageRoutes.map(page => {
      if (page.path !== '') {
        return {
          title: this.convertRouteToTitle(page.path),
          route: page.path
        };
      }
    }).filter(x => x);
  }
  /**
   * Subscribe to form bar observables - Called in the AfterViewInit
   * Use when form bar is part of the container
   */
  protected subscribeFormBar() {
    if ( this.containerService ) {
      this._subscriptions = [
        this.containerService.$useDefaultColor
        .subscribe(
          (async (defaultColor) => {
            this.useDefaultColor = await defaultColor;
        })),
        this.containerService.$submitLabel
        .subscribe(
          (async (label) => {
            this.submitLabel = await label;
        })),
        this.containerService.$isLoading
        .subscribe(
          (async (isLoading) => {
            this.isLoading = await isLoading;
        }))
      ];
    }
  }
  /**
   * Unsubscribe to form bar observables  - Called in the onDestroy()
   * Use when form bar is part of the container
   */
  protected unsubscribeFormBar() {
    this._subscriptions.forEach( x => x.unsubscribe() );
  }
}