C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-liveapps-lib/src/lib/components/live-apps-creator-selector/live-apps-creator-selector.component.ts
selector | tcla-live-apps-creator-selector |
styleUrls | ./live-apps-creator-selector.component.css |
templateUrl | ./live-apps-creator-selector.component.html |
Properties |
|
Methods |
Inputs |
Outputs |
HostListeners |
Accessors |
constructor(liveapps: LiveAppsService)
|
||||||
Parameters :
|
appId | |
Type : string
|
|
formFieldRendering | |
Type : boolean
|
|
label | |
Type : string
|
|
sandboxId | |
Type : number
|
|
seletedCreatorId | |
Type : string
|
|
~event creatorSelection : Case Creator selected ~payload LaProcessSelection : LaProcessSelection object output when a creator is selected from a drop down |
typeId | |
Type : string
|
|
creatorSelection | |
Type : EventEmitter
|
|
window:resize |
Arguments : '$event'
|
window:resize(event)
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:45
|
ngOnChanges | ||||||
ngOnChanges(changes: SimpleChanges)
|
||||||
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
|
caseCreatorList |
Type : Process[]
|
caseType |
Type : CaseType
|
Public compareProcessId |
Default value : () => {...}
|
creatorSelector |
Type : MatSelect
|
Decorators :
@ViewChild('creatorSelector', {static: false})
|
Public formFieldRendering |
Type : boolean
|
Default value : false
|
Use Form field rendering around the selection box |
Private getCaseIDAttributeName |
Default value : () => {...}
|
Public label |
Type : string
|
Default value : 'Case Creators'
|
Label for the actions selector |
Public refresh |
Default value : () => {...}
|
Public reset |
Default value : () => {...}
|
Public selectProcess |
Default value : () => {...}
|
Public typeId |
Type : string
|
Default value : '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
|
TypeId | ||||||
setTypeId(typeId: string)
|
||||||
Parameters :
Returns :
void
|
FormFieldRendering | ||||||
setFormFieldRendering(formFieldRendering: boolean)
|
||||||
Parameters :
Returns :
void
|
Label | ||||||
setLabel(label: string)
|
||||||
Parameters :
Returns :
void
|
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core';
import {CaseType, CaseTypesList, Process} from '../../models/liveappsdata';
import {LaProcessSelection} from '../../models/tc-case-processes';
import {LiveAppsComponent} from '../live-apps-component/live-apps-component.component';
import {LiveAppsService} from '../../services/live-apps.service';
import {MatSelect} from '@angular/material/select';
@Component({
selector: 'tcla-live-apps-creator-selector',
templateUrl: './live-apps-creator-selector.component.html',
styleUrls: ['./live-apps-creator-selector.component.css']
})
export class LiveAppsCreatorSelectorComponent extends LiveAppsComponent implements OnChanges {
@ViewChild('creatorSelector', {static: false}) creatorSelector: MatSelect;
@Input() sandboxId: number;
@Input() appId: string;
public typeId: string = '1';
@Input('typeId') set TypeId(typeId: string) {
if (typeId){
this.typeId = typeId;
}
}
/**
* ~event creatorSelection : Case Creator selected
* ~payload LaProcessSelection : LaProcessSelection object output when a creator is selected from a drop down
*/
/**
* Pre-select specified creatorId
*/
@Input() seletedCreatorId: string;
/**
* Use Form field rendering around the selection box
*/
public formFieldRendering: boolean = false;
@Input('formFieldRendering') set FormFieldRendering(formFieldRendering: boolean) {
if (formFieldRendering){
this.formFieldRendering = formFieldRendering;
}
}
/**
* Label for the actions selector
*/
public label: string = 'Case Creators';
@Input('label') set Label(label: string) {
if (label){
this.label = label;
}
}
@Output() creatorSelection = new EventEmitter<LaProcessSelection>();
appSchema: CaseTypesList;
caseType: CaseType;
caseCreatorList: Process[];
// run when the user clicks on a case creator
public selectProcess = (process) => {
this.creatorSelection.emit(new LaProcessSelection('creator', this.appSchema, this.getCaseIDAttributeName(), process,
// Format of ref is <applicationName>.<applicationInternalName>.<processType>.<processName>
(this.caseType.applicationName + '.' + this.caseType.applicationInternalName + '.' + 'creator' + '.' + process.name),
undefined, undefined, undefined
));
}
public reset = () => {
this.creatorSelector.value = undefined;
}
private getCaseIDAttributeName = () => {
let caseIdAttrib: any;
this.caseType.attributes.forEach((attribute) => {
if (attribute.isIdentifier) {
caseIdAttrib = attribute;
}
});
return caseIdAttrib;
}
public refresh = () => {
// retrieve the schema for this case type so we can display case creators and case actions for this case type
this.liveapps.getCaseTypeSchema(this.sandboxId, this.appId, 100)
.subscribe(schema => {
this.appSchema = schema;
schema.casetypes.forEach((casetype) => {
// the schema will contain definitions for both the 'case' and any defined types in that case.
// We want the schema for this 'case'.
if (casetype.applicationId === this.appId && casetype.id === this.typeId) {
if (casetype.jsonSchema !== undefined) {
this.caseType = casetype;
this.caseCreatorList = casetype.creators ? casetype.creators : [];
if (this.caseCreatorList.length === 1) {
this.selectProcess(this.caseCreatorList[0]);
}
} else {
console.error('No schema returned for this case type: You may need to update/re-deploy the live apps application');
}
}
}
);
}
);
}
public compareProcessId = (o1: any, o2: any): boolean => {
return o1.id === this.seletedCreatorId;
}
constructor(protected liveapps: LiveAppsService) {
super();
}
ngOnChanges(changes: SimpleChanges) {
if (changes.appId && (changes.appId.currentValue !== changes.appId.previousValue)) {
this.caseCreatorList = [];
this.refresh();
}
}
}
<div *ngIf="!formFieldRendering && caseCreatorList && caseCreatorList.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="{{label}}" (selectionChange)="selectProcess($event.value)">
<mat-option matInput *ngFor="let creator of caseCreatorList" [value]="creator">
<span>{{creator.name}}</span>
</mat-option>
</mat-select>
</div>
<div *ngIf="formFieldRendering" fxFlex>
<mat-form-field style="width:100%" class="tcs-creator-selector-ff">
<mat-label>{{label}}</mat-label>
<mat-select #creatorSelector class="tcs-creator-selector-option-formfield" [compareWith]="compareProcessId" [disableOptionCentering]="true"
placeholder="{{label}}" (selectionChange)="selectProcess($event.value)">
<mat-option matInput *ngFor="let creator of caseCreatorList" [value]="creator">
<span>{{creator.name}}</span>
</mat-option>
</mat-select>
</mat-form-field>
</div>
./live-apps-creator-selector.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 .tcs-creator-selector-option .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;
}