File

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

Description

Lists live apps applications in drop down list allowing selection of app

alt-text

Extends

LiveAppsComponent

Implements

OnInit

Example

<tcla-live-apps-applications></tcla-live-apps-applications>

Metadata

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

Index

Properties
Methods
Inputs
Outputs
HostListeners
Accessors

Constructor

constructor(liveapps: LiveAppsService)
Parameters :
Name Type Optional
liveapps LiveAppsService No

Inputs

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

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

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

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

Accessors

SelectedApp
setSelectedApp(selectedApp)
Parameters :
Name Optional
selectedApp No
Returns : void
FormFieldRendering
setFormFieldRendering(formFieldRendering: boolean)
Parameters :
Name Type Optional
formFieldRendering boolean No
Returns : void
Label
setLabel(label: string)
Parameters :
Name Type Optional
label string No
Returns : void
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
import {LiveAppsService} from '../../services/live-apps.service';
import {CaseInfo, CaseType, CaseTypesList} from '../../models/liveappsdata';
import {map, take, takeUntil} from 'rxjs/operators';
import {Subject} from 'rxjs';
import {LiveAppsComponent} from '../live-apps-component/live-apps-component.component';


/**
 * Lists live apps applications in drop down list allowing selection of app
 *
 * ![alt-text](../live-apps-applications.png "Image")
 *
 *@example <tcla-live-apps-applications></tcla-live-apps-applications>
 */

@Component({
  selector: 'tcla-live-apps-applications',
  templateUrl: './live-apps-applications.component.html',
  styleUrls: ['./live-apps-applications.component.css']
})

export class LiveAppsApplicationsComponent extends LiveAppsComponent implements OnInit {
  /**
   * sandboxId - this comes from claims resolver
   */
  @Input() sandboxId: number;

  /**
   * The list of LA Application IDs you want to handle
   */
  @Input() appIds: string[];

  /**
   * Whether to auto select the first app in dropdown selector (eg search)
   */
  @Input() selectFirstApp: boolean;

  /**
   * Application selected from dropdown (output)
   */
  public selectedApp: CaseType = new CaseType();
  @Input('selectedApp') set SelectedApp(selectedApp: CaseType) {
    if (selectedApp){
      this.selectedApp = selectedApp;
    }
  }

  /**
   * Use Form field rendering around the selection box
   */
  public formFieldRendering: boolean = false;
  @Input('formFieldRendering') set FormFieldRendering(formFieldRendering: boolean) {
    if (formFieldRendering){
      this.formFieldRendering = formFieldRendering;
    }
  }

  /**
   * Pre-select specified appId
   */

  @Input() selectedAppId: string;

  /**
   * Label for the application selector
   */
  public label: string = 'Applications';
  @Input('label') set Label(label: string) {
    if (label){
      this.label = label;
    }
  }

  /**
   * ~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
   */
  @Output() selection: EventEmitter<CaseType> = new EventEmitter<CaseType>();

  applications: CaseTypesList = new CaseTypesList();
  // selectedApp: CaseType = new CaseType();
  errorMessage: string;

  constructor(protected liveapps: LiveAppsService) {
    super();
  }

  changeAppSelection = (appSelected: CaseType) => {
    this.selectedApp = this.applications.casetypes.find((casetype) => {
      return casetype.applicationId === appSelected.applicationId;
    });
  }

  selectApplication = (selectionEvent) => {
    this.selectedApp = selectionEvent.source.value;
    this.selection.emit(selectionEvent.source.value);
  }

  public refresh = (bypassCache: boolean) => {
    this.liveapps.getApplications(this.sandboxId, this.appIds, 100, bypassCache)
      .pipe(
        take(1),
        takeUntil(this._destroyed$)
      )
      .subscribe(applicationList => {
        this.applications = applicationList;
        if (this.selectedApp.applicationId) {
          this.selectedApp = applicationList.casetypes.find((casetype) => {
            return casetype.applicationId === this.selectedApp.applicationId;
          });
          // this.selection.emit(this.selectedApp);
        } else
        // select first as default
        if (applicationList.casetypes.length > 0 && this.selectFirstApp) {
          this.selectedApp = applicationList.casetypes[0];
          this.selection.emit(applicationList.casetypes[0]);
        }
      }, error => { this.errorMessage = 'Error retrieving applications: ' + error.error.errorMsg; });
  }

  public compareProcessId = (o1: any, o2: any): boolean => {
    return o1.applicationId === this.selectedAppId;
  }

  ngOnInit(): void {
    this.refresh(false);
  }

}
<div *ngIf="!formFieldRendering" class="tcs-application-selector" fxFlex style="margin-left: 10px;">
  <mat-label></mat-label>
  <mat-select *ngIf="selectedApp" class="tcs-application-selector-option" [disableOptionCentering]="true"
              placeholder="{{label}}" [(value)]="selectedApp" [compareWith]="compareProcessId"
              (selectionChange)="selectApplication($event)" matTooltip="{{selectedApp.applicationName}}"
              matTooltipShowDelay="1000" matTooltipPosition="below">
    <mat-option matInput *ngFor="let application of applications.casetypes" [value]="application">
      {{application.label | ellipsis : 20}}
    </mat-option>
  </mat-select>
</div>
<div *ngIf="formFieldRendering" fxFlex>
  <mat-form-field style="width:100%">
    <mat-label>{{label}}</mat-label>
    <mat-select *ngIf="selectedApp" [disableOptionCentering]="true" placeholder="{{label}}" [(value)]="selectedApp"
                (selectionChange)="selectApplication($event)" [compareWith]="compareProcessId"
                matTooltip="{{selectedApp.applicationName}}" matTooltipShowDelay="1000" matTooltipPosition="below">
      <mat-option matInput *ngFor="let application of applications.casetypes" [value]="application">
        {{application.label}}
      </mat-option>
    </mat-select>
  </mat-form-field>
</div>


<!--div *ngIf="errorMessage">{{errorMessage}}</div>
<div *ngIf="applications" class="la-applications-div" fxLayoutAlign="space-around start">
  <div class="la-applications-card" fxLayout="column">
    <h3>Select application:</h3>
    <div class="la-application-selection">
      <div class="la-available-sub" (click)="selectApplication(application)" *ngFor="let application of applications.casetypes">
        <div class="la-application-name">{{application.applicationName}}</div>
        <div fxLayout="column" class="la-application-selection-dtl" fxLayoutAlign="start start">
          <div>Application Id: {{application.applicationId}}</div>
          <div>Type Id: {{application.id}}</div>
        </div>
      </div>
    </div>
  </div>
</div-->

./live-apps-applications.component.css

::ng-deep .tcs-application-selector .mat-form-field-underline {
  display: none;
}

:host ::ng-deep .tcs-application-selector .mat-select-value {
  min-width: 100px;
  max-width: 100%;
  width: auto;
}

:host ::ng-deep .tcs-application-selector .tcs-application-selector-option .mat-select-value span {
  font-family: Source Sans Pro;
  font-size: 16px;
  font-weight: normal;
  font-style: normal;
  font-stretch: normal;
  line-height: 1.5;
  letter-spacing: 0.3px;
  color: #0081cb;
}

:host ::ng-deep .tcs-application-selector .tcs-application-selector-option .mat-select-arrow-wrapper div {
  color: #0081cb;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""