File

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

Description

This Component provides access to the OOTB form web component.

alt-text

Example

<tcla-live-apps-form></tcla-live-apps-form>

Metadata

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

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor()

Inputs

config
Type : LiveAppsFormConfig

config - configuration of the form web component

Outputs

completed
Type : EventEmitter<any>

completed - emitted when form is complete

data
Type : EventEmitter<any>

data - emits data when form is loaded

Methods

Public handleFormEvent
handleFormEvent(event)
Parameters :
Name Optional
event No
Returns : void

Properties

Public cancel
Default value : () => {...}
Public close
Default value : () => {...}
customFormComponent
Type : ElementRef<any>
Decorators :
@ViewChild('customFormComponent', {static: false})
Private formApi
Type : any
Public submit
Default value : () => {...}
import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import {LiveAppsFormConfig} from '../../models/tc-liveapps-form';

/**
 * This Component provides access to the OOTB form web component.
 *
 * ![alt-text](../live-apps-form.png "Live Apps Form Image")
 *
 *@example <tcla-live-apps-form></tcla-live-apps-form>
 */

@Component({
  selector: 'tcla-live-apps-form-wc',
  templateUrl: './live-apps-form-wc.component.html',
  styleUrls: ['./live-apps-form-wc.component.css']
})
export class LiveAppsFormWcComponent {

  /**
   * config - configuration of the form web component
   */
  @Input() config: LiveAppsFormConfig;

  /**
   * data - emits data when form is loaded
   */
  @Output() data: EventEmitter<any> = new EventEmitter<any>();

  /**
   * completed - emitted when form is complete
   */
  @Output() completed: EventEmitter<any> = new EventEmitter<any>();

  @ViewChild('customFormComponent', { static: false }) customFormComponent: ElementRef<any>;

  private formApi: any;

  constructor() { }

  public submit = (data: any) => {
    this.formApi.submit(data);
  }

  public close = (data: any) => {
    this.formApi.close(data);
  }

  public cancel = () => {
    this.formApi.cancel();
  }

  public handleFormEvent (event) {
    if (event && event.detail && event.detail) {
      switch (event.type) {
        case 'formLoad':
          this.formApi = event.target;
          if (event.detail.data) {
            this.data.emit(event.detail.data);
          }
          if (this.config.useCustomForm && this.customFormComponent) {
            // @ts-ignore
            if (this.customFormComponent.notifyLoad) {
              // @ts-ignore
              this.customFormComponent.notifyLoad(event);
            }
          }
          break;
        case 'formSubmit':
          if (this.config.useCustomForm && this.customFormComponent) {
            // @ts-ignore
            if (this.customFormComponent.notifySubmit) {
              // @ts-ignore
              this.customFormComponent.notifySubmit(event);
            }
          }
          if (event.detail.completed) {
            this.completed.emit(event);
          }
          break;
        case 'formCancel':
          if (this.config.useCustomForm && this.customFormComponent) {
            // @ts-ignore
            if (this.customFormComponent.notifyCancel) {
              // @ts-ignore
              this.customFormComponent.notifyCancel(event);
            }
          }
          this.completed.emit(event);
          break;
        case 'formClose':
          if (this.config.useCustomForm && this.customFormComponent) {
            // @ts-ignore
            if (this.customFormComponent.notifyClose) {
              // @ts-ignore
              this.customFormComponent.notifyClose(event);
            }
          }
          this.completed.emit(event);
          break;
        default:
          console.warn('Unhandled form event (live-apps-form-wc)');
          console.warn(event);
          break;
      }
    }
  }
}
<tib-la-caseaction-form *ngIf="config?.type?.toUpperCase() === 'ACTION'" #actionRef
                        [caseRef]="config.caseRef"
                        [useCustomForm]="config.useCustomForm"
                        [sandbox]="config.sandbox"
                        [formDivId]="config.formDivId"
                        [id]="config.id"
                        [name]="config.name"
                        [version]="config.version"
                        [applicationId]="config.applicationId"
                        [applicationName]="config.applicationName"
                        [label]="config.label"
                        [activityName]="config.activityName"
                        (formLoad)="handleFormEvent($event)"
                        (formCancel)="handleFormEvent($event)"
                        (formSubmit)="handleFormEvent($event)">
</tib-la-caseaction-form>
<tib-la-openworkitem-form *ngIf="config?.type?.toUpperCase() === 'WORKITEM'" #actionRef
                          [useCustomForm]="config.useCustomForm"
                          [id]="config.id"
                          [sandbox]="config.sandbox"
                          [formDivId]="config.formDivId"
                          (formLoad)="handleFormEvent($event)"
                          (formCancel)="handleFormEvent($event)"
                          (formClose)="handleFormEvent($event)"
                          (formSubmit)="handleFormEvent($event)">
</tib-la-openworkitem-form>
<tib-la-casecreator-form *ngIf="config?.type?.toUpperCase() === 'CREATOR'" #creatorRef
                         [useCustomForm]="config.useCustomForm"
                         [sandbox]="config.sandbox"
                         [formDivId]="config.formDivId"
                         [id]="config.id"
                         [name]="config.name"
                         [version]="config.version"
                         [applicationId]="config.applicationId"
                         [applicationName]="config.applicationName"
                         [label]="config.label"
                         [activityName]="config.activityName"
                         (formLoad)="handleFormEvent($event)"
                         (formCancel)="handleFormEvent($event)"
                         (formSubmit)="handleFormEvent($event)">
</tib-la-casecreator-form>
<div [id]="config.formDivId"></div>
<!--div>{{config | json}}</div-->
<tcla-custom-form-library #customFormComponent *ngIf="config.useCustomForm" [config]="config"
                                                      (formCancel)="cancel()"
                                                      (formSubmit)="submit($event)"
                                                      (formClose)="close($event)"
></tcla-custom-form-library>

./live-apps-form-wc.component.css

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""