Skip to content

Commit 08febf0

Browse files
vishalshrm539Sharma
andauthored
Fixed issues in Field comps (#316)
* Fixed issues in Field comps * Added formatting for DD/MM/YYYY * Added asterisk for required * Fixed DateTime formatting and RadioButton styling issues * Fixed Phone test * Fixed Time formatting issue in readonly case --------- Co-authored-by: Sharma <vishal.sharma@in.pega.com>
1 parent 98b3815 commit 08febf0

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$, displayMode$ }"></component-mapper>
33
</div>
44
<ng-template #noDisplayMode>
5-
<div *ngIf="!bReadonly$ && bHasForm$; else noEdit">
5+
<div *ngIf="bHasForm$; else noEdit">
66
<div #f="ngForm" [formGroup]="formGroup$" *ngIf="bVisible$">
77
<mat-form-field class="psdk-full-width" subscriptSizing="dynamic" [hintLabel]="helperText">
88
<ngx-mat-intl-tel-input
@@ -11,7 +11,8 @@
1111
[preferredCountries]="['us']"
1212
[enablePlaceholder]="true"
1313
[enableSearch]="true"
14-
[disabled]="bDisabled$"
14+
[required]="bRequired$"
15+
[disabled]="bDisabled$ || bReadonly$"
1516
(change)="fieldOnChange()"
1617
(blur)="fieldOnBlur()"
1718
>

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
<ng-template #noDisplayMode>
99
<div [formGroup]="formGroup$" *ngIf="bVisible$">
1010
<mat-form-field class="psdk-radio-form" subscriptSizing="dynamic" [hintLabel]="helperText">
11-
<span class="psdk-label-wrapper-readonly">
12-
<label class="psdk-label-readonly">{{ label$ }}</label>
13-
</span>
14-
<!-- <mat-label>{{label$}}</mat-label> -->
15-
<input matInput [placeholder]="placeholder" style="display: none" />
11+
<mat-label>{{ label$ }}</mat-label>
12+
<input matInput [placeholder]="placeholder" style="display: none" [required]="bRequired$" />
1613
<mat-radio-group
1714
[value]="value$"
1815
[required]="bRequired$"

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$, displayMode$ }"></component-mapper>
33
</div>
44
<ng-template #noDisplayMode>
5-
<div *ngIf="!bReadonly$ && bHasForm$; else noEdit">
5+
<div *ngIf="bHasForm$; else noEdit">
66
<div [formGroup]="formGroup$">
77
<div *ngIf="bVisible$">
88
<mat-form-field class="psdk-full-width" subscriptSizing="dynamic" [hintLabel]="helperText">
9+
<mat-label>{{ label$ }}</mat-label>
910
<textarea
1011
matInput
1112
rows="5"
@@ -15,6 +16,7 @@
1516
[value]="value$"
1617
[required]="bRequired$"
1718
[disabled]="bDisabled$"
19+
[readonly]="bReadonly$"
1820
[formControl]="fieldControl"
1921
(change)="fieldOnChange($event)"
2022
(blur)="fieldOnBlur($event)"

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
55
import { Utils } from '../../../_helpers/utils';
66
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
77
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
8+
import { format } from '../../../_helpers/formatters';
89

910
interface TextProps extends PConnFieldProps {
1011
// If any, enter additional props that only exist on Text here
@@ -99,8 +100,9 @@ export class TextComponent implements OnInit, OnDestroy {
99100
break;
100101
case 'time':
101102
if (this.value$) {
102-
const timeParts = this.value$.split(':');
103-
this.formattedValue$ = `${timeParts[0]}:${timeParts[1]}`;
103+
this.formattedValue$ = format(this.value$, 'timeonly', {
104+
format: 'hh:mm A'
105+
});
104106
} else {
105107
this.formattedValue$ = '';
106108
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
</div>
2424
</ng-template>
2525
<ng-template #noEdit>
26-
<component-mapper *ngIf="bVisible$ !== false" name="Text" [props]="{ pConn$, formatAs$: 'text' }"></component-mapper>
26+
<component-mapper *ngIf="bVisible$ !== false" name="Text" [props]="{ pConn$, formatAs$: 'time' }"></component-mapper>
2727
</ng-template>

packages/angular-sdk-components/src/lib/_helpers/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ export class Utils {
213213
// 05/22/2021
214214
sReturnDate = dayjs(dateVal).format('MM/DD/YYYY');
215215
break;
216+
case 'Date-Long-Custom-DD/MM/YYYY':
217+
// 22/05/2021
218+
sReturnDate = dayjs(dateVal).format('DD/MM/YYYY');
219+
break;
216220
case 'Date':
217221
case 'Date-Medium':
218222
// Jan 1, 2001

projects/angular-test-app/tests/e2e/DigV2/FormFields/Phone.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ test.describe('E2E test', () => {
5555
// );
5656
// attributes = await common.getAttributes(notrequiredPhone);
5757
// await expect(attributes.includes('required')).toBeFalsy();
58+
59+
await page.locator('ngx-mat-intl-tel-input[data-test-id="af983eaa1b85b015a7654702abd0b249"] >> input').click();
5860
await page.locator('button:has-text("submit")').click();
5961
await expect(page.locator('mat-error')).toBeVisible();
6062

0 commit comments

Comments
 (0)