File

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

Extends

LiveAppsComponent

Implements

OnChanges

Metadata

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

Index

Properties
Methods
Inputs
Outputs
HostListeners
Accessors

Constructor

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

Inputs

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

~event creatorSelection : Case Creator selected ~payload LaProcessSelection : LaProcessSelection object output when a creator is selected from a drop down

typeId
Type : string

Outputs

creatorSelection
Type : EventEmitter

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
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

appSchema
Type : CaseTypesList
caseCreatorList
Type : Process[]
caseType
Type : CaseType
Public compareProcessId
Default value : () => {...}
creatorSelector
Type : MatSelect
Decorators :
@ViewChild('creatorSelector', {static: false})
Public formFieldRendering
Type : boolean
Default value : false

Use Form field rendering around the selection box

Private getCaseIDAttributeName
Default value : () => {...}
Public label
Type : string
Default value : 'Case Creators'

Label for the actions selector

Public refresh
Default value : () => {...}
Public reset
Default value : () => {...}
Public selectProcess
Default value : () => {...}
Public typeId
Type : string
Default value : '1'
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

TypeId
setTypeId(typeId: string)
Parameters :
Name Type Optional
typeId string 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, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
import {CaseType, CaseTypesList, Process} from '../../models/liveappsdata';
import {LaProcessSelection} from '../../models/tc-case-processes';
import {LiveAppsComponent} from '../live-apps-component/live-apps-component.component';
import {LiveAppsService} from '../../services/live-apps.service';
import {MatSelect} from '@angular/material/select';

@Component({
  selector: 'tcla-live-apps-creator-selector',
  templateUrl: './live-apps-creator-selector.component.html',
  styleUrls: ['./live-apps-creator-selector.component.css']
})
export class LiveAppsCreatorSelectorComponent extends LiveAppsComponent implements OnChanges {
  @ViewChild('creatorSelector', {static: false}) creatorSelector: MatSelect;
  @Input() sandboxId: number;
  @Input() appId: string;
  public typeId: string = '1';
  @Input('typeId') set TypeId(typeId: string) {
    if (typeId){
      this.typeId = typeId;
    }
  }

  /**
   * ~event creatorSelection : Case Creator selected
   * ~payload LaProcessSelection : LaProcessSelection object output when a creator is selected from a drop down
   */

  /**
   * Pre-select specified creatorId
   */
  @Input() seletedCreatorId: string;

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

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

  @Output() creatorSelection = new EventEmitter<LaProcessSelection>();

  appSchema: CaseTypesList;
  caseType: CaseType;
  caseCreatorList: Process[];

  // run when the user clicks on a case creator
  public selectProcess = (process) => {
    this.creatorSelection.emit(new LaProcessSelection('creator', this.appSchema, this.getCaseIDAttributeName(), process,
      // Format of ref is <applicationName>.<applicationInternalName>.<processType>.<processName>
      (this.caseType.applicationName + '.' + this.caseType.applicationInternalName + '.' + 'creator' + '.' + process.name),
      undefined, undefined, undefined
    ));
  }

  public reset = () => {
    this.creatorSelector.value = undefined;
  }

  private getCaseIDAttributeName = () => {
    let caseIdAttrib: any;
    this.caseType.attributes.forEach((attribute) => {
      if (attribute.isIdentifier) {
        caseIdAttrib = attribute;
      }
    });
    return caseIdAttrib;
  }

  public refresh = () => {
    // retrieve the schema for this case type so we can display case creators and case actions for this case type
    this.liveapps.getCaseTypeSchema(this.sandboxId, this.appId, 100)
    .subscribe(schema => {
      this.appSchema = schema;
      schema.casetypes.forEach((casetype) => {
          // the schema will contain definitions for both the 'case' and any defined types in that case.
          // We want the schema for this 'case'.
          if (casetype.applicationId === this.appId && casetype.id === this.typeId) {
            if (casetype.jsonSchema !== undefined) {
              this.caseType = casetype;
              this.caseCreatorList = casetype.creators ? casetype.creators : [];
              if (this.caseCreatorList.length === 1) {
                this.selectProcess(this.caseCreatorList[0]);
              }
            } else {
              console.error('No schema returned for this case type: You may need to update/re-deploy the live apps application');
            }
          }
        }
      );
    }
    );
  }

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

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

  ngOnChanges(changes: SimpleChanges) {
    if (changes.appId && (changes.appId.currentValue !== changes.appId.previousValue)) {
        this.caseCreatorList = [];
      this.refresh();
    }
  }
}
<div *ngIf="!formFieldRendering && caseCreatorList && caseCreatorList.length > 1" fxFlex style="margin-left: 10px;">
    <span class="tcs-case-creation-dialog-instruction">Select a case creator</span>
    <mat-select #creatorSelector class="tcs-creator-selector-option" [disableOptionCentering]="true"
                placeholder="{{label}}" (selectionChange)="selectProcess($event.value)">
      <mat-option matInput *ngFor="let creator of caseCreatorList" [value]="creator">
        <span>{{creator.name}}</span>
      </mat-option>
    </mat-select>
</div>
<div *ngIf="formFieldRendering" fxFlex>
  <mat-form-field style="width:100%" class="tcs-creator-selector-ff">
    <mat-label>{{label}}</mat-label>
    <mat-select #creatorSelector class="tcs-creator-selector-option-formfield" [compareWith]="compareProcessId" [disableOptionCentering]="true"
                placeholder="{{label}}" (selectionChange)="selectProcess($event.value)">
      <mat-option matInput *ngFor="let creator of caseCreatorList" [value]="creator">
        <span>{{creator.name}}</span>
      </mat-option>
    </mat-select>
  </mat-form-field>
</div>

./live-apps-creator-selector.component.css


:host ::ng-deep  .tcs-creator-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-creator-selector-option .mat-select-arrow-wrapper div {
  color: #0081cb;
}

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

.tcs-creators-box {
  width: 200px;
  height: 44px;
  box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.5);
  background-color: #ffffff;
}

tcs-creator-selector-option {
  width: 170px;
  margin-left: 5px;
  margin-right: 5px;
  height: 20px;
  background-color: #eeeeee;
  padding-left: 20px;
  padding-right: 20px;
  height: 35px;
}

.tcs-case-creation-dialog-instruction {
  font-family: Source Sans Pro;
  font-size: 16px;
  font-weight: 600;
  font-style: normal;
  font-stretch: normal;
  line-height: normal;
  letter-spacing: normal;
  color:#727272;
}


Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""