File

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

Description

Wraps rendering an execution of an action

Extends

LiveAppsCaseCreatorComponent

Implements

OnInit OnChanges

Example

<tcla-live-apps-case-action></tcla-live-apps-case-action>

Metadata

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

Index

Properties
Methods
Inputs
Outputs
HostListeners
Accessors

Constructor

constructor(lasvc: LiveAppsService, tcfcs: TcFormConfigService)
Parameters :
Name Type Optional
lasvc LiveAppsService No
tcfcs TcFormConfigService No

Inputs

caseRef
Type : string

The case reference

formsFramework
Type : string
legacyActions
Type : boolean
showHeader
Type : boolean

Whether to show the header bar in the widget - eg. favorites on home page (contains icon etc) - if off icons still appear without bar

applicationId
Type : string

LA application ID

customFormDefs
Type : CustomFormDefs

Custom Form configuration file

dataOverride
Type : any

Data object that will be displayed on the form. Allows overriding over form data (eg. when selecting data in spotfire)

formConfig
formsFramework
Type : string
legacyCreators
Type : boolean
process
Type : LaProcessSelection

The process definition of the action or creator to execute

sandboxId
Type : number

sandboxId - this comes from claims resolver

typeId
Type : string

The LA Application Type Id (generally 1)

Outputs

caseChanged
Type : EventEmitter<ProcessId>

~event caseChanged : Case action started (process started) ~payload ProcessId : ProcessId object passed when a case has been updated or created by a process (action/creator)

HostListeners

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

Methods

Private getMainCaseTypeFromSchema
getMainCaseTypeFromSchema(typeId: string, process: LaProcessSelection)
Parameters :
Name Type Optional
typeId string No
process LaProcessSelection No
Returns : CaseType
ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
ngOnInit
ngOnInit()
Returns : void
initialize
initialize()
Returns : void
ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
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

actionFormWc
Type : LiveAppsFormWcComponent
Decorators :
@ViewChild('actionFormWc', {static: false})
Private buildWcFormConfig
Default value : () => {...}
Public cancelAction
Default value : () => {...}
caseState
Type : string
Public formsFramework
Type : string
Default value : 'material-design'

Allow override of forms framework Options: bootstrap-4 or material-design

Private getCaseData
Default value : () => {...}
Public legacyActions
Type : boolean
Default value : false

Enable legacy actions

legacyProcessComponent
Type : LiveAppsLegacyProcessComponent
Decorators :
@ViewChild(LiveAppsLegacyProcessComponent, {static: false})
originalData
Type : any
selectedFormConfig
Type : ProcessFormConfig
test
Default value : () => {...}
wcFormConfig
Type : LiveAppsFormConfig
data
Type : any
Public formConfig
Type : FormConfig
Default value : new FormConfig()

Custom Form Layout Configuration

formRef
Type : any
Public formsFramework
Type : string
Default value : 'material-design'

Allow override of forms framework Options: bootstrap-4 or material-design

Public handleFormOpen
Default value : () => {...}
handleLegacyProcessCancelled
Default value : () => {...}
handleLegacyProcessComplete
Default value : () => {...}
handleSubmit
Default value : () => {...}
isCustomForm
Default value : false
layout
Type : any[]
Public legacyCreators
Type : boolean
Default value : false

Enable legacy creators

options
Type : any
schema
Type : any
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

LegacyActions
setLegacyActions(legacyActions: boolean)
Parameters :
Name Type Optional
legacyActions boolean No
Returns : void
FormsFramework
setFormsFramework(formsFramework: string)
Parameters :
Name Type Optional
formsFramework string No
Returns : void
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
import {LiveAppsCaseCreatorComponent} from '../live-apps-case-creator/live-apps-case-creator.component';
import {LiveAppsService} from '../../services/live-apps.service';
import {map, take, takeUntil} from 'rxjs/operators';
import {CaseType, ProcessId} from '../../models/liveappsdata';
import {LaProcessSelection} from '../../models/tc-case-processes';
import {LiveAppsLegacyProcessComponent} from '../live-apps-legacy-process/live-apps-legacy-process.component';
import {TcFormConfigService} from '../../services/tc-form-config.service';
import {LiveAppsFormConfig} from '../../models/tc-liveapps-form';
import {FormConfig, ProcessFormConfig} from '../../models/tc-liveapps-config';
import {LiveAppsFormWcComponent} from '../live-apps-form-wc/live-apps-form-wc.component';


/**
 * Wraps rendering an execution of an action
 *
 *@example <tcla-live-apps-case-action></tcla-live-apps-case-action>
 */

@Component({
  selector: 'tcla-live-apps-case-action',
  templateUrl: './live-apps-case-action.component.html',
  styleUrls: ['./live-apps-case-action.component.css']
})
export class LiveAppsCaseActionComponent extends LiveAppsCaseCreatorComponent implements OnInit, OnChanges {
  /**
   * The case reference
   */
  @Input() caseRef: string;

  /**
   * Whether to show the header bar in the widget - eg. favorites on home page (contains icon etc) - if off icons still appear without bar
   */
  @Input() showHeader: boolean;

  /**
   * Enable legacy actions
   */
  public legacyActions: boolean = false;
  @Input('legacyActions') set LegacyActions(legacyActions: boolean) {
    if (legacyActions){
      this.legacyActions = legacyActions;
    }
  }

  /**
   * Allow override of forms framework
   * Options: bootstrap-4 or material-design
   */
  public formsFramework: string = 'material-design';
  @Input('formsFramework') set FormsFramework(formsFramework: string) {
    if (formsFramework){
      this.formsFramework = formsFramework;
    }
  }


  @ViewChild(LiveAppsLegacyProcessComponent, {static: false}) legacyProcessComponent: LiveAppsLegacyProcessComponent;
  @ViewChild('actionFormWc', {static: false}) actionFormWc: LiveAppsFormWcComponent;

  originalData: any;
  caseState: string;
  wcFormConfig: LiveAppsFormConfig;
  selectedFormConfig: ProcessFormConfig;

  private getMainCaseTypeFromSchema(typeId: string, process: LaProcessSelection): CaseType {
    let requestedType: CaseType;
    process.appSchema.casetypes.forEach((cType) => {
      if (cType.id === typeId) {
        requestedType = cType;
      }
    });
    return requestedType;
  }

  test = (event) => {
    console.log(event);
  }

  private getCaseData = (caseRef) => {
    // retrieve the case data for this case reference
    this.data = undefined;
    this.caseState = undefined;
    this.liveapps.getCase(this.caseRef, this.sandboxId, this.applicationId, this.typeId )
      .pipe(
        take(1),
        takeUntil(this._destroyed$)
      )
      .subscribe(result => {
        if (result.metadata.applicationId === this.applicationId.toString()) {
          const casedata = result.untaggedCasedataObj;
          this.caseState = casedata.state;
          this.originalData = {
            [this.process.process.name]: casedata
          };
          // JS: use name rather than internalObjectName to handle appliction name change
          const caseTypeName = this.getMainCaseTypeFromSchema(this.typeId, this.process).name;
          this.data = {
            [caseTypeName]: casedata
          };
        } else {
          console.error('The selected case is not the right case type for this action');
        }
      }, error => {
        // Emit any error retrieving case data to the parent
        console.error('Unable to retrieve case data');
        console.error(error);
      });
  }

  public cancelAction = () => {
    if (this.legacyProcessComponent) {
      this.legacyProcessComponent.cancelProcess();
    }
    if (this.actionFormWc) {
      this.actionFormWc.cancel();
    }
    if (this.formRef) {
      // this.formRef.detail.form.destroy();
      this.formRef.detail.form.invokeAction('cancel');
      this.formRef = undefined;
    }
  }

  constructor(protected lasvc: LiveAppsService, protected tcfcs: TcFormConfigService) {
    super(lasvc, tcfcs);
  }

  private buildWcFormConfig = (process: LaProcessSelection, selectedFormConfig: ProcessFormConfig, caseRef: string) => {
    this.wcFormConfig = new LiveAppsFormConfig().deserialize({
      type: 'action',
      id: process.action.id,
      sandbox: this.sandboxId.toString(),
      formDivId: 'actionDialogDiv',
      useCustomForm: (selectedFormConfig && selectedFormConfig.externalForm) ? selectedFormConfig.externalForm.toString() : false,
      name: process.action.name,
      label: process.action.label,
      version: process.action.version.toString(),
      applicationId: process.action.applicationId,
      applicationName: process.action.applicationName,
      activityId: process.action.activityId,
      activityName: process.action.activityName,
      caseRef: caseRef,
      formRef: process.ref
    });
  }

  ngOnInit() {
    // set default layout
    // this.layout = [];
  }

  ngOnChanges(changes: SimpleChanges) {
    // the extended class will detect change in the process and layout passed
    super.ngOnChanges(changes);

    // setup form config for WC forms
    if (this.legacyActions && this.formConfig && this.process && this.caseRef) {
      this.selectedFormConfig = TcFormConfigService.getProcessFormConfig(this.process.ref, this.formConfig);
      this.buildWcFormConfig(this.process, this.selectedFormConfig, this.caseRef);
    } else {
      // non WC forms:
      if (this.process && this.caseRef) {
        this.getCaseData(this.caseRef);
      }
    }
  }

}
<div class="tcs-case-action-pane" fxLayout="column" fxFill>
  <tc-tibco-cloud-widget-header *ngIf="showHeader" fxFlex="nogrow" [headerText]="'Action'" [icon]="'tcs-case-action-item'"></tc-tibco-cloud-widget-header>
  <tcfrm-rendered-form *ngIf="!wcFormConfig && data && process && (!legacyActions || isCustomForm)" [schema]="schema" [layout]="layout" [data]="data" [caseRef]="caseRef" [appId]="applicationId" [customFormDefs]="customFormDefs" [formsFramework]="formsFramework" [formRef]="process.ref" (formSubmit)="handleSubmit($event, caseRef)"></tcfrm-rendered-form>
  <!--tcla-live-apps-legacy-process *ngIf="data && process && legacyActions && !isCustomForm" [process]="process" [caseState]="caseState" [type]="'action'" [applicationId]="applicationId" [typeId]="typeId" [caseRef]="caseRef" (processCancelled)="handleLegacyProcessCancelled()" (processComplete)="handleLegacyProcessComplete()" class="live-apps-widget" fxFill></tcla-live-apps-legacy-process-->
  <!--div *ngIf="process && legacyActions && !isCustomForm">
    <div class="live-apps-form" id="actionFormDiv"></div>
    <tib-la-caseaction-form
      [sandbox]="sandboxId"
      [formDivId]="'actionFormDiv'"
      [noData]="false"
      [chatBotEnabled]="false"
      [caseRef]="caseRef"
      [id]="process.process.id"
      [name]="process.action.name"
      [label]="process.action.label"
      [version]="process.action.version"
      [applicationId]="process.action.applicationId"
      [applicationName]="process.action.applicationName"
      [activityId]="process.action.activityId"
      [activityName]="process.action.activityName"
      (formLoad) ="handleFormOpen($event)"
      (formSubmit)="handleLegacyProcessComplete($event)"
      (formCancel)="handleLegacyProcessCancelled($event)"
    >
    </tib-la-caseaction-form-->
  <tcla-live-apps-form-wc #actionFormWc *ngIf="process && legacyActions && !isCustomForm && wcFormConfig" [config]="wcFormConfig" (completed)="handleLegacyProcessComplete($event)"></tcla-live-apps-form-wc>
</div>

./live-apps-case-action.component.css

.tcs-case-action-pane {
  border-radius: 3px;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.33);
  background-color: #ffffff;
}

.tcs-case-action-header {
  height: 40px;
  border-radius: 3px 3px 0px 0px;
  box-shadow: 0 1px 2px 0 #dedede;
  padding-left: 20px;
  padding-right: 20px;
}

.tcs-case-action-header-text {
  margin-left: 10px;
  font-family: Source Sans Pro;
  font-size: 18px;
  font-weight: 600;
  font-style: normal;
  font-stretch: normal;
  line-height: 1.5;
  letter-spacing: 0.3px;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""