Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit, Input, ChangeDetectorRef, forwardRef, OnDestroy } fr
import { CommonModule } from '@angular/common';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { MatOptionModule } from '@angular/material/core';
import { MatAutocompleteModule, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
import { interval, Observable } from 'rxjs';
Expand Down Expand Up @@ -71,6 +71,8 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
hideLabel: boolean;
filteredOptions: Observable<any[]>;
filterValue = '';
actionsApi: Object;
propName: string;

constructor(
private angularPConnect: AngularPConnectService,
Expand Down Expand Up @@ -102,7 +104,7 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {

this.filteredOptions = this.fieldControl.valueChanges.pipe(
startWith(''),
map(value => this._filter(value || ''))
map(value => this._filter((value as string) || ''))
);
}

Expand Down Expand Up @@ -151,6 +153,9 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {

this.setPropertyValuesFromProps();

this.actionsApi = this.pConn$.getActionsApi();
this.propName = this.pConn$.getStateProps().value;

const context = this.pConn$.getContextName();
const { columns, datasource } = this.generateColumnsAndDataSource();

Expand Down Expand Up @@ -299,13 +304,14 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
// this works - this.pConn$.setValue( this.componentReference, this.fieldControl.value);
// PConnect wants to use changeHandler for onChange
// this.angularPConnect.changeHandler( this, event);
this.filterValue = (event.target as HTMLInputElement).value;

this.angularPConnectData.actions?.onChange(this, event);
const value = (event.target as HTMLInputElement).value;
this.filterValue = value;
handleEvent(this.actionsApi, 'change', this.propName, value);
}

optionChanged(event: MatAutocompleteSelectedEvent) {
this.angularPConnectData.actions?.onChange(this, event);
optionChanged(event: any) {
const value = (event.target as HTMLInputElement).value;
handleEvent(this.actionsApi, 'change', this.propName, value);
}

fieldOnBlur(event: Event) {
Expand All @@ -315,11 +321,8 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
const index = this.options$?.findIndex(element => element.value === el.value);
key = index > -1 ? (key = this.options$[index].key) : el.value;
}

const value = key;
const actionsApi = this.pConn$?.getActionsApi();
const propName = this.pConn$?.getStateProps().value;
handleEvent(actionsApi, 'changeNblur', propName, value);
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
if (this.configProps$?.onRecordChange) {
el.value = value;
this.configProps$.onRecordChange(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
selectedvalues: any;
referenceList: string;
listOfCheckboxes: any[] = [];
actionsApi: any;
propName: any;
actionsApi: Object;
propName: string;

fieldControl = new FormControl('', null);

Expand Down Expand Up @@ -225,16 +225,17 @@ export class CheckBoxComponent implements OnInit, OnDestroy {

fieldOnChange(event: any) {
event.value = event.checked;

handleEvent(this.actionsApi, 'changeNblur', this.propName, event.checked);
this.pConn$.clearErrorMessages({
property: this.propName
});
}

fieldOnBlur(event: any) {
if (this.selectionMode === 'multi') {
this.pConn$.getValidationApi().validate(this.selectedvalues, this.selectionList);
} else {
event.value = event.checked;
this.angularPConnectData.actions?.onBlur(this, event);
this.pConn$.getValidationApi().validate(event.target.checked);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[placeholder]="placeholder"
[formControl]="fieldControl"
(blur)="fieldOnBlur($event)"
(dateTimeChange)="fieldOnDateChange($event)"
(dateTimeChange)="fieldOnDateChange()"
[value]="value$"
[required]="bRequired$"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Utils } from '../../../_helpers/utils';
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
import { dateFormatInfoDefault, getDateFormatInfo } from '../../../_helpers/date-format-utils';
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
import { handleEvent } from '../../../_helpers/event-util';

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

constructor(
private angularPConnect: AngularPConnectService,
Expand Down Expand Up @@ -157,6 +160,9 @@ export class DateTimeComponent implements OnInit, OnDestroy {

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

this.actionsApi = this.pConn$.getActionsApi();
this.propName = this.pConn$.getStateProps().value;

// trigger display of error message with field control
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
const timer = interval(100).subscribe(() => {
Expand All @@ -168,22 +174,19 @@ export class DateTimeComponent implements OnInit, OnDestroy {
}
}

fieldOnDateChange(event: any) {
// this comes from the date pop up
if (typeof event.value === 'object') {
// convert date to pega "date" format
event.value = event.value?.toISOString();
}
this.angularPConnectData.actions?.onChange(this, { value: event.value });
fieldOnDateChange() {
this.pConn$.clearErrorMessages({
property: this.propName
});
}

fieldOnBlur(event: any) {
if (typeof event.value === 'object') {
// convert date to pega "date" format
event.value = event.value?.toISOString();
}

this.angularPConnectData.actions?.onBlur(this, event);
const value = event?.target?.value;
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
}

getErrorMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ComponentMapperComponent } from '../../../_bridge/component-mapper/comp
import { dateFormatInfoDefault, getDateFormatInfo } from '../../../_helpers/date-format-utils';
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
import { format } from '../../../_helpers/formatters';
import { handleEvent } from '../../../_helpers/event-util';

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

constructor(
private angularPConnect: AngularPConnectService,
Expand Down Expand Up @@ -167,6 +170,9 @@ export class DateComponent implements OnInit, OnDestroy {
this.helperText = this.configProps$.helperText;
this.placeholder = this.configProps$.placeholder || '';

this.actionsApi = this.pConn$.getActionsApi();
this.propName = this.pConn$.getStateProps().value;

// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
setTimeout(() => {
if (this.configProps$.required != null) {
Expand Down Expand Up @@ -213,7 +219,11 @@ export class DateComponent implements OnInit, OnDestroy {
// convert date to pega "date" format
event.value = event.value?.toISOString();
}
this.angularPConnectData.actions?.onChange(this, { value: event.value });
const value = event?.target?.value;
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
this.pConn$.clearErrorMessages({
property: this.propName
});
}

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

hasErrors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class DropdownComponent implements OnInit, OnDestroy {
localeName = '';
localePath = '';
localizedValue = '';
actionsApi: Object;
propName: string;

constructor(
private angularPConnect: AngularPConnectService,
Expand Down Expand Up @@ -166,9 +168,10 @@ export class DropdownComponent implements OnInit, OnDestroy {
this.value$ = 'Select';
}

const propName = this.pConn$.getStateProps().value;
this.actionsApi = this.pConn$.getActionsApi();
this.propName = this.pConn$.getStateProps().value;
const className = this.pConn$.getCaseInfo().getClassName();
const refName = propName?.slice(propName.lastIndexOf('.') + 1);
const refName = this.propName?.slice(this.propName.lastIndexOf('.') + 1);

this.fieldMetadata = this.configProps$.fieldMetadata;
const metaData = Array.isArray(this.fieldMetadata) ? this.fieldMetadata.filter(field => field?.classID === className)[0] : this.fieldMetadata;
Expand Down Expand Up @@ -204,17 +207,13 @@ export class DropdownComponent implements OnInit, OnDestroy {
if (event?.value === 'Select') {
event.value = '';
}
const actionsApi = this.pConn$?.getActionsApi();
const propName = this.pConn$?.getStateProps().value;
handleEvent(actionsApi, 'changeNblur', propName, event.value);
handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value);
if (this.configProps$?.onRecordChange) {
this.configProps$.onRecordChange(event);
}
}

fieldOnBlur(event: any) {
// PConnect wants to use eventHandler for onBlur
this.angularPConnectData.actions?.onBlur(this, event);
this.pConn$.clearErrorMessages({
property: this.propName
});
}

getLocalizedOptionValue(opt: IOption) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
import { Utils } from '../../../_helpers/utils';
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
import { handleEvent } from '../../../_helpers/event-util';

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

fieldControl = new FormControl('', null);
actionsApi: Object;
propName: string;

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

this.actionsApi = this.pConn$.getActionsApi();
this.propName = this.pConn$.getStateProps().value;

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

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

fieldOnChange(event: any) {
this.angularPConnectData.actions?.onChange(this, event);
const value = event?.target?.value;
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
this.pConn$.clearErrorMessages({
property: this.propName
});
}

fieldOnBlur(event: any) {
// PConnect wants to use eventHandler for onBlur
this.angularPConnectData.actions?.onBlur(this, event);
const value = event?.target?.value;
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
}

getErrorMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[required]="bRequired$"
[formControl]="fieldControl"
[attr.data-test-id]="testId"
(change)="fieldOnChange($event)"
(change)="fieldOnChange()"
(blur)="fieldOnBlur($event)"
/>
<mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
import { Utils } from '../../../_helpers/utils';
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
import { handleEvent } from '../../../_helpers/event-util';

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

fieldControl = new FormControl<number | null>(null, null);
actionsApi: Object;
propName: string;

constructor(
private angularPConnect: AngularPConnectService,
Expand Down Expand Up @@ -115,6 +118,9 @@ export class IntegerComponent implements OnInit, OnDestroy {
this.helperText = this.configProps$.helperText;
this.placeholder = this.configProps$.placeholder || '';

this.actionsApi = this.pConn$.getActionsApi();
this.propName = this.pConn$.getStateProps().value;

// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
setTimeout(() => {
if (this.configProps$.required != null) {
Expand Down Expand Up @@ -155,13 +161,15 @@ export class IntegerComponent implements OnInit, OnDestroy {
}
}

fieldOnChange(event: any) {
this.angularPConnectData.actions?.onChange(this, event);
fieldOnChange() {
this.pConn$.clearErrorMessages({
property: this.propName
});
}

fieldOnBlur(event: any) {
// PConnect wants to use eventHandler for onBlur
this.angularPConnectData.actions?.onBlur(this, event);
const value = event?.target?.value;
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
}

getErrorMessage() {
Expand Down
Loading
Loading