File

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

Description

Wraps case creator and case creator list

Extends

LiveAppsComponent

Implements

OnInit

Example

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

Metadata

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

Index

Properties
Methods
Inputs
Outputs
HostListeners

Constructor

constructor(liveapps: LiveAppsService, caseProcessesService: TcCaseProcessesService)
Parameters :
Name Type Optional
liveapps LiveAppsService No
caseProcessesService TcCaseProcessesService No

Inputs

appId
Type : string

The LA Application Id

sandboxId
Type : number

sandboxId - this comes from claims resolver

typeId
Type : string

The LA Application Type Id (generally 1)

Outputs

creatorClicked
Type : EventEmitter<LaProcessSelection>

~event creatorClicked : Case Creator selected ~payload LaProcessSelection : LaProcessSelection object output when an action is clicked (ie. message to parent to run creator component)

HostListeners

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

Methods

ngOnInit
ngOnInit()
Returns : void
Public selectCreator
selectCreator(creator: CaseCreator)
Parameters :
Name Type Optional
creator CaseCreator 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
caseActionList
Type : Process[]
Public casecreators
Type : CaseCreator[]
caseType
Type : CaseType
Public errorMessage
Type : string
Public refresh
Default value : () => {...}
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
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild} from '@angular/core';
import {Subject} from 'rxjs';
import {LiveAppsService} from '../../services/live-apps.service';
import {map, take, takeUntil, tap} from 'rxjs/operators';
import {CaseCreator, CaseType, CaseTypesList, Process} from '../../models/liveappsdata';
import {LaProcessSelection} from '../../models/tc-case-processes';
import {LiveAppsComponent} from '../live-apps-component/live-apps-component.component';
import {TcCaseProcessesService} from '../../services/tc-case-processes.service';
import {CustomFormDefs} from '@tibco-tcstk/tc-forms-lib';


/**
 * Wraps case creator and case creator list
 *
 *@example <tcla-live-apps-case-creators></tcla-live-apps-case-creators>
 */
@Component({
  selector: 'tcla-live-apps-case-creators',
  templateUrl: './live-apps-case-creators.component.html',
  styleUrls: ['./live-apps-case-creators.component.css']
})
export class LiveAppsCaseCreatorsComponent extends LiveAppsComponent implements OnInit {
  /**
   * 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;

  /**
   * ~event creatorClicked : Case Creator selected
   * ~payload LaProcessSelection : LaProcessSelection object output when an action is clicked (ie. message to parent to run creator component)
   */
  @Output() creatorClicked: EventEmitter<LaProcessSelection> = new EventEmitter<LaProcessSelection>();


  public casecreators: CaseCreator[];
  public errorMessage: string;

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

  constructor(protected liveapps: LiveAppsService, protected caseProcessesService: TcCaseProcessesService) {
    super();
  }

  public refresh = () => {
    this.caseProcessesService.getCaseCreators(this.sandboxId, this.appId, this.typeId)
      .pipe(
        take(1),
        takeUntil(this._destroyed$)
      ).subscribe(
      casecreators => {
        this.casecreators = casecreators.creators;
        if (this.casecreators.length === 1) {
          this.selectCreator(this.casecreators[0]);
        }
      }, error => { this.errorMessage = 'Error retrieving case actions: ' + error.error.errorMsg; });
  }

  public selectCreator(creator: CaseCreator) {
    this.caseProcessesService.getProcessDetails(null, this.appId, this.typeId, this.sandboxId, null, creator, 100).pipe(
      take(1),
      takeUntil(this._destroyed$),
      tap(processDetails => {
        if (!processDetails || !processDetails.process || (processDetails.process.jsonSchema.$schema === 'NOSCHEMA')) {
          // This will be triggered when no form schema is available
          // Typically happens when:
          // 1) The form has elements that are not supported by the Live Apps API for form schemas such as participant selectors
          // 2) The Live Apps application is legacy and has no form schema at all, redeploying the live apps application would fix this.
            console.error('No schema available for this case type: The form may not be supported or you may need to update/re-deploy the live apps application. Alternatively use a custom form.');
          }
        }
      )
    )
    .subscribe(processSchema => {
        this.creatorClicked.emit(processSchema);
        return processSchema;
      }
      , error => { this.errorMessage = 'Error retrieving case actions: ' + error.error.errorMsg; });
  }

  ngOnInit() {
    this.refresh();
  }

}
<div *ngIf="casecreators && casecreators.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="Case Creators" (selectionChange)="selectCreator($event.value)">
    <mat-option *ngFor="let creator of casecreators" [value]="creator">
      <span>{{creator.label}}</span>
    </mat-option>
  </mat-select>
</div>

./live-apps-case-creators.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 .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 ""