File

C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-liveapps-lib/src/lib/components/live-apps-application-list/live-apps-application-list.component.ts

Description

Special rendering of LiveAppsApplicationsComponent

Extends

LiveAppsApplicationsComponent

Implements

OnInit OnChanges

Example

<tcla-live-apps-application-list></tcla-live-apps-application-list>

Metadata

selector tcla-live-apps-application-list
styleUrls ./live-apps-application-list.component.css
templateUrl ./live-apps-application-list.component.html

Index

Properties
Methods
Inputs
Outputs
HostListeners

Inputs

selectedAppIds
Type : string[]
Default value : []

The app Ids selected (output)

appIds
Type : string[]

The list of LA Application IDs you want to handle

formFieldRendering
Type : boolean
label
Type : string
sandboxId
Type : number

sandboxId - this comes from claims resolver

selectedApp
selectedAppId
Type : string

Pre-select specified appId

selectFirstApp
Type : boolean

Whether to auto select the first app in dropdown selector (eg search)

Outputs

appIdsSelected
Type : EventEmitter<string[]>

~event appIdsSelected : Applications selected in component (appIds) ~payload string[] : selected App Ids from the application list (used on config)

appsSelected
Type : EventEmitter<CaseType[]>

~event appsSelected : Applications selected in component (CaseType objects) ~payload CaseType[] : Array of CaseType objects of what was selected

selection
Type : EventEmitter<CaseType>

~event selection : Value selected in child component ~payload CaseType : type varies. but is when something is selected in a drop down it is passed back to the caller

HostListeners

window:resize
Arguments : '$event'
window:resize(event)
Inherited from LiveAppsComponent

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
ngOnInit
ngOnInit()
Returns : void
ngOnInit
ngOnInit()
Returns : void
ngAfterViewInit
ngAfterViewInit()
Inherited from LiveAppsComponent
Returns : void
ngOnDestroy
ngOnDestroy()
Inherited from LiveAppsComponent
Returns : void
ngOnInit
ngOnInit()
Inherited from LiveAppsComponent
Returns : void
setupWidthObserver
setupWidthObserver()
Inherited from LiveAppsComponent
Returns : void

Properties

appSelectionList
Type : MatSelectionList
Decorators :
@ViewChild(MatSelectionList, {static: false})
Private getAppIds
Default value : () => {...}
handleAppSelection
Default value : () => {...}
handleDeselectAll
Default value : () => {...}
handleSelectAll
Default value : () => {...}
Public mySelectedOptions
Type : CaseType[]
Public refresh
Default value : () => {...}
applications
Type : CaseTypesList
Default value : new CaseTypesList()
changeAppSelection
Default value : () => {...}
Public compareProcessId
Default value : () => {...}
errorMessage
Type : string
Public formFieldRendering
Type : boolean
Default value : false

Use Form field rendering around the selection box

Public label
Type : string
Default value : 'Applications'

Label for the application selector

Public refresh
Default value : () => {...}
selectApplication
Default value : () => {...}
Public selectedApp
Type : CaseType
Default value : new CaseType()

Application selected from dropdown (output)

Protected _destroyed$
Default value : new Subject()
Inherited from LiveAppsComponent
componentChildDivs
Type : LiveAppsComponent[]
Decorators :
@ViewChildren('componentChildDiv')
Inherited from LiveAppsComponent
componentDiv
Type : ElementRef
Decorators :
@ViewChild('componentDiv', {static: false})
Inherited from LiveAppsComponent
Protected containerChanges$
Type : Observable<TcComponent>
Inherited from LiveAppsComponent
Private observer
Inherited from LiveAppsComponent
Public resize
Default value : () => {...}
Inherited from LiveAppsComponent
Public widget
Type : TcComponent
Inherited from LiveAppsComponent
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
import {CaseType} from '../../models/liveappsdata';
import {LiveAppsApplicationsComponent} from '../live-apps-applications/live-apps-applications.component';
import {map, take, takeUntil} from 'rxjs/operators';
import { MatSelectionList } from '@angular/material/list';


/**
 * Special rendering of LiveAppsApplicationsComponent
 *
 *@example <tcla-live-apps-application-list></tcla-live-apps-application-list>
 */

@Component({
  selector: 'tcla-live-apps-application-list',
  templateUrl: './live-apps-application-list.component.html',
  styleUrls: ['./live-apps-application-list.component.css']
})
export class LiveAppsApplicationListComponent extends LiveAppsApplicationsComponent implements OnInit, OnChanges {
  @ViewChild (MatSelectionList, {static: false}) appSelectionList: MatSelectionList;

  /**
   * The app Ids selected (output)
   */
  @Input() selectedAppIds: string[] = [];

  /**
   * ~event appsSelected : Applications selected in component (CaseType objects)
   * ~payload CaseType[] : Array of CaseType objects of what was selected
   */
  @Output() appsSelected: EventEmitter<CaseType[]> = new EventEmitter<CaseType[]>();

  /**
   * ~event appIdsSelected : Applications selected in component (appIds)
   * ~payload string[] : selected App Ids from the application list (used on config)
   */
  @Output() appIdsSelected: EventEmitter<string[]> = new EventEmitter<string[]>();


  public mySelectedOptions: CaseType[];

  handleAppSelection = (selectionEvent: CaseType[]) => {
    this.appsSelected.emit(selectionEvent);
    const selIds = [];
    selectionEvent.forEach((selected) => {
      selIds.push(selected.applicationId);
    });
    this.appIdsSelected.emit(selIds);
  }

  handleSelectAll = () => {
    this.mySelectedOptions = this.applications.casetypes;
    this.appIdsSelected.emit(this.getAppIds(this.mySelectedOptions));
    this.appsSelected.emit(this.applications.casetypes);
  }

  handleDeselectAll = () => {
    this.mySelectedOptions = [];
    this.appIdsSelected.emit([]);
    this.appsSelected.emit([]);
  }

  private getAppIds = (casetypes: CaseType[]): string[] => {
    const selIds = [];
    casetypes.forEach((selected) => {
      selIds.push(selected.applicationId);
    });
    return selIds;
  }

  public refresh = (bypassCache: boolean) => {
    this.liveapps.getApplications(this.sandboxId, this.appIds, 100, bypassCache)
      .pipe(
        take(1),
        takeUntil(this._destroyed$),
        map(applicationList => {
          this.applications = applicationList;
          // handle single app selection input
          if (this.selectedApp && this.selectedApp.applicationId) {
            this.selectedApp = applicationList.casetypes.find((casetype) => {
              return casetype.applicationId === this.selectedApp.applicationId;
            });
            // this.selection.emit(this.selectedApp);
          } else if (this.selectedAppIds && this.selectedAppIds.length > 0) {
            // pre select any casetypes that were passed in the selectedAppIds input attribute
            this.mySelectedOptions = this.applications.casetypes.filter(casetype => {
              return (this.selectedAppIds.findIndex((ct) => {
                return ct === casetype.applicationId;
              }
              ) !== -1);
            });
          }
        })
      )
      .subscribe(null, error => { this.errorMessage = 'Error retrieving applications: ' + error.error.errorMsg; });
  }

  ngOnChanges(changes: SimpleChanges) {
    // only interested in initial selection - catching every change would create an infinite loop!
    if (changes.selectedAppIds && (changes.selectedAppIds.firstChange)) {
      this.refresh(false);
    }
  }


  ngOnInit(): void {
    // leave this blank so superclass ngOnInit not called
  }
}
<div fxFlex style="padding: 10px;" fxLayout="column">
  <div fxLayout="row" class="tcs-application-list-buttons">
    <button mat-button (click)="handleSelectAll()">
      <span>Select All</span>
    </button>
    <button mat-button (click)="handleDeselectAll()">
      <span>Deselect All</span>
    </button>
  </div>
  <mat-selection-list class="tcs-application-list" #selectedApps [(ngModel)]="mySelectedOptions" (ngModelChange)="handleAppSelection($event)"
                      fxLayout="column" fxLayout="row wrap">
    <mat-list-option class="tcs-application-option" checkboxPosition="before"
                     *ngFor="let casetype of applications.casetypes"
                     [value]="casetype">
      <span>{{casetype.label}}</span>
    </mat-list-option>
  </mat-selection-list>
</div>

./live-apps-application-list.component.css

 .tcs-application-option {
   max-width: 320px;
 }

 .tcs-application-list {
   overflow: auto;
 }

 .tcs-application-list-buttons {
   min-height: 40px;
 }
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""