File

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

Implements

OnChanges

Metadata

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

Index

Properties
Methods
Inputs
Outputs
Accessors

Constructor

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

Inputs

appId
Type : string

The LA Application Id

includeCaseDataPage
Type : boolean
sandboxId
Type : number

sandboxId - this comes from claims resolver

typeId
Type : string

The LA Application Type Id (generally 1)

Outputs

processClicked
Type : EventEmitter<Process>

~event processClicked : Process selected ~payload LaProcessSelection : LaProcessSelection object output when a process is clicked

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void

Properties

caseType
Type : CaseType
Public includeCaseDataPage
Type : boolean
Default value : false

includeCaseDataPage - include case data page as process selection

processes
Type : Process[]
selectedProcess
Type : Process
selectProcess
Default value : () => {...}

Accessors

IncludeCaseDataPage
setIncludeCaseDataPage(includeCaseDataPage: boolean)
Parameters :
Name Type Optional
includeCaseDataPage boolean No
Returns : void
import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
import {LaProcessSelection} from '../../models/tc-case-processes';
import {CaseType, CaseTypesList, JsonSchema, Process} from '../../models/liveappsdata';
import {LiveAppsService} from '../../services/live-apps.service';
import {TcCaseProcessesService} from '../../services/tc-case-processes.service';


@Component({
  selector: 'tcla-live-apps-processes',
  templateUrl: './live-apps-processes.component.html',
  styleUrls: ['./live-apps-processes.component.css']
})
export class LiveAppsProcessesComponent implements OnChanges {

  /**
   * The LA Application Id
   */
  @Input() appId: string;

  /**
   * The LA Application Type Id (generally 1)
   */
  @Input() typeId: string;

  /**
   * sandboxId - this comes from claims resolver
   */
  @Input() sandboxId: number;

  /**
   * includeCaseDataPage - include case data page as process selection
   */
  public includeCaseDataPage: boolean = false;
  @Input('includeCaseDataPage') set IncludeCaseDataPage(includeCaseDataPage: boolean) {
    if (includeCaseDataPage){
      this.includeCaseDataPage = includeCaseDataPage;
    }
  }

  /**
   * ~event processClicked : Process selected
   * ~payload LaProcessSelection : LaProcessSelection object output when a process is clicked
   */
  @Output() processClicked: EventEmitter<Process> = new EventEmitter<Process>();

  caseType: CaseType;
  processes: Process[];
  selectedProcess: Process;

  constructor(protected liveapps: LiveAppsService) { }

  selectProcess = (process: Process) => {
    this.processClicked.emit(process);
  }

  ngOnChanges(changes: SimpleChanges): void {
    if (this.appId && this.typeId && this.sandboxId &&
      (changes.appId.currentValue !== changes.appId.previousValue
        || changes.typeId.currentValue !== changes.typeId.previousValue
        || changes.sandboxId.currentValue !== changes.sandboxId.previousValue)) {
      this.liveapps.getCaseTypeSchema(this.sandboxId, this.appId, 100).subscribe(
        (next: CaseTypesList) => {
          // should only get one main case type back as filtered for this appId
          const caseTypes = next.casetypes.filter(ct => {
            return ct.id === '1';
          });
          if (caseTypes && caseTypes.length > 0) {
            this.caseType = caseTypes[0];
            this.processes = [];
            if (this.includeCaseDataPage) {
              // Format of ref is <applicationName>.<applicationInternalName>.<processType>.<processName>
              const cdProcess = new Process().deserialize(
                {
                  jsonSchema: this.caseType.jsonSchema,
                  name: 'Data Page',
                  id: 'casedata',
                  formTag: this.caseType.applicationName + '.' + this.caseType.applicationInternalName + '.' + 'casedata.default',
                  processType: 'casedata',
                  unsupportedForm: false
                }
              );
              this.processes.push(cdProcess);
            }
            if (this.caseType.creators) {
              this.processes.push(...this.caseType.creators);
            }
            if (this.caseType.actions) {
              this.processes.push(...this.caseType.actions);
            }
          } else {
            console.error('No main case type returned for this application: ', next);
          }
        }
      );
    }
  }

}
<div style="margin-left: 10px" fxFlex>
  <mat-form-field style="width:100%">
    <mat-label>Process</mat-label>
    <mat-select (selectionChange)="selectProcess($event.value)">
      <mat-option *ngFor="let process of processes" [value]="process">
        {{process.name}} ({{process.processType}})
      </mat-option>
    </mat-select>
  </mat-form-field>

</div>

./live-apps-processes.component.css

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""