Skip to content

Commit 7033574

Browse files
4manasamashm
andauthored
Fixed the identified issues during adoption testing (#245)
* Fixed issue with percentage and currency values not displaying correctly in read-only mode --------- Co-authored-by: mashm <[email protected]>
1 parent 573d6f3 commit 7033574

File tree

10 files changed

+37
-9
lines changed

10 files changed

+37
-9
lines changed

packages/angular-sdk-components/src/lib/_components/designSystemExtension/material-details-fields/material-details-fields.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<a *ngSwitchCase="'email'" href="mailto: {{ field.config.value }}">{{ _getValue(field.config.value) }}</a>
2222
<span *ngSwitchCase="'date'" class="psdk-details-text-style">{{ _formatDate(field.config.value, field.type) }}</span>
2323
<span *ngSwitchCase="'caseoperator'"></span>
24-
<span *ngSwitchDefault>{{ _getValue(field.config.value) }}</span>
24+
<span *ngSwitchDefault>{{ _getValue(field.config.value, field) }}</span>
2525
</div>
2626
</div>
2727
</ng-template>

packages/angular-sdk-components/src/lib/_components/designSystemExtension/material-details-fields/material-details-fields.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export class MaterialDetailsFieldsComponent {
1616
@Input() arFields$: any[];
1717
@Input() arHighlightedFields: any[];
1818

19-
_getValue(configValue) {
19+
_getValue(configValue, field: any = {}) {
20+
if (field?.type === 'userreference') {
21+
return configValue.userName;
22+
}
2023
if (configValue && configValue != '') {
2124
return configValue;
2225
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div *ngIf="displayMode$; else noDisplayMode">
2-
<component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$, displayMode$ }"></component-mapper>
2+
<component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$: formattedValue, displayMode$ }"></component-mapper>
33
</div>
44
<ng-template #noDisplayMode>
55
<div *ngIf="bHasForm$; else noEdit">

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
99
import { Utils } from '../../../_helpers/utils';
1010
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
1111
import { handleEvent } from '../../../_helpers/event-util';
12-
import { getCurrencyCharacters } from '../../../_helpers/currency-utils';
12+
import { getCurrencyCharacters, getCurrencyOptions } from '../../../_helpers/currency-utils';
1313
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
14+
import { format } from '../../../_helpers/formatters';
1415

1516
interface CurrrencyProps extends PConnFieldProps {
1617
// If any, enter additional props that only exist on Currency here
@@ -55,6 +56,7 @@ export class CurrencyComponent implements OnInit, OnDestroy {
5556
currDec: string;
5657
inputMode: any;
5758
decimalPrecision: number | undefined;
59+
formattedValue: string;
5860

5961
constructor(
6062
private angularPConnect: AngularPConnectService,
@@ -136,6 +138,11 @@ export class CurrencyComponent implements OnInit, OnDestroy {
136138
this.currSep = theSymbols.theDigitGroupSeparator;
137139
this.currDec = theSymbols.theDecimalIndicator;
138140

141+
if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
142+
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
143+
this.formattedValue = format(this.configProps$.value, this.pConn$?.getComponentName()?.toLowerCase(), theCurrencyOptions);
144+
}
145+
139146
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
140147
setTimeout(() => {
141148
if (this.configProps$.required != null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div *ngIf="displayMode$; else noDisplayMode">
2-
<component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$, displayMode$ }"></component-mapper>
2+
<component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$: formattedValue, displayMode$ }"></component-mapper>
33
</div>
44
<ng-template #noDisplayMode>
55
<div *ngIf="bHasForm$; else noEdit">

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
99
import { Utils } from '../../../_helpers/utils';
1010
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
1111
import { handleEvent } from '../../../_helpers/event-util';
12-
import { getCurrencyCharacters } from '../../../_helpers/currency-utils';
12+
import { getCurrencyCharacters, getCurrencyOptions } from '../../../_helpers/currency-utils';
1313
import { PConnFieldProps } from '../../../_types/PConnProps.interface';
14+
import { format } from '../../../_helpers/formatters';
1415

1516
interface PercentageProps extends PConnFieldProps {
1617
showGroupSeparators?: string;
1718
decimalPrecision?: number;
19+
currencyISOCode?: string;
1820
// If any, enter additional props that only exist on Percentage here
1921
}
2022

@@ -53,6 +55,7 @@ export class PercentageComponent implements OnInit, OnDestroy {
5355
fieldControl = new FormControl<number | null>(null, null);
5456
actionsApi: Object;
5557
propName: string;
58+
formattedValue: string;
5659

5760
constructor(
5861
private angularPConnect: AngularPConnectService,
@@ -121,6 +124,7 @@ export class PercentageComponent implements OnInit, OnDestroy {
121124
}
122125
this.helperText = this.configProps$.helperText;
123126
this.placeholder = this.configProps$.placeholder || '';
127+
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
124128
const showGroupSeparators = this.configProps$.showGroupSeparators;
125129

126130
const theSymbols = getCurrencyCharacters('');
@@ -130,6 +134,11 @@ export class PercentageComponent implements OnInit, OnDestroy {
130134
this.actionsApi = this.pConn$.getActionsApi();
131135
this.propName = this.pConn$.getStateProps().value;
132136

137+
if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
138+
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
139+
this.formattedValue = format(nValue, this.pConn$?.getComponentName()?.toLowerCase(), theCurrencyOptions);
140+
}
141+
133142
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
134143
setTimeout(() => {
135144
if (this.configProps$.required != null) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit, Input, forwardRef, OnDestroy } from '@angular/core';
22
import { CommonModule } from '@angular/common';
3+
import { FormGroup } from '@angular/forms';
34
import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/angular-pconnect';
45
import { Utils } from '../../../_helpers/utils';
56
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
@@ -18,6 +19,7 @@ interface TextProps extends PConnFieldProps {
1819
})
1920
export class TextComponent implements OnInit, OnDestroy {
2021
@Input() pConn$: typeof PConnect;
22+
@Input() formGroup$: FormGroup;
2123
@Input() formatAs$: string;
2224

2325
// Used with AngularPConnect

packages/angular-sdk-components/src/lib/_components/infra/stages/stages.component.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
border-radius: 0.5rem;
6060
border: 0.0625rem solid var(--app-neutral-light-color);
6161
overflow: hidden;
62-
height: 2rem;
6362
display: flex;
63+
flex-wrap: wrap;
6464
}
6565

6666
.psdk-stages-chevron {
6767
position: relative;
68-
padding: calc(1rem);
68+
padding: calc(0.5rem);
6969
display: flex;
7070
justify-content: center;
7171
align-items: center;

packages/angular-sdk-components/src/lib/_components/template/details-two-column/details-two-column.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class DetailsTwoColumnComponent implements OnInit, OnDestroy {
6363

6464
if (this.showHighlightedData) {
6565
const highlightedData = rawMetaData?.highlightedData;
66-
this.highlightedDataArr = highlightedData.map(field => {
66+
this.highlightedDataArr = highlightedData?.map(field => {
6767
field.config.displayMode = 'STACKED_LARGE_VAL';
6868

6969
if (field.config.value === '@P .pyStatusWork') {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ export function format(value, type, options = {}): string {
7575
break;
7676
}
7777

78+
case 'percentage': {
79+
const defaultOptions = { locale: getLocale(), decPlaces: 2 };
80+
const params = { ...defaultOptions, ...options };
81+
formattedValue = Currency.Percentage(value, params);
82+
break;
83+
}
84+
7885
case 'decimal': {
7986
const defaultOptions = { locale: getLocale(), decPlaces: 2 };
8087
const params = { ...defaultOptions, ...options };

0 commit comments

Comments
 (0)