File

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

Description

Handles rendering of case creator form.

Extends

LiveAppsComponent

Implements

OnChanges OnInit

Example

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

Metadata

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

Index

Properties
Methods
Inputs
Outputs
HostListeners
Accessors

Constructor

constructor(liveapps: LiveAppsService, processesService: TcCaseProcessesService, caseDataService: TcCaseDataService)
Parameters :
Name Type Optional
liveapps LiveAppsService No
processesService TcCaseProcessesService No
caseDataService TcCaseDataService No

Inputs

applicationId
Type : string

LA application ID

customFormTag
Type : string

Custom Form tag if using an external form app

dataOverride
Type : any

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

formsFramework
Type : string
layout
Type : any[]

Custom Form Layout

legacyCreators
Type : boolean
processName
Type : string

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

caseCreated
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

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

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

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

handleLegacyProcessCancelled
Default value : () => {...}
handleLegacyProcessComplete
Default value : () => {...}
handleSubmit
Default value : () => {...}
isCustomForm
Default value : false
Public legacyCreators
Type : boolean
Default value : false

Enable legacy creators

options
Type : any
process
Type : Process
useLegacy
Default value : false
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

LegacyCreators
setLegacyCreators(legacyCreators: boolean)
Parameters :
Name Type Optional
legacyCreators boolean No
Returns : void
FormsFramework
setFormsFramework(formsFramework: string)
Parameters :
Name Type Optional
formsFramework string No
Returns : void
import {Component, EventEmitter, Input, Output, OnDestroy, SimpleChanges, OnChanges, OnInit} from '@angular/core';
import {LiveAppsComponent} from '../live-apps-component/live-apps-component.component';
import { Process, ProcessId} from '../../models/liveappsdata';
import {LiveAppsService} from '../../services/live-apps.service';
import {take, takeUntil} from 'rxjs/operators';
import {TcCaseProcessesService} from '../../services/tc-case-processes.service';
import {TcCaseDataService} from '../../services/tc-case-data.service';

/**
 * Handles rendering of case creator form.
 *
 *@example <tcla-live-apps-case-creator></tcla-live-apps-case-creator>
 */

@Component({
  selector: 'tcla-live-apps-creator-standalone',
  templateUrl: './live-apps-creator-standalone.component.html',
  styleUrls: ['./live-apps-creator-standalone.component.css']
})
export class LiveAppsCreatorStandaloneComponent extends LiveAppsComponent implements OnChanges, OnInit {

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

  /**
   * LA application ID
   */
  @Input() applicationId: string;

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

  /**
   * The process definition of the action or creator to execute
   */
  @Input() processName: string;

  /**
   * Data object that will be displayed on the form. Allows overriding over form data (eg. when selecting data in spotfire)
   */
  @Input() dataOverride: any;

  /**
   * Custom Form tag if using an external form app
   */
  @Input() customFormTag: string;

  /**
   * Custom Form Layout
   */
  @Input() layout: any[];

  /**
   * Enable legacy creators
   */
  public legacyCreators: boolean = false;
  @Input('legacyCreators') set LegacyCreators(legacyCreators: boolean) {
    if (legacyCreators){
      this.legacyCreators = legacyCreators;
    }
  }

  /**
   * 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;
    }
  }

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

  data: any;
  options: any;
  process: Process;
  isCustomForm = false;
  customFormDefs: any;
  useLegacy = false;

  handleSubmit = (data, caseRef) => {
    // if no_process_submit then no need to run process as this was done inside a custom form app
    if (data !== 'NO_PROCESS_SUBMIT') {
      // run the process
      this.liveapps.runProcess(this.sandboxId, this.applicationId, this.process.id, caseRef, data)
        .pipe(
          take(1),
          takeUntil(this._destroyed$)
        )
        .subscribe(response => {
            if (response) {
              if (!response.data.errorMsg) {
                // parse data to object
                response.data = JSON.parse(response.data);
                // case created send back response including caseIdentifier if one is present
                let caseIdentifier;
                let caseReference;
                if (response.caseIdentifier) {
                  caseIdentifier = response.caseIdentifier;
                }
                if (response.caseReference) {
                  caseReference = response.caseReference;
                }
                const processResponse = new ProcessId().deserialize({'caseIdentifier': caseIdentifier, 'caseReference': caseReference});
                this.caseCreated.emit(processResponse);
                this.process = undefined;
                this.data = undefined;
                this.layout = undefined;
              } else {
                console.error('Unable to run case creator');
                console.error(response.data.errorMsg);
              }
            }
          }, error => {
            console.error('Unable to run case creator');
            console.error(error);
          }
        );
    } else {
      const processResponse = new ProcessId().deserialize({'caseIdentifier': undefined, 'caseReference': undefined});
      this.caseCreated.emit(processResponse);
      this.process = undefined;
      this.data = undefined;
      this.layout = undefined;
    }
  }

  handleLegacyProcessComplete = () => {
    const processResponse = new ProcessId().deserialize({'caseIdentifier': undefined, 'caseReference': undefined});
    this.caseCreated.emit(processResponse);
  }

  handleLegacyProcessCancelled = () => {
    // -1 for caseReference means cancelled
    const processResponse = new ProcessId().deserialize({'caseIdentifier': undefined, 'caseReference': '-1'});
    this.caseCreated.emit(processResponse);
  }

  constructor(protected liveapps: LiveAppsService, protected processesService: TcCaseProcessesService, protected caseDataService: TcCaseDataService) {
    super();
  }

  ngOnInit() {
    this.options = {
      defaultOptions: {
        'appearance': 'legacy'
      }
    };
  }

  ngOnChanges(changes: SimpleChanges) {
    // initialize once data is available
    if (this.applicationId && this.processName && this.typeId && this.sandboxId) {
      if (this.legacyCreators) {
        // use legacy creator iframe
        this.useLegacy = this.legacyCreators;
      }
      // use rendered form
      if (this.customFormTag) {
        // use custom form
        this.customFormDefs = { customForms: [this.customFormTag] };
      }
      // get schema
      this.processesService.getProcess(this.sandboxId, this.applicationId, this.typeId, this.processName, 'creator').subscribe(
        next => {
          this.process = next;
        },
        error => {
          console.error('Unable to get creator info');
          console.error(error);
        }
      );
    }
  }

}
<div fxFill>
  <tcfrm-rendered-form *ngIf="process && !useLegacy" style="overflow: auto;" [formsFramework]="formsFramework" [layout]="layout" [customFormDefs]=customFormDefs [formRef]="process.formTag" [appId]="applicationId" [customFormDefs]="customFormDefs" [schema]="process.jsonSchema" [data]="data" [options]="options" (formSubmit)="handleSubmit($event, undefined)"></tcfrm-rendered-form>
  <tcla-live-apps-legacy-process *ngIf="process && useLegacy" [process]="{ process: process }" [type]="'creator'" [applicationId]="applicationId" [typeId]="typeId" (processCancelled)="handleLegacyProcessCancelled()" (processComplete)="handleLegacyProcessComplete()" class="live-apps-widget" fxFill></tcla-live-apps-legacy-process>
</div>

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

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""