Skip to content

Commit

Permalink
ListView to display currency symbol and alert banner in flow container (
Browse files Browse the repository at this point in the history
#78)

Co-authored-by: mohas22 <[email protected]>
  • Loading branch information
samhere06 and mohas22 authored Nov 13, 2023
1 parent 9a28881 commit b893709
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<div style="text-align: left" class="psdk-flow-container-top">
<div *ngIf="!bShowConfirm">
<h2 *ngIf="!todo_showTodo$">{{ containerName$ }}</h2>
<div *ngIf="!todo_showTodo$">
<h2>{{ containerName$ }}</h2>
<div *ngIf="banners?.length">
<component-mapper name="AlertBanner" [props]="{ banners }"></component-mapper>
</div>
</div>
<div *ngIf="todo_showTodo$">
<component-mapper
name="Todo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class FlowContainerComponent implements OnInit {
localizedVal: any;
localeCategory = 'Messages';
localeReference: any;
banners: Array<any>;
//itemKey: string = ""; // JA - this is what Nebula/Constellation uses to pass to finishAssignment, navigateToStep

constructor(
Expand Down Expand Up @@ -164,10 +165,19 @@ export class FlowContainerComponent implements OnInit {
} else {
this.updateSelf();
}
} else {
this.showPageMessages(completeProps);
}
}
}

showPageMessages(completeProps: Object) {
this.ngZone.run(() => {
const pageMessages = completeProps['pageMessages'];
this.banners = [{ messages: pageMessages?.map((msg) => this.localizedVal(msg.message, 'Messages')), variant: 'urgent' }];
});
}

getTodoVisibilty() {
const caseViewMode = this.pConn$.getValue('context_data.caseViewMode');
if (caseViewMode && caseViewMode === 'review') {
Expand Down Expand Up @@ -221,6 +231,7 @@ export class FlowContainerComponent implements OnInit {

initComponent(bLoadChildren: boolean) {
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps());
this.showPageMessages(this.configProps$);

// when true, update arChildren from pConn, otherwise, arChilren will be updated in updateSelf()
if (bLoadChildren) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { DragDropModule, CdkDragDrop, moveItemInArray, CdkDropList, CdkDrag } fr
import { ProgressSpinnerService } from '../../../_messages/progress-spinner.service';
import { Utils } from '../../../_helpers/utils';
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
import { getCurrencyOptions } from '../../../_helpers/currency-utils';
import Currency from '../../../_helpers/formatters/currency';
import { getLocale } from '../../../_helpers/formatters/common';

declare const window: any;

Expand Down Expand Up @@ -955,6 +958,7 @@ export class ListViewComponent implements OnInit {
let fieldName;
let formattedDate;
let myFormat;
let theCurrencyOptions;

switch (fieldData[field].type) {
case 'Date':
Expand All @@ -977,6 +981,20 @@ export class ListViewComponent implements OnInit {

rowData[fieldName] = formattedDate;
break;
case 'Currency':
fieldName = config.name;
theCurrencyOptions = getCurrencyOptions(this.PCore$?.getEnvironmentInfo()?.getLocale());
// eslint-disable-next-line no-case-declarations
const defaultOptions = {
locale: getLocale(),
position: 'before',
decPlaces: 2
};
// eslint-disable-next-line no-case-declarations
const params = { ...defaultOptions, ...theCurrencyOptions };
rowData[fieldName] = Currency.Currency(rowData[fieldName], params);
//val = format(value, column.type, theCurrencyOptions);
break;
}
}

Expand Down Expand Up @@ -1044,7 +1062,7 @@ export class ListViewComponent implements OnInit {
if (theField.indexOf('.') === 0) {
theField = theField.substring(1);
}
const colIndex = fields.findIndex(ele => ele.fieldID === theField);
const colIndex = fields.findIndex((ele) => ele.fieldID === theField);
const displayAsLink = field.config.displayAsLink;
const headerRow: any = {};
headerRow.id = theField;
Expand All @@ -1053,7 +1071,7 @@ export class ListViewComponent implements OnInit {
headerRow.numeric = field.type === 'Decimal' || field.type === 'Integer' || field.type === 'Percentage' || field.type === 'Currency' || false;
headerRow.disablePadding = false;
headerRow.label = presetFields[index].config.label;
if(colIndex >= 0){
if (colIndex >= 0) {
headerRow.classID = fields[colIndex].classID;
}
if (displayAsLink) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { default as CurrencyMapAlias } from './formatters/currency-map';
declare const PCore;

export const getCurrencyOptions = (inISOCode: string) => {
const operatorLocale = PCore.getEnvironmentInfo().getUseLocale() || 'en-US';
const operatorLocale = PCore.getEnvironmentInfo().getUseLocale() || PCore.getEnvironmentInfo().getLocale() || 'en-US';

let currMapToUse = CurrencyMapAlias.US;
let localeToUse = operatorLocale;
Expand Down

0 comments on commit b893709

Please sign in to comment.