Skip to content

Commit 629f05c

Browse files
4manasamanasatumms2021389
authored
Added support for Advance Search feature in DataReference (#326)
* Added Advanced search feature support in DataReference --------- Co-authored-by: manasa <[email protected]> Co-authored-by: Siva Rama Krishna <[email protected]>
1 parent 14bce76 commit 629f05c

38 files changed

+1709
-161
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@
7575
"dayjs": "^1.11.13",
7676
"downloadjs": "^1.4.7",
7777
"fast-deep-equal": "^3.1.3",
78-
"mat-tel-input": "19.0.5-0",
7978
"libphonenumber-js": "^1.10.53",
8079
"lodash.clonedeep": "^4.5.0",
80+
"mat-tel-input": "19.0.5-0",
8181
"ngx-currency": "^19.0.0",
8282
"rxjs": "^7.8.1",
8383
"tslib": "^2.8.1",

packages/angular-sdk-components/src/lib/_bridge/component-mapper/component-mapper.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ComponentMapperComponent implements OnInit, OnDestroy, OnChanges {
1818
public componentRef: ComponentRef<any> | undefined;
1919
public isInitialized = false;
2020

21-
@Input() name = '';
21+
@Input() name?: string = '';
2222
@Input() props: any;
2323
@Input() errorMsg = '';
2424
@Input() outputEvents: any;
@@ -43,7 +43,7 @@ export class ComponentMapperComponent implements OnInit, OnDestroy, OnChanges {
4343
}
4444

4545
loadComponent() {
46-
const component = getComponentFromMap(this.name);
46+
const component = getComponentFromMap(this.name || '');
4747

4848
if (this.dynamicComponent) {
4949
this.dynamicComponent.clear();
@@ -67,7 +67,7 @@ export class ComponentMapperComponent implements OnInit, OnDestroy, OnChanges {
6767
if (propsValues[i] !== undefined) {
6868
// We'll set 'displayOnlyFA$' prop only to the components which really need it
6969
// Eventual plan is to get rid of this particular prop
70-
if (propsKeys[i] === 'displayOnlyFA$' && !componentsRequireDisplayOnlyFAProp.includes(this.name)) {
70+
if (propsKeys[i] === 'displayOnlyFA$' && !componentsRequireDisplayOnlyFAProp.includes(this.name || '')) {
7171
// eslint-disable-next-line no-continue
7272
continue;
7373
}

packages/angular-sdk-components/src/lib/_bridge/helpers/sdk-pega-component-map.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ import { TimeComponent } from '../../_components/field/time/time.component';
4343
import { UrlComponent } from '../../_components/field/url/url.component';
4444
import { UserReferenceComponent } from '../../_components/field/user-reference/user-reference.component';
4545
import { ScalarListComponent } from '../../_components/field/scalar-list/scalar-list.component';
46+
import { SearchFormComponent } from '../../_components/template/data-reference/search-form/search-form.component';
4647
import { SelectableCardComponent } from '../../_components/field/selectable-card/selectable-card.component';
4748
import { RichTextComponent } from '../../_components/field/rich-text/rich-text.component';
4849

4950
// Template components
51+
import { AdvancedSearchComponent } from '../../_components/template/advanced-search/advanced-search.component';
5052
import { AppShellComponent } from '../../_components/template/app-shell/app-shell.component';
5153
import { BannerPageComponent } from '../../_components/template/banner-page/banner-page.component';
5254
import { CaseSummaryComponent } from '../../_components/template/case-summary/case-summary.component';
@@ -77,6 +79,7 @@ import { OneColumnPageComponent } from '../../_components/template/one-column-pa
7779
import { OneColumnTabComponent } from '../../_components/template/one-column-tab/one-column-tab.component';
7880
import { PageComponent } from '../../_components/template/page/page.component';
7981
import { PromotedFiltersComponent } from '../../_components/template/promoted-filters/promoted-filters.component';
82+
import { SearchGroupsComponent } from '../../_components/template/advanced-search/search-groups/search-groups.component';
8083
import { SimpleTableComponent } from '../../_components/template/simple-table/simple-table.component';
8184
import { SimpleTableManualComponent } from '../../_components/template/simple-table-manual/simple-table-manual.component';
8285
import { SimpleTableSelectComponent } from '../../_components/template/simple-table-select/simple-table-select.component';
@@ -128,6 +131,7 @@ import { WssQuickCreateComponent } from '../../_components/designSystemExtension
128131
// Also, note that "Checkbox" component is named/exported as CheckboxComponent
129132

130133
const pegaSdkComponentMap = {
134+
AdvancedSearch: AdvancedSearchComponent,
131135
ActionButtons: ActionButtonsComponent,
132136
Alert: AlertComponent,
133137
AlertBanner: AlertBannerComponent,
@@ -213,6 +217,8 @@ const pegaSdkComponentMap = {
213217
RichTextEditor: RichTextEditorComponent,
214218
RootContainer: RootContainerComponent,
215219
ScalarList: ScalarListComponent,
220+
SearchForm: SearchFormComponent,
221+
SearchGroups: SearchGroupsComponent,
216222
SelectableCard: SelectableCardComponent,
217223
SemanticLink: SemanticLinkComponent,
218224
SimpleTable: SimpleTableComponent,

packages/angular-sdk-components/src/lib/_components/field/currency/currency.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ export class CurrencyComponent implements OnInit, OnDestroy {
129129
nValue = parseFloat(nValue);
130130
}
131131
this.value$ = nValue;
132-
this.fieldControl.setValue(this.value$);
132+
} else {
133+
this.value$ = null;
133134
}
135+
this.fieldControl.setValue(this.value$);
134136
this.helperText = this.configProps$.helperText;
135137
this.placeholder = this.configProps$.placeholder || '';
136138
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';

packages/angular-sdk-components/src/lib/_components/field/text-input/text-input.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export class TextInputComponent implements OnInit, OnDestroy {
6363
// call updateSelf when initializing
6464
// this.updateSelf();
6565
this.checkAndUpdate();
66-
6766
if (this.formGroup$) {
6867
// add control to formGroup
6968
this.formGroup$.addControl(this.controlName$, this.fieldControl);
@@ -105,7 +104,6 @@ export class TextInputComponent implements OnInit, OnDestroy {
105104
updateSelf(): void {
106105
// moved this from ngOnInit() and call this from there instead...
107106
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as TextInputProps;
108-
109107
if (this.configProps$.value != undefined) {
110108
this.value$ = this.configProps$.value;
111109
}

packages/angular-sdk-components/src/lib/_components/infra/assignment-card/assignment-card.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<form [formGroup]="formGroup$" name="flowContainer" class="psdk-flow-container">
2-
<div *ngFor="let kid of arChildren$">
2+
<div *ngFor="let kid of childrenArray" class="psdk-assignment-card-child">
33
<div [ngSwitch]="kid.getPConnect().getComponentName()">
44
<component-mapper *ngSwitchCase="'View'" name="View" [props]="{ formGroup$, pConn$: kid.getPConnect() }"></component-mapper>
55
<component-mapper

packages/angular-sdk-components/src/lib/_components/infra/assignment-card/assignment-card.component.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
import { Component, OnInit, Input, Output, EventEmitter, forwardRef, OnChanges } from '@angular/core';
1+
import { Component, OnInit, Input, Output, EventEmitter, forwardRef, OnChanges, SimpleChanges } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
44
import { ReferenceComponent } from '../reference/reference.component';
55
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
66

7+
function isChildrenUpdated(children) {
8+
if (!children || children.firstChange) {
9+
return false;
10+
}
11+
for (let i = 0; i < children.previousValue.length; i++) {
12+
if (!PCore.isDeepEqual(children.previousValue[i].getPConnect().getConfigProps(), children.currentValue[i].getPConnect().getConfigProps())) {
13+
return true;
14+
}
15+
}
16+
return false;
17+
}
718
@Component({
819
selector: 'app-assignment-card',
920
templateUrl: './assignment-card.component.html',
@@ -18,18 +29,24 @@ export class AssignmentCardComponent implements OnInit, OnChanges {
1829
@Input() arChildren$: any[];
1930
@Input() updateToken$: number;
2031

32+
childrenArray: any[] = [];
33+
2134
@Output() actionButtonClick: EventEmitter<any> = new EventEmitter();
2235

2336
ngOnInit(): void {
2437
// Children may contain 'reference' component, so we need to
2538
// normalize them
26-
this.arChildren$ = ReferenceComponent.normalizePConnArray(this.arChildren$);
39+
this.childrenArray = ReferenceComponent.normalizePConnArray(this.arChildren$);
2740
}
2841

29-
ngOnChanges() {
42+
ngOnChanges(changes: SimpleChanges) {
3043
// Children may contain 'reference' component, so we need to
3144
// normalize them
32-
this.arChildren$ = ReferenceComponent.normalizePConnArray(this.arChildren$);
45+
46+
const { arChildren$ } = changes;
47+
if (isChildrenUpdated(arChildren$)) {
48+
this.childrenArray = ReferenceComponent.normalizePConnArray(this.arChildren$);
49+
}
3350
}
3451

3552
onActionButtonClick(oData: any) {

packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-case-declarations */
2-
import { Component, OnInit, Input, NgZone, forwardRef, OnDestroy, OnChanges } from '@angular/core';
2+
import { Component, OnInit, Input, forwardRef, OnDestroy, OnChanges } from '@angular/core';
33
import { CommonModule } from '@angular/common';
44
import { MatSnackBarModule, MatSnackBar } from '@angular/material/snack-bar';
55
import { FormGroup } from '@angular/forms';
@@ -56,6 +56,7 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
5656

5757
bHasNavigation$ = false;
5858
bIsVertical$ = false;
59+
prevNavigationSteps: any[] = [];
5960
arCurrentStepIndicies$: number[] = [];
6061
arNavigationSteps$: any[] = [];
6162

@@ -82,7 +83,6 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
8283
private angularPConnect: AngularPConnectService,
8384
private psService: ProgressSpinnerService,
8485
private erService: ErrorMessagesService,
85-
private ngZone: NgZone,
8686
private snackBar: MatSnackBar,
8787
public bannerService: BannerService
8888
) {}
@@ -250,17 +250,19 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
250250

251251
// iterate through steps to find current one(s)
252252
// immutable, so we want to change the local copy, so need to make a copy
253-
this.ngZone.run(() => {
253+
254+
if (!PCore.isDeepEqual(this.prevNavigationSteps, oCaseInfo.navigation.steps)) {
254255
// what comes back now in configObject is the children of the flowContainer
255256
this.arNavigationSteps$ = JSON.parse(JSON.stringify(oCaseInfo.navigation.steps));
257+
this.prevNavigationSteps = JSON.parse(JSON.stringify(oCaseInfo.navigation.steps));
256258
this.arNavigationSteps$.forEach(step => {
257259
if (step.name) {
258260
step.name = PCore.getLocaleUtils().getLocaleValue(step.name, undefined, this.localeReference);
259261
}
260262
});
261263
this.arCurrentStepIndicies$ = [];
262264
this.arCurrentStepIndicies$ = this.findCurrentIndicies(this.arNavigationSteps$, this.arCurrentStepIndicies$, 0);
263-
});
265+
}
264266
}
265267

266268
findCurrentIndicies(arStepperSteps: any[], arIndicies: number[], depth: number): number[] {
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<div *ngIf="loadedPConn$">
2-
<component-mapper [name]="componentName$" [props]="{ pConn$: loadedPConn$ }" errorMsg="Defer Load Missing: {{ componentName$ }}"></component-mapper>
1+
<div *ngIf="childComponentPConnect">
2+
<component-mapper
3+
[name]="childComponentPConnect.getComponentName()"
4+
[props]="{ pConn$: childComponentPConnect, formGroup$ }"
5+
errorMsg="Defer Load Missing: {{ childComponentPConnect.getComponentName() }}"
6+
></component-mapper>
37
</div>

packages/angular-sdk-components/src/lib/_components/infra/defer-load/defer-load.component.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, Input, forwardRef, OnDestroy, OnChanges } from '@angular/core';
1+
import { Component, OnInit, Input, forwardRef, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { publicConstants } from '@pega/pcore-pconnect-typedefs/constants';
44
import { ReferenceComponent } from '../../infra/reference/reference.component';
@@ -19,11 +19,10 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
1919
})
2020
export class DeferLoadComponent implements OnInit, OnDestroy, OnChanges {
2121
@Input() pConn$: typeof PConnect;
22-
@Input() loadData$: any;
22+
@Input() formGroup$;
2323
@Input() name;
2424

25-
componentName$: string;
26-
loadedPConn$: any;
25+
childComponentPConnect: typeof PConnect;
2726
bShowDefer$ = false;
2827

2928
angularPConnectData: AngularPConnectData = {};
@@ -45,7 +44,7 @@ export class DeferLoadComponent implements OnInit, OnDestroy, OnChanges {
4544
ngOnInit(): void {
4645
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
4746
// The below call is causing an error while creating/opening a case, hence commenting it out
48-
// this.loadActiveTab();
47+
this.updateSelf();
4948
}
5049

5150
ngOnDestroy(): void {
@@ -62,11 +61,17 @@ export class DeferLoadComponent implements OnInit, OnDestroy, OnChanges {
6261
if (theRequestedAssignment !== this.currentLoadedAssignment || (lastUpdateCaseTime && lastUpdateCaseTime !== this.lastUpdateCaseTime)) {
6362
this.currentLoadedAssignment = theRequestedAssignment;
6463
this.lastUpdateCaseTime = lastUpdateCaseTime;
65-
this.loadActiveTab();
64+
this.updateSelf();
6665
}
6766
}
6867

69-
ngOnChanges() {
68+
ngOnChanges(changes: SimpleChanges) {
69+
if (!Object.values(changes).every(val => val.firstChange === true)) {
70+
this.updateSelf();
71+
}
72+
}
73+
74+
updateSelf() {
7075
this.loadViewCaseID = this.pConn$.getValue(this.constants.PZINSKEY) || this.pConn$.getValue(this.constants.CASE_INFO.CASE_INFO_ID);
7176
let containerItemData;
7277
const targetName = this.pConn$.getTarget();
@@ -119,8 +124,9 @@ export class DeferLoadComponent implements OnInit, OnDestroy, OnChanges {
119124
};
120125
const configObject = PCore.createPConnect(config);
121126
configObject.getPConnect().setInheritedProp('displayMode', 'DISPLAY_ONLY');
122-
this.loadedPConn$ = ReferenceComponent.normalizePConn(configObject.getPConnect());
123-
this.componentName$ = this.loadedPConn$.getComponentName();
127+
128+
this.childComponentPConnect = ReferenceComponent.normalizePConn(configObject.getPConnect());
129+
124130
if (this.deferLoadId) {
125131
PCore.getDeferLoadManager().stop(this.deferLoadId, this.pConn$.getContextName());
126132
}

0 commit comments

Comments
 (0)