Skip to content

Commit dca7f5b

Browse files
author
mashm
committed
Merge branch 'master' of https://github.com/pegasystems/angular-sdk-components into mod/tor/adoptionTestingFixes
2 parents 3a8b490 + 573d6f3 commit dca7f5b

25 files changed

+190
-112
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, OnInit, Input, ChangeDetectorRef, forwardRef, OnDestroy } fr
22
import { CommonModule } from '@angular/common';
33
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
44
import { MatOptionModule } from '@angular/material/core';
5-
import { MatAutocompleteModule, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
5+
import { MatAutocompleteModule } from '@angular/material/autocomplete';
66
import { MatInputModule } from '@angular/material/input';
77
import { MatFormFieldModule } from '@angular/material/form-field';
88
import { interval, Observable } from 'rxjs';
@@ -71,6 +71,8 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
7171
hideLabel: boolean;
7272
filteredOptions: Observable<any[]>;
7373
filterValue = '';
74+
actionsApi: Object;
75+
propName: string;
7476

7577
constructor(
7678
private angularPConnect: AngularPConnectService,
@@ -102,7 +104,7 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
102104

103105
this.filteredOptions = this.fieldControl.valueChanges.pipe(
104106
startWith(''),
105-
map(value => this._filter(value || ''))
107+
map(value => this._filter((value as string) || ''))
106108
);
107109
}
108110

@@ -151,6 +153,9 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
151153

152154
this.setPropertyValuesFromProps();
153155

156+
this.actionsApi = this.pConn$.getActionsApi();
157+
this.propName = this.pConn$.getStateProps().value;
158+
154159
const context = this.pConn$.getContextName();
155160
const { columns, datasource } = this.generateColumnsAndDataSource();
156161

@@ -299,13 +304,14 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
299304
// this works - this.pConn$.setValue( this.componentReference, this.fieldControl.value);
300305
// PConnect wants to use changeHandler for onChange
301306
// this.angularPConnect.changeHandler( this, event);
302-
this.filterValue = (event.target as HTMLInputElement).value;
303-
304-
this.angularPConnectData.actions?.onChange(this, event);
307+
const value = (event.target as HTMLInputElement).value;
308+
this.filterValue = value;
309+
handleEvent(this.actionsApi, 'change', this.propName, value);
305310
}
306311

307-
optionChanged(event: MatAutocompleteSelectedEvent) {
308-
this.angularPConnectData.actions?.onChange(this, event);
312+
optionChanged(event: any) {
313+
const value = (event.target as HTMLInputElement).value;
314+
handleEvent(this.actionsApi, 'change', this.propName, value);
309315
}
310316

311317
fieldOnBlur(event: Event) {
@@ -315,11 +321,8 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
315321
const index = this.options$?.findIndex(element => element.value === el.value);
316322
key = index > -1 ? (key = this.options$[index].key) : el.value;
317323
}
318-
319324
const value = key;
320-
const actionsApi = this.pConn$?.getActionsApi();
321-
const propName = this.pConn$?.getStateProps().value;
322-
handleEvent(actionsApi, 'changeNblur', propName, value);
325+
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
323326
if (this.configProps$?.onRecordChange) {
324327
el.value = value;
325328
this.configProps$.onRecordChange(event);

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
6969
selectedvalues: any;
7070
referenceList: string;
7171
listOfCheckboxes: any[] = [];
72-
actionsApi: any;
73-
propName: any;
72+
actionsApi: Object;
73+
propName: string;
7474

7575
fieldControl = new FormControl('', null);
7676

@@ -173,8 +173,8 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
173173

174174
this.caption$ = this.configProps$.caption;
175175
this.helperText = this.configProps$.helperText;
176-
this.trueLabel$ = this.configProps$.trueLabel;
177-
this.falseLabel$ = this.configProps$.falseLabel;
176+
this.trueLabel$ = this.configProps$.trueLabel || 'Yes';
177+
this.falseLabel$ = this.configProps$.falseLabel || 'No';
178178

179179
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
180180
setTimeout(() => {
@@ -225,16 +225,17 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
225225

226226
fieldOnChange(event: any) {
227227
event.value = event.checked;
228-
229228
handleEvent(this.actionsApi, 'changeNblur', this.propName, event.checked);
229+
this.pConn$.clearErrorMessages({
230+
property: this.propName
231+
});
230232
}
231233

232234
fieldOnBlur(event: any) {
233235
if (this.selectionMode === 'multi') {
234236
this.pConn$.getValidationApi().validate(this.selectedvalues, this.selectionList);
235237
} else {
236-
event.value = event.checked;
237-
this.angularPConnectData.actions?.onBlur(this, event);
238+
this.pConn$.getValidationApi().validate(event.target.checked);
238239
}
239240
}
240241

packages/angular-sdk-components/src/lib/_components/field/date-time/date-time.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[placeholder]="placeholder"
1414
[formControl]="fieldControl"
1515
(blur)="fieldOnBlur($event)"
16-
(dateTimeChange)="fieldOnDateChange($event)"
16+
(dateTimeChange)="fieldOnDateChange()"
1717
[value]="value$"
1818
[required]="bRequired$"
1919
/>

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Utils } from '../../../_helpers/utils';
1111
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
1212
import { dateFormatInfoDefault, getDateFormatInfo } from '../../../_helpers/date-format-utils';
1313
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
14+
import { handleEvent } from '../../../_helpers/event-util';
1415

1516
interface DateTimeProps extends PConnFieldProps {
1617
// If any, enter additional props that only exist on DateTime here
@@ -63,6 +64,8 @@ export class DateTimeComponent implements OnInit, OnDestroy {
6364
// and then update, as needed, based on locale, etc.
6465
theDateFormat = getDateFormatInfo();
6566
placeholder: string;
67+
actionsApi: Object;
68+
propName: string;
6669

6770
constructor(
6871
private angularPConnect: AngularPConnectService,
@@ -157,6 +160,9 @@ export class DateTimeComponent implements OnInit, OnDestroy {
157160

158161
this.componentReference = this.pConn$.getStateProps().value;
159162

163+
this.actionsApi = this.pConn$.getActionsApi();
164+
this.propName = this.pConn$.getStateProps().value;
165+
160166
// trigger display of error message with field control
161167
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
162168
const timer = interval(100).subscribe(() => {
@@ -168,22 +174,19 @@ export class DateTimeComponent implements OnInit, OnDestroy {
168174
}
169175
}
170176

171-
fieldOnDateChange(event: any) {
172-
// this comes from the date pop up
173-
if (typeof event.value === 'object') {
174-
// convert date to pega "date" format
175-
event.value = event.value?.toISOString();
176-
}
177-
this.angularPConnectData.actions?.onChange(this, { value: event.value });
177+
fieldOnDateChange() {
178+
this.pConn$.clearErrorMessages({
179+
property: this.propName
180+
});
178181
}
179182

180183
fieldOnBlur(event: any) {
181184
if (typeof event.value === 'object') {
182185
// convert date to pega "date" format
183186
event.value = event.value?.toISOString();
184187
}
185-
186-
this.angularPConnectData.actions?.onBlur(this, event);
188+
const value = event?.target?.value;
189+
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
187190
}
188191

189192
getErrorMessage() {

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ComponentMapperComponent } from '../../../_bridge/component-mapper/comp
1515
import { dateFormatInfoDefault, getDateFormatInfo } from '../../../_helpers/date-format-utils';
1616
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
1717
import { format } from '../../../_helpers/formatters';
18+
import { handleEvent } from '../../../_helpers/event-util';
1819

1920
interface DateProps extends PConnFieldProps {
2021
// If any, enter additional props that only exist on Date here
@@ -84,6 +85,8 @@ export class DateComponent implements OnInit, OnDestroy {
8485
dateFormatInfo = dateFormatInfoDefault;
8586
// and then update, as needed, based on locale, etc.
8687
theDateFormat = getDateFormatInfo();
88+
actionsApi: Object;
89+
propName: string;
8790

8891
constructor(
8992
private angularPConnect: AngularPConnectService,
@@ -167,6 +170,9 @@ export class DateComponent implements OnInit, OnDestroy {
167170
this.helperText = this.configProps$.helperText;
168171
this.placeholder = this.configProps$.placeholder || '';
169172

173+
this.actionsApi = this.pConn$.getActionsApi();
174+
this.propName = this.pConn$.getStateProps().value;
175+
170176
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
171177
setTimeout(() => {
172178
if (this.configProps$.required != null) {
@@ -213,7 +219,11 @@ export class DateComponent implements OnInit, OnDestroy {
213219
// convert date to pega "date" format
214220
event.value = event.value?.toISOString();
215221
}
216-
this.angularPConnectData.actions?.onChange(this, { value: event.value });
222+
const value = event?.target?.value;
223+
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
224+
this.pConn$.clearErrorMessages({
225+
property: this.propName
226+
});
217227
}
218228

219229
fieldOnBlur(event: any) {
@@ -222,7 +232,8 @@ export class DateComponent implements OnInit, OnDestroy {
222232
// convert date to pega "date" format
223233
event.value = event.value?.toISOString();
224234
}
225-
this.angularPConnectData.actions?.onBlur(this, { value: event.value });
235+
const value = event?.target?.value;
236+
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
226237
}
227238

228239
hasErrors() {

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export class DropdownComponent implements OnInit, OnDestroy {
6161
localeName = '';
6262
localePath = '';
6363
localizedValue = '';
64+
actionsApi: Object;
65+
propName: string;
6466

6567
constructor(
6668
private angularPConnect: AngularPConnectService,
@@ -166,9 +168,10 @@ export class DropdownComponent implements OnInit, OnDestroy {
166168
this.value$ = 'Select';
167169
}
168170

169-
const propName = this.pConn$.getStateProps().value;
171+
this.actionsApi = this.pConn$.getActionsApi();
172+
this.propName = this.pConn$.getStateProps().value;
170173
const className = this.pConn$.getCaseInfo().getClassName();
171-
const refName = propName?.slice(propName.lastIndexOf('.') + 1);
174+
const refName = this.propName?.slice(this.propName.lastIndexOf('.') + 1);
172175

173176
this.fieldMetadata = this.configProps$.fieldMetadata;
174177
const metaData = Array.isArray(this.fieldMetadata) ? this.fieldMetadata.filter(field => field?.classID === className)[0] : this.fieldMetadata;
@@ -204,17 +207,13 @@ export class DropdownComponent implements OnInit, OnDestroy {
204207
if (event?.value === 'Select') {
205208
event.value = '';
206209
}
207-
const actionsApi = this.pConn$?.getActionsApi();
208-
const propName = this.pConn$?.getStateProps().value;
209-
handleEvent(actionsApi, 'changeNblur', propName, event.value);
210+
handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value);
210211
if (this.configProps$?.onRecordChange) {
211212
this.configProps$.onRecordChange(event);
212213
}
213-
}
214-
215-
fieldOnBlur(event: any) {
216-
// PConnect wants to use eventHandler for onBlur
217-
this.angularPConnectData.actions?.onBlur(this, event);
214+
this.pConn$.clearErrorMessages({
215+
property: this.propName
216+
});
218217
}
219218

220219
getLocalizedOptionValue(opt: IOption) {

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
88
import { Utils } from '../../../_helpers/utils';
99
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
1010
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
11+
import { handleEvent } from '../../../_helpers/event-util';
1112

1213
interface EmailProps extends PConnFieldProps {
1314
// If any, enter additional props that only exist on Email here
@@ -43,6 +44,8 @@ export class EmailComponent implements OnInit, OnDestroy {
4344
placeholder: string;
4445

4546
fieldControl = new FormControl('', null);
47+
actionsApi: Object;
48+
propName: string;
4649

4750
constructor(
4851
private angularPConnect: AngularPConnectService,
@@ -139,6 +142,9 @@ export class EmailComponent implements OnInit, OnDestroy {
139142
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
140143
}
141144

145+
this.actionsApi = this.pConn$.getActionsApi();
146+
this.propName = this.pConn$.getStateProps().value;
147+
142148
this.componentReference = this.pConn$.getStateProps().value;
143149

144150
// trigger display of error message with field control
@@ -153,12 +159,16 @@ export class EmailComponent implements OnInit, OnDestroy {
153159
}
154160

155161
fieldOnChange(event: any) {
156-
this.angularPConnectData.actions?.onChange(this, event);
162+
const value = event?.target?.value;
163+
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
164+
this.pConn$.clearErrorMessages({
165+
property: this.propName
166+
});
157167
}
158168

159169
fieldOnBlur(event: any) {
160-
// PConnect wants to use eventHandler for onBlur
161-
this.angularPConnectData.actions?.onBlur(this, event);
170+
const value = event?.target?.value;
171+
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
162172
}
163173

164174
getErrorMessage() {

packages/angular-sdk-components/src/lib/_components/field/integer/integer.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[required]="bRequired$"
1616
[formControl]="fieldControl"
1717
[attr.data-test-id]="testId"
18-
(change)="fieldOnChange($event)"
18+
(change)="fieldOnChange()"
1919
(blur)="fieldOnBlur($event)"
2020
/>
2121
<mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
88
import { Utils } from '../../../_helpers/utils';
99
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
1010
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
11+
import { handleEvent } from '../../../_helpers/event-util';
1112

1213
interface IntegerProps extends PConnFieldProps {
1314
// If any, enter additional props that only exist on Integer here
@@ -43,6 +44,8 @@ export class IntegerComponent implements OnInit, OnDestroy {
4344
placeholder: string;
4445

4546
fieldControl = new FormControl<number | null>(null, null);
47+
actionsApi: Object;
48+
propName: string;
4649

4750
constructor(
4851
private angularPConnect: AngularPConnectService,
@@ -115,6 +118,9 @@ export class IntegerComponent implements OnInit, OnDestroy {
115118
this.helperText = this.configProps$.helperText;
116119
this.placeholder = this.configProps$.placeholder || '';
117120

121+
this.actionsApi = this.pConn$.getActionsApi();
122+
this.propName = this.pConn$.getStateProps().value;
123+
118124
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
119125
setTimeout(() => {
120126
if (this.configProps$.required != null) {
@@ -155,13 +161,15 @@ export class IntegerComponent implements OnInit, OnDestroy {
155161
}
156162
}
157163

158-
fieldOnChange(event: any) {
159-
this.angularPConnectData.actions?.onChange(this, event);
164+
fieldOnChange() {
165+
this.pConn$.clearErrorMessages({
166+
property: this.propName
167+
});
160168
}
161169

162170
fieldOnBlur(event: any) {
163-
// PConnect wants to use eventHandler for onBlur
164-
this.angularPConnectData.actions?.onBlur(this, event);
171+
const value = event?.target?.value;
172+
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
165173
}
166174

167175
getErrorMessage() {

0 commit comments

Comments
 (0)