C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-liveapps-lib/src/lib/components/live-apps-case-actions/live-apps-case-actions.component.ts
Renders case action buttons
<tcla-live-apps-case-actions></tcla-live-apps-case-actions>
selector | tcla-live-apps-case-actions |
styleUrls | ./live-apps-case-actions.component.css |
templateUrl | ./live-apps-case-actions.component.html |
Properties |
|
Methods |
Inputs |
Outputs |
HostListeners |
Accessors |
constructor(liveapps: LiveAppsService, caseProcessesService: TcCaseProcessesService)
|
|||||||||
Parameters :
|
actionFilter | |
Type : string[]
|
|
Dont show buttons for any actions that start with this string. eg: '$' will remove the action $Update |
appId | |
Type : string
|
|
The LA Application Id |
caseRef | |
Type : string
|
|
The case reference |
loadOnDemand | |
Type : boolean
|
|
maxActions | |
Default value : 1
|
|
Max Actions that can be run simultaneously |
sandboxId | |
Type : number
|
|
sandboxId - this comes from claims resolver |
typeId | |
Type : string
|
|
window:resize |
Arguments : '$event'
|
window:resize(event)
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:45
|
loadActions | ||||
loadActions(event)
|
||||
Parameters :
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
Public selectAction | ||||||
selectAction(action: CaseAction)
|
||||||
Parameters :
Returns :
void
|
ngAfterViewInit |
ngAfterViewInit()
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:91
|
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:99
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:104
|
Returns :
void
|
setupWidthObserver |
setupWidthObserver()
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:70
|
Returns :
void
|
appSchema |
Type : CaseTypesList
|
caseActionList |
Type : Process[]
|
Public caseactions |
Type : CaseAction[]
|
caseType |
Type : CaseType
|
Public disabled |
Default value : false
|
Public errorMessage |
Type : string
|
Public isLoading |
Default value : true
|
Public loadOnDemand |
Type : boolean
|
Default value : false
|
Whether to load actions on component load. Default false. |
Public refresh |
Default value : () => {...}
|
Public toggleEnable |
Default value : () => {...}
|
Public typeId |
Type : string
|
Default value : '1'
|
The LA Application Type Id (generally 1) |
Protected _destroyed$ |
Default value : new Subject()
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:39
|
componentChildDivs |
Type : LiveAppsComponent[]
|
Decorators :
@ViewChildren('componentChildDiv')
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:36
|
componentDiv |
Type : ElementRef
|
Decorators :
@ViewChild('componentDiv', {static: false})
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:35
|
Protected containerChanges$ |
Type : Observable<TcComponent>
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:40
|
Private observer |
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:42
|
Public resize |
Default value : () => {...}
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:56
|
Public widget |
Type : TcComponent
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:41
|
LoadOnDemand | ||||||
setLoadOnDemand(loadOnDemand: boolean)
|
||||||
Parameters :
Returns :
void
|
TypeId | ||||||
setTypeId(typeId: string)
|
||||||
Parameters :
Returns :
void
|
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 {CaseAction, 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';
/**
* Renders case action buttons
*
* ![alt-text](../live-apps-case-actions.png "Image")
*
*@example <tcla-live-apps-case-actions></tcla-live-apps-case-actions>
*/
@Component({
selector: 'tcla-live-apps-case-actions',
templateUrl: './live-apps-case-actions.component.html',
styleUrls: ['./live-apps-case-actions.component.css']
})
export class LiveAppsCaseActionsComponent extends LiveAppsComponent implements OnInit {
/**
* The case reference
*/
@Input() caseRef: string;
/**
* The LA Application Id
*/
@Input() appId: string;
/**
* Whether to load actions on component load. Default false.
*/
public loadOnDemand: boolean = false;
@Input('loadOnDemand') set LoadOnDemand(loadOnDemand: boolean) {
if (loadOnDemand){
this.loadOnDemand = loadOnDemand;
}
}
/**
* The LA Application Type Id (generally 1)
*/
public typeId: string = '1';
@Input('typeId') set TypeId(typeId: string) {
if (typeId){
this.typeId = typeId;
}
}
/**
* sandboxId - this comes from claims resolver
*/
@Input() sandboxId: number;
/**
* Max Actions that can be run simultaneously
*/
@Input() maxActions = 1;
/**
* Dont show buttons for any actions that start with this string.
* eg: '$' will remove the action $Update
*/
@Input() actionFilter: string[];
/**
* ~event actionClicked : Case Action selected
* ~payload LaProcessSelection : LaProcessSelection object output when an action is clicked (ie. message to parent to run action component)
*/
@Output() actionClicked: EventEmitter<LaProcessSelection> = new EventEmitter<LaProcessSelection>();
public caseactions: CaseAction[];
public errorMessage: string;
public disabled = false;
public isLoading = true;
appSchema: CaseTypesList;
caseType: CaseType;
caseActionList: Process[];
constructor(protected liveapps: LiveAppsService, protected caseProcessesService: TcCaseProcessesService) {
super();
}
public refresh = () => {
this.isLoading = true;
this.caseProcessesService.getCaseActionsForCaseRef(this.caseRef, this.sandboxId, this.appId, this.typeId)
.pipe(
take(1),
takeUntil(this._destroyed$)
).subscribe(
caseactions => {
this.caseactions = [];
if (this.actionFilter) {
caseactions.actions = caseactions.actions.filter(act => {
// check if it matches any of the actionFilters
let test = true;
this.actionFilter.forEach(actfilter => {
if (test && act.label.substr(0, actfilter.length) === actfilter) {
test = false;
}
});
return test;
});
}
this.caseactions = caseactions.actions;
this.isLoading = false;
}, error => { this.errorMessage = 'Error retrieving case actions: ' + error.error.errorMsg; });
}
public toggleEnable = () => {
this.disabled = !this.disabled;
}
public selectAction(action: CaseAction) {
this.caseProcessesService.getProcessDetails(this.caseRef, this.appId, this.typeId, this.sandboxId, action, null, 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');
}
}
)
)
.subscribe(processSchema => {
this.actionClicked.emit(processSchema);
return processSchema;
}, error => { this.errorMessage = 'Error retrieving case actions: ' + error.error.errorMsg; });
}
ngOnInit() {
if (!this.loadOnDemand) {
this.refresh();
}
}
loadActions(event) {
if (event) {
this.refresh();
}
}
}
<div *ngIf="loadOnDemand">
<div fxLayout="row" fxLayoutAlign="center center" style="width: 100px">
<mat-select fxFlex class="tcs-case-action-option" panelClass="tcs-dynamic-action-list" (openedChange)="loadActions($event)" [disableOptionCentering]="false" placeholder="Actions" matTooltip="" matTooltipShowDelay="1000" matTooltipPosition="below">
<mat-option disabled *ngIf="isLoading">
<div fxLayout="row" fxLayoutAlign="start center">
<span>Loading</span>
<div fxFlex fxLayoutAlign="end center">
<mat-spinner class="spinner" diameter="20"></mat-spinner>
</div>
</div>
</mat-option>
<mat-option *ngFor="let action of caseactions" [value]="" (click)="selectAction(action)">
<span>{{action.label}}</span>
</mat-option>
</mat-select>
</div>
</div>
<div *ngIf="!loadOnDemand" fxLayout="row">
<button [disabled]="disabled" [ngClass]="disabled ? 'disabled' : ''" mat-button class="tcs-case-action-button" *ngFor="let action of caseactions| slice:0:maxActions"
matTooltip="{{action.label}}" matTooltipShowDelay="1000" matTooltipPosition="above"
(click)="selectAction(action)">
{{action.label | ellipsis: 30 }}
</button>
<div fxLayout="row" fxLayoutAlign="center center" style="width: 75px" *ngIf="caseactions && caseactions.length > maxActions">
<mat-select class="tcs-case-action-option" [disableOptionCentering]="true" placeholder="More" matTooltip="" matTooltipShowDelay="1000" matTooltipPosition="below">
<mat-option *ngFor="let action of caseactions | slice:maxActions:caseactions.length" [value]="" (click)="selectAction(action)">
<span>{{action.label}}</span>
</mat-option>
</mat-select>
</div>
</div>
./live-apps-case-actions.component.css
::ng-deep .tcs-dynamic-action-list .mat-option {
min-width: 200px !important;
max-width: 200px !important;
}
.tcs-case-action-button {
margin-left: 5px;
margin-right: 5px;
margin-top: 5px;
margin-bottom: 5px;
height: 40px;
border-radius: 3px;
border-color: #0081cb;
border-style: solid;
border-width: 1px;
background-color: #ffffff;
color: #0081cb;
font-family: Source Sans Pro;
font-size: 16px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: normal;
letter-spacing: 0.2px;
}
.tcs-case-action-button.disabled {
border: none;
}
.tcs-case-action-option {
padding-top: 9px;
padding-left: 10px;
padding-right: 10px;
height: 40px;
border-radius: 3px;
border-color: #0081cb;
border-style: solid;
border-width: 1px;
background-color: #ffffff;
color: #0081cb;
}