Skip to content

Commit 3dee647

Browse files
vishalshrm539Sharma
andauthored
Fixed the overrides issues (#302)
Co-authored-by: Sharma <[email protected]>
1 parent f08b12b commit 3dee647

File tree

8 files changed

+29
-37
lines changed

8 files changed

+29
-37
lines changed

packages/angular-sdk-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pega/angular-sdk-components",
3-
"version": "24.2.10",
3+
"version": "24.2.11",
44
"peerDependencies": {
55
"@angular/common": "^18.2.12",
66
"@angular/core": "^18.2.12"

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { ComponentMapperComponent } from '../../../_bridge/component-mapper/comp
1313
import { dateFormatInfoDefault, getDateFormatInfo } from '../../../_helpers/date-format-utils';
1414
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
1515
import { handleEvent } from '../../../_helpers/event-util';
16-
import { format, convertToTimezone } from '../../../_helpers/formatters';
16+
import { format } from '../../../_helpers/formatters';
17+
import { DateFormatters } from '../../../_helpers/formatters/date';
1718

1819
interface DateTimeProps extends PConnFieldProps {
1920
// If any, enter additional props that only exist on DateTime here
@@ -91,8 +92,9 @@ export class DateTimeComponent implements OnInit, OnDestroy {
9192
// add control to formGroup
9293
this.formGroup$.addControl(this.controlName$, this.fieldControl);
9394
let dateTimeValue = this.value$ ?? '';
95+
9496
if (this.value$) {
95-
dateTimeValue = dayjs(convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
97+
dateTimeValue = dayjs(DateFormatters?.convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
9698
}
9799
this.fieldControl.setValue(dateTimeValue);
98100
this.bHasForm$ = true;
@@ -140,7 +142,7 @@ export class DateTimeComponent implements OnInit, OnDestroy {
140142
this.value$ = this.configProps$?.value;
141143
let dateTimeValue = this.configProps$?.value ?? '';
142144
if (this.value$) {
143-
dateTimeValue = dayjs(convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
145+
dateTimeValue = dayjs(DateFormatters?.convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
144146
}
145147
this.fieldControl.setValue(dateTimeValue);
146148
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError

packages/angular-sdk-components/src/lib/_helpers/formatters/boolean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function Boolean(value, { allowEmpty = true, tick = '', cross = '' } = {}) {
1111
return value;
1212
}
1313

14-
export default {
14+
export const BooleanFormatters = {
1515
TrueFalse: (value, options) =>
1616
Boolean(value, {
1717
...options,

packages/angular-sdk-components/src/lib/_helpers/formatters/currency.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function SymbolFormatter(value, { symbol = '$', suffix = true, locale = 'en-US'
6363
return formattedValue;
6464
}
6565

66-
export default {
66+
export const CurrencyFormatters = {
6767
Currency: (value, options) => CurrencyFormatter(value, options),
6868
'Currency-Code': (value, options) => CurrencyFormatter(value, { ...options, symbol: false }),
6969
Decimal: (value, options) => NumberFormatter(value, options),

packages/angular-sdk-components/src/lib/_helpers/formatters/date.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function TimeFormatter(value, options) {
4242
return DateFormatter(value, options);
4343
}
4444

45-
export default {
45+
export const DateFormatters = {
4646
'DateTime-Long': (value, options) => DateFormatter(value, { ...options, type: 'customFormat', format: 'LLL' }),
4747
'DateTime-Short': (value, options) =>
4848
DateFormatter(value, {

packages/angular-sdk-components/src/lib/_helpers/formatters/index.ts

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import Boolean from './boolean';
2-
import Currency from './currency';
3-
import DateFormatter from './date';
1+
import { BooleanFormatters } from './boolean';
2+
import { CurrencyFormatters } from './currency';
3+
import { DateFormatters } from './date';
44
import { getCurrentTimezone, getLocale } from './common';
55

6-
export default {
7-
...Boolean,
8-
...Currency,
9-
...DateFormatter
6+
export const CommonFormatters = {
7+
...BooleanFormatters,
8+
...CurrencyFormatters,
9+
...DateFormatters
1010
};
1111

1212
function getDateObject(text): Date {
@@ -69,28 +69,28 @@ export function format(value, type, options = {}): string {
6969
decPlaces: 2
7070
};
7171
const params = { ...defaultOptions, ...options };
72-
formattedValue = Currency.Currency(value, params);
72+
formattedValue = CurrencyFormatters.Currency(value, params);
7373
break;
7474
}
7575

7676
case 'percentage': {
7777
const defaultOptions = { locale: getLocale(), decPlaces: 2 };
7878
const params = { ...defaultOptions, ...options };
79-
formattedValue = Currency.Percentage(value, params);
79+
formattedValue = CurrencyFormatters.Percentage(value, params);
8080
break;
8181
}
8282

8383
case 'decimal': {
8484
const defaultOptions = { locale: getLocale(), decPlaces: 2 };
8585
const params = { ...defaultOptions, ...options };
86-
formattedValue = Currency.Decimal(value, params);
86+
formattedValue = CurrencyFormatters.Decimal(value, params);
8787
break;
8888
}
8989

9090
case 'integer': {
9191
const defaultOptions = { locale: getLocale() };
9292
const params = { ...defaultOptions, ...options };
93-
formattedValue = Currency.Integer(value, params);
93+
formattedValue = CurrencyFormatters.Integer(value, params);
9494
break;
9595
}
9696

@@ -100,7 +100,7 @@ export function format(value, type, options = {}): string {
100100
timezone: getCurrentTimezone()
101101
};
102102
const params = { ...defaultOptions, ...options };
103-
formattedValue = DateFormatter.Date(parseDateInISO(value), params);
103+
formattedValue = DateFormatters.Date(parseDateInISO(value), params);
104104
break;
105105
}
106106

@@ -110,13 +110,13 @@ export function format(value, type, options = {}): string {
110110
timezone: getCurrentTimezone()
111111
};
112112
const params = { ...defaultOptions, ...options };
113-
formattedValue = DateFormatter.Date(parseDateInISO(value), params);
113+
formattedValue = DateFormatters.Date(parseDateInISO(value), params);
114114
break;
115115
}
116116

117117
case 'boolean':
118118
case 'checkbox': {
119-
formattedValue = Boolean.TrueFalse(value, { allowEmpty: false, ...options });
119+
formattedValue = BooleanFormatters.TrueFalse(value, { allowEmpty: false, ...options });
120120
break;
121121
}
122122

@@ -132,7 +132,7 @@ export function format(value, type, options = {}): string {
132132
timezone: getCurrentTimezone()
133133
};
134134
const params = { ...defaultOptions, ...options };
135-
formattedValue = DateFormatter['Time-Only'](value, params);
135+
formattedValue = DateFormatters['Time-Only'](value, params);
136136
break;
137137
}
138138

@@ -141,16 +141,3 @@ export function format(value, type, options = {}): string {
141141
}
142142
return formattedValue;
143143
}
144-
145-
export function convertToTimezone(value, options) {
146-
if (value && options) {
147-
const defaultOptions = {
148-
type: 'customFormat',
149-
format: 'YYYY-MM-DDTHH:mm:ss',
150-
timezone: getCurrentTimezone()
151-
};
152-
const params = { ...defaultOptions, ...options };
153-
return DateFormatter.convertToTimezone(value, params);
154-
}
155-
return value;
156-
}

packages/angular-sdk-components/src/public-api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ export * from './lib/_helpers/event-util';
138138
export * from './lib/_helpers/field-group-utils';
139139
export * from './lib/_helpers/formatters/format-utils';
140140
export * from './lib/_helpers/formatters/currency-map';
141-
export * from './lib/_helpers/formatters';
141+
export * from './lib/_helpers/formatters/date';
142+
export * from './lib/_helpers/formatters/boolean';
143+
export * from './lib/_helpers/formatters/currency';
144+
export * from './lib/_helpers/formatters/index';
142145
export * from './lib/_helpers/tab-utils';
143146
export * from './lib/_helpers/template-utils';
144147
export * from './lib/_helpers/utils';

packages/angular-sdk-overrides/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pega/angular-sdk-overrides",
3-
"version": "24.2.10",
3+
"version": "24.2.11",
44
"description": "Angular SDK - Code for overriding components",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"

0 commit comments

Comments
 (0)