C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-liveapps-lib/src/lib/components/live-apps-case-search/live-apps-case-search.component.ts
Selection of app + searching for cases
<tcla-live-apps-case-search></tcla-live-apps-case-search>
selector | tcla-live-apps-case-search |
styleUrls | ./live-apps-case-search.component.css |
templateUrl | ./live-apps-case-search.component.html |
Properties |
|
Methods |
Inputs |
Outputs |
HostListeners |
constructor(liveapps: LiveAppsService)
|
||||||
Parameters :
|
appIds | |
Type : string[]
|
|
The list of LA Application IDs you want to handle |
sandboxId | |
Type : number
|
|
sandboxId - this comes from claims resolver |
foundRefs | |
Type : EventEmitter<CaseSearchResults>
|
|
~event foundRefs : Search completed (caseRefs returned) ~payload CaseSearchResults : caseRefs matching the search (so parent can display them in case list component) |
window:resize |
Arguments : '$event'
|
window:resize(event)
|
Inherited from
LiveAppsComponent
|
Defined in
LiveAppsComponent:45
|
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
|
applicationsComponent |
Type : LiveAppsApplicationsComponent
|
Decorators :
@ViewChild(LiveAppsApplicationsComponent, {static: false})
|
Public clearResults |
Default value : () => {...}
|
Public doSearch |
Default value : () => {...}
|
forcedSearch |
Default value : false
|
Public forceSearch |
Default value : () => {...}
|
Public handleSearchAppSelection |
Default value : () => {...}
|
Public refresh |
Default value : () => {...}
|
searchBox |
Type : ElementRef
|
Decorators :
@ViewChild('searchBox', {static: false})
|
searchString |
Type : string
|
searchTerm$ |
Type : Subject<string>
|
searchValue |
Type : Observable<String>
|
Public selectedApp |
Type : CaseType
|
Default value : new CaseType()
|
Public selectedStateId |
Type : number
|
Public selectedStateLabel |
Type : string
|
Public setCaseType |
Default value : () => {...}
|
Public setSelectedStateId |
Default value : () => {...}
|
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
|
import {Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild} from '@angular/core';
import {Observable, Subject} from 'rxjs';
import {LiveAppsService} from '../../services/live-apps.service';
import {CaseInfoList, CaseSearchResults, CaseType} from '../../models/liveappsdata';
import {LiveAppsComponent} from '../live-apps-component/live-apps-component.component';
import {LiveAppsApplicationsComponent} from '../live-apps-applications/live-apps-applications.component';
import {map, tap} from 'rxjs/operators';
/**
* Selection of app + searching for cases
*
* ![alt-text](../live-apps-case-search.png "Image")
*
*@example <tcla-live-apps-case-search></tcla-live-apps-case-search>
*/
@Component({
selector: 'tcla-live-apps-case-search',
templateUrl: './live-apps-case-search.component.html',
styleUrls: ['./live-apps-case-search.component.css']
})
export class LiveAppsCaseSearchComponent extends LiveAppsComponent {
@ViewChild('searchBox', {static: false}) searchBox: ElementRef;
/**
* sandboxId - this comes from claims resolver
*/
@Input() sandboxId: number;
/**
* The list of LA Application IDs you want to handle
*/
@Input() appIds: string[];
/**
* ~event foundRefs : Search completed (caseRefs returned)
* ~payload CaseSearchResults : caseRefs matching the search (so parent can display them in case list component)
*/
@Output() foundRefs: EventEmitter<CaseSearchResults> = new EventEmitter<CaseSearchResults>();
@ViewChild(LiveAppsApplicationsComponent, {static: false}) applicationsComponent: LiveAppsApplicationsComponent;
searchTerm$: Subject<string>;
searchValue: Observable<String>;
searchString: string;
forcedSearch = false;
public selectedStateId: number;
public selectedStateLabel: string;
// case type selector
public selectedApp: CaseType = new CaseType();
constructor(protected liveapps: LiveAppsService) {
super();
}
public refresh = () => {
if (this.applicationsComponent) {
this.applicationsComponent.refresh(true);
}
}
public setCaseType = (caseType: CaseType) => {
this.selectedApp = caseType;
this.doSearch();
this.applicationsComponent.changeAppSelection(caseType);
}
public setSelectedStateId = (stateId: number, stateLabel: string) => {
this.selectedStateId = stateId;
this.selectedStateLabel = stateLabel;
// not currently supported to limit search by stateId
// this.doSearch(stateId);
}
// handle search app selection
public handleSearchAppSelection = (application: CaseType) => {
this.selectedApp = application;
this.doSearch();
}
// clear search results
public clearResults = () => {
this.searchString = '';
this.selectedStateId = undefined;
this.selectedStateLabel = undefined;
this.doSearch();
}
public forceSearch = () => {
this.forcedSearch = true;
this.liveapps.caseSearchEntries(this.searchBox.nativeElement.value, this.sandboxId, this.selectedApp.applicationId, this.selectedApp.id, true, 0, 1000, null).subscribe(
results => {
this.foundRefs.emit(results);
}
);
}
public doSearch = (stateId?: number) => {
this.forcedSearch = false;
this.searchBox.nativeElement.value = '';
const result = new CaseSearchResults().deserialize({ caserefs: [], searchString: '' });
this.foundRefs.emit(result);
this.searchTerm$ = new Subject<string>();
this.searchTerm$.subscribe(next => {
this.searchString = next;
return next;
})
this.searchValue = this.searchTerm$.asObservable();
if (this.selectedApp.applicationId && this.selectedApp.id && this.sandboxId) {
const skip = 0;
const top = 1000;
// Note: The API limits searches to 1000 items
// The service is configured to optimize performance by only returning case references at this stage
// The case details will only be loaded when the item is rendered (for example in the case-list component)
// Any case list component should use cdk virtual scroll to ensure 1000 case details are not loaded in one go
// (from the API or to the DOM)
this.liveapps.caseSearch(this.searchTerm$, this.sandboxId, this.selectedApp.applicationId, this.selectedApp.id, skip, top, stateId ? stateId : null)
.subscribe(results => {
this.foundRefs.emit(results);
});
}
}
}
<div fxLayout="row" fxLayout="center center" style="max-width: 700px; width: 100%;">
<div class="tcs-search-box" fxlayout="row" fxLayoutAlign="space-around center" fxFlex>
<tcla-live-apps-applications fxLayout="row" fxLayoutAlign="start center" class="tcs-search-application-selector" [appIds]="appIds" [sandboxId]="sandboxId" [selectFirstApp]="true" (selection)="handleSearchAppSelection($event)"></tcla-live-apps-applications>
<div class="tcs-search-input-container" fxFlex>
<!-- free search by state with state filter currently not supported -->
<!--div class="tcs-state-filter-marker" *ngIf="selectedStateLabel" fxLayout="row">[<div class="tcs-type-filter-text-highlight">{{selectedStateLabel}}</div>] </div-->
<input #searchBox class="tcs-search-input" placeholder="{{ selectedApp.applicationName ? 'Search within ' + selectedApp.applicationName + ' cases' : 'Select a case type to search cases' }}" (keyup)="searchTerm$.next($event.target.value)" [disabled]="!selectedApp.applicationId" fxFlex>
<div fxLayoutAlign="center end">
<mat-icon *ngIf="forcedSearch || searchString" class="tcs-icon tcs-close-icon" svgIcon="tcs-close-icon" (click)="clearResults()"></mat-icon>
<mat-icon *ngIf="!forcedSearch && !searchString" class="tcs-icon tcs-search-icon" svgIcon="tcs-search-icon" (click)="forceSearch()"></mat-icon>
</div>
</div>
</div>
</div>
./live-apps-case-search.component.css
.tcs-search-box {
/*width: 650px;*/
width: 100%;
height: 44px;
box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.5);
background-color: #ffffff;
}
.tcs-search-input {
height: 24px;
font-family: Source Sans Pro;
font-size: 18px;
font-weight: 600;
font-style: normal;
font-stretch: normal;
line-height: 1.5;
letter-spacing: 0.3px;
text-align: left;
border: none;
}
.tcs-search-input:focus {
outline: none;
}
.tcs-search-input::placeholder{
opacity: 0.38;
}
.tcs-search-input-container {
margin-left: 20px;
margin-right: 20px;
}
.tcs-search-application-selector {
width: 200px;
margin-left: 5px;
margin-right: 5px;
height: 20px;
background-color: #eeeeee;
padding-left: 5px;
padding-right: 5px;
padding-top: 4px;
height: 35px;
}
:host ::ng-deep .tcs-search-icon:hover .svg-content {
fill: #0081cb;
}
:host ::ng-deep .tcs-close-icon:hover .svg-content {
fill: #0081cb;
}
.tcs-search-icon:hover {
cursor: pointer;
}
.tcs-close-icon:hover {
cursor: pointer;
}
.tcs-type-filter-text {
font-family: Source Sans Pro;
font-size: 12px;
font-weight: 600;
font-style: normal;
font-stretch: normal;
line-height: 1.5;
letter-spacing: 0.3px;
text-align: left;
color: black;
margin-left: 10px;
}
.tcs-type-filter-text-highlight {
color: #FF7800;
}
.tcs-state-filter-marker {
margin-top:2px;
}