@pega/dx-component-builder-sdk 0.242.11 → 0.242.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tasks/create/templates/SDK-Angular/field/Decimal/decimal.component.html.mustache +3 -3
- package/src/tasks/create/templates/SDK-Angular/field/Decimal/decimal.component.ts.mustache +16 -13
- package/src/tasks/create/templates/SDK-Angular/field/Decimal-Currency/decimal-currency.component.html.mustache +3 -3
- package/src/tasks/create/templates/SDK-Angular/field/Decimal-Currency/decimal-currency.component.ts.mustache +14 -11
- package/src/tasks/create/templates/SDK-Angular/field/Decimal-Percentage/decimal-percentage.component.html.mustache +2 -3
- package/src/tasks/create/templates/SDK-Angular/field/Decimal-Percentage/decimal-percentage.component.ts.mustache +15 -9
- package/src/tasks/create/templates/SDK-Angular/field/Picklist/demo.stories.tsx.mustache +1 -0
- package/src/tasks/create/templates/SDK-Angular/field/Picklist/picklist.component.ts.mustache +82 -67
- package/tests/assets/sdk-a/components/create/override-sdk/field/currency/currency.component.html +3 -3
- package/tests/assets/sdk-a/components/create/override-sdk/field/currency/currency.component.ts +14 -11
- package/tests/assets/sdk-a/components/create/override-sdk/field/decimal/decimal.component.html +3 -3
- package/tests/assets/sdk-a/components/create/override-sdk/field/decimal/decimal.component.ts +16 -13
- package/tests/assets/sdk-a/components/create/override-sdk/field/percentage/percentage.component.html +2 -3
- package/tests/assets/sdk-a/components/create/override-sdk/field/percentage/percentage.component.ts +15 -9
- package/tests/assets/sdk-a/components/create/override-sdk/template/list-view/list-view.component.html +3 -0
- package/tests/assets/sdk-a/components/create/override-sdk/template/list-view/list-view.component.scss +11 -0
- package/tests/assets/sdk-a/components/create/override-sdk/template/list-view/list-view.component.ts +21 -1
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-currency/pega-dxil-my-currency.component.html +3 -3
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-currency/pega-dxil-my-currency.component.ts +14 -11
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-decimal/pega-dxil-my-decimal.component.html +3 -3
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-decimal/pega-dxil-my-decimal.component.ts +16 -13
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-percentage/pega-dxil-my-percentage.component.html +2 -3
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-percentage/pega-dxil-my-percentage.component.ts +15 -9
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-picklist/demo.stories.tsx +1 -0
- package/tests/assets/sdk-a/components/createAll/custom-sdk/field/pega-dxil-my-picklist/pega-dxil-my-picklist.component.ts +82 -67
- package/tests/assets/sdk-a/components/createAll/override-sdk/field/currency/currency.component.html +3 -3
- package/tests/assets/sdk-a/components/createAll/override-sdk/field/currency/currency.component.ts +14 -11
- package/tests/assets/sdk-a/components/createAll/override-sdk/field/decimal/decimal.component.html +3 -3
- package/tests/assets/sdk-a/components/createAll/override-sdk/field/decimal/decimal.component.ts +16 -13
- package/tests/assets/sdk-a/components/createAll/override-sdk/field/percentage/percentage.component.html +2 -3
- package/tests/assets/sdk-a/components/createAll/override-sdk/field/percentage/percentage.component.ts +15 -9
- package/tests/assets/sdk-a/components/createAll/override-sdk/template/list-view/list-view.component.html +3 -0
- package/tests/assets/sdk-a/components/createAll/override-sdk/template/list-view/list-view.component.scss +11 -0
- package/tests/assets/sdk-a/components/createAll/override-sdk/template/list-view/list-view.component.ts +21 -1
- package/tests/functional/sdk-a/localCreatePublishDeleteOverride.test.js +1 -1
package/package.json
CHANGED
package/src/tasks/create/templates/SDK-Angular/field/Decimal/decimal.component.html.mustache
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
matInput
|
|
14
14
|
currencyMask
|
|
15
15
|
[options]="{
|
|
16
|
-
prefix:
|
|
17
|
-
thousands:
|
|
18
|
-
decimal:
|
|
16
|
+
prefix: currencySymbol,
|
|
17
|
+
thousands: thousandSeparator,
|
|
18
|
+
decimal: decimalSeparator,
|
|
19
19
|
align: 'left',
|
|
20
20
|
nullable: true,
|
|
21
21
|
precision: decimalPrecision,
|
|
@@ -58,9 +58,9 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
58
58
|
placeholder: string;
|
|
59
59
|
|
|
60
60
|
fieldControl = new FormControl<number | null>(null, null);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
decimalSeparator: string;
|
|
62
|
+
thousandSeparator: string;
|
|
63
|
+
currencySymbol = '';
|
|
64
64
|
decimalPrecision: number | undefined;
|
|
65
65
|
formatter;
|
|
66
66
|
formattedValue: any;
|
|
@@ -143,8 +143,8 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
143
143
|
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
|
|
144
144
|
|
|
145
145
|
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
146
|
-
this.
|
|
147
|
-
this.
|
|
146
|
+
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
147
|
+
this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
|
|
148
148
|
|
|
149
149
|
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
|
|
150
150
|
this.formatter = this.configProps$.formatter;
|
|
@@ -183,9 +183,7 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
if (this.bReadonly$ && this.formatter === 'Currency') {
|
|
186
|
-
this.
|
|
187
|
-
} else {
|
|
188
|
-
this.currSym = '';
|
|
186
|
+
this.currencySymbol = theSymbols.theCurrencySymbol;
|
|
189
187
|
}
|
|
190
188
|
this.decimalPrecision = this.configProps$?.decimalPrecision ?? 2;
|
|
191
189
|
|
|
@@ -196,11 +194,16 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
196
194
|
const actionsApi = this.pConn$?.getActionsApi();
|
|
197
195
|
const propName = this.pConn$?.getStateProps().value;
|
|
198
196
|
let value = event?.target?.value;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
value = value?.replace(
|
|
197
|
+
// replacing thousand separator with empty string as not required in api call
|
|
198
|
+
if (this.configProps$.showGroupSeparators) {
|
|
199
|
+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
|
|
200
|
+
const regExp = new RegExp(String.raw`${thousandSep}`, 'g');
|
|
201
|
+
value = value?.replace(regExp, '');
|
|
202
|
+
}
|
|
203
|
+
// replacing decimal separator with '.'
|
|
204
|
+
if (this.decimalSeparator !== '.') {
|
|
205
|
+
const regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
|
|
206
|
+
value = value.replace(regExp, '.');
|
|
204
207
|
}
|
|
205
208
|
handleEvent(actionsApi, 'changeNblur', propName, value);
|
|
206
209
|
}
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
matInput
|
|
16
16
|
currencyMask
|
|
17
17
|
[options]="{
|
|
18
|
-
prefix:
|
|
19
|
-
thousands:
|
|
20
|
-
decimal:
|
|
18
|
+
prefix: currencySymbol,
|
|
19
|
+
thousands: thousandSeparator,
|
|
20
|
+
decimal: decimalSeparator,
|
|
21
21
|
align: 'left',
|
|
22
22
|
nullable: true,
|
|
23
23
|
precision: decimalPrecision,
|
|
@@ -52,9 +52,9 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
52
52
|
currencyOptions: Object = {};
|
|
53
53
|
|
|
54
54
|
fieldControl = new FormControl<number | null>(null, { updateOn: 'blur' });
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
currencySymbol: string;
|
|
56
|
+
thousandSeparator: string;
|
|
57
|
+
decimalSeparator: string;
|
|
58
58
|
inputMode: any;
|
|
59
59
|
decimalPrecision: number | undefined;
|
|
60
60
|
formattedValue: string;
|
|
@@ -136,9 +136,9 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
136
136
|
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
|
|
137
137
|
|
|
138
138
|
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
139
|
+
this.currencySymbol = theSymbols.theCurrencySymbol;
|
|
140
|
+
this.thousandSeparator = theSymbols.theDigitGroupSeparator;
|
|
141
|
+
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
142
142
|
this.formatter = this.configProps$.formatter;
|
|
143
143
|
|
|
144
144
|
if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
|
|
@@ -201,11 +201,14 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
201
201
|
const propName = this.pConn$?.getStateProps().value;
|
|
202
202
|
let value = event?.target?.value;
|
|
203
203
|
value = value?.substring(1);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
// replacing thousand separator with empty string as not required in api call
|
|
205
|
+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
|
|
206
|
+
let regExp = new RegExp(String.raw`${thousandSep}`, 'g');
|
|
207
|
+
value = value?.replace(regExp, '');
|
|
208
|
+
// replacing decimal separator with '.'
|
|
209
|
+
if (this.decimalSeparator !== '.') {
|
|
210
|
+
regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
|
|
211
|
+
value = value.replace(regExp, '.');
|
|
209
212
|
}
|
|
210
213
|
handleEvent(actionsApi, 'changeNblur', propName, value);
|
|
211
214
|
}
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
[options]="{
|
|
16
16
|
prefix: '',
|
|
17
17
|
suffix: '%',
|
|
18
|
-
thousands:
|
|
19
|
-
decimal:
|
|
18
|
+
thousands: thousandSeparator,
|
|
19
|
+
decimal: decimalSeparator,
|
|
20
20
|
align: 'left',
|
|
21
21
|
nullable: true,
|
|
22
22
|
precision: decimalPrecision,
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
(change)="fieldOnChange()"
|
|
32
32
|
(blur)="fieldOnBlur($event)"
|
|
33
33
|
[readonly]="bReadonly$"
|
|
34
|
-
[value]="value$"
|
|
35
34
|
/>
|
|
36
35
|
<mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>
|
|
37
36
|
</mat-form-field>
|
|
@@ -48,8 +48,8 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
48
48
|
testId: string;
|
|
49
49
|
helperText: string;
|
|
50
50
|
placeholder: string;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
decimalSeparator: string;
|
|
52
|
+
thousandSeparator: string;
|
|
53
53
|
inputMode: any;
|
|
54
54
|
decimalPrecision: number | undefined;
|
|
55
55
|
fieldControl = new FormControl<number | null>(null, null);
|
|
@@ -121,14 +121,15 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
121
121
|
const nValue: any = this.configProps$.value;
|
|
122
122
|
if (nValue) {
|
|
123
123
|
this.value$ = nValue;
|
|
124
|
+
this.fieldControl.setValue(nValue);
|
|
124
125
|
}
|
|
125
126
|
this.helperText = this.configProps$.helperText;
|
|
126
127
|
this.placeholder = this.configProps$.placeholder || '';
|
|
127
128
|
const showGroupSeparators = this.configProps$.showGroupSeparators;
|
|
128
129
|
|
|
129
130
|
const theSymbols = getCurrencyCharacters('');
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
131
|
+
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
132
|
+
this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
|
|
132
133
|
|
|
133
134
|
this.actionsApi = this.pConn$.getActionsApi();
|
|
134
135
|
this.propName = this.pConn$.getStateProps().value;
|
|
@@ -187,11 +188,16 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
187
188
|
fieldOnBlur(event: any) {
|
|
188
189
|
let value = event?.target?.value;
|
|
189
190
|
value = value ? value.replace(/%/g, '') : '';
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
value = value
|
|
191
|
+
// replacing thousand separator with empty string as not required in api call
|
|
192
|
+
if (this.configProps$.showGroupSeparators) {
|
|
193
|
+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
|
|
194
|
+
const regExp = new RegExp(String.raw`${thousandSep}`, 'g');
|
|
195
|
+
value = value?.replace(regExp, '');
|
|
196
|
+
}
|
|
197
|
+
// replacing decimal separator with '.'
|
|
198
|
+
if (this.decimalSeparator !== '.') {
|
|
199
|
+
const regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
|
|
200
|
+
value = value.replace(regExp, '.');
|
|
195
201
|
}
|
|
196
202
|
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
|
|
197
203
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
+
import { moduleMetadata } from '@storybook/angular';
|
|
2
3
|
import { FormBuilder } from '@angular/forms';
|
|
3
4
|
import { DatapageService } from '@pega/angular-sdk-components';
|
|
4
5
|
import { configProps, stateProps } from './mock';
|
package/src/tasks/create/templates/SDK-Angular/field/Picklist/picklist.component.ts.mustache
CHANGED
|
@@ -5,6 +5,7 @@ import { MatOptionModule } from '@angular/material/core';
|
|
|
5
5
|
import { MatSelectModule } from '@angular/material/select';
|
|
6
6
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
7
7
|
import { interval } from 'rxjs';
|
|
8
|
+
import isEqual from 'fast-deep-equal';
|
|
8
9
|
import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
|
|
9
10
|
import { DatapageService } from '@pega/angular-sdk-components';
|
|
10
11
|
import { Utils } from '@pega/angular-sdk-components';
|
|
@@ -12,6 +13,39 @@ import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
|
12
13
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
13
14
|
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
14
15
|
|
|
16
|
+
function flattenParameters(params = {}) {
|
|
17
|
+
const flatParams = {};
|
|
18
|
+
Object.keys(params).forEach(key => {
|
|
19
|
+
const { name, value: theVal } = params[key];
|
|
20
|
+
flatParams[name] = theVal;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return flatParams;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function preProcessColumns(columnList) {
|
|
27
|
+
return columnList.map(col => {
|
|
28
|
+
const tempColObj = { ...col };
|
|
29
|
+
tempColObj.value = col.value && col.value.startsWith('.') ? col.value.substring(1) : col.value;
|
|
30
|
+
return tempColObj;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getDisplayFieldsMetaData(columnList) {
|
|
35
|
+
const displayColumns = columnList.filter(col => col.display === 'true');
|
|
36
|
+
const metaDataObj: any = { key: '', primary: '', secondary: [] };
|
|
37
|
+
const keyCol = columnList.filter(col => col.key === 'true');
|
|
38
|
+
metaDataObj.key = keyCol.length > 0 ? keyCol[0].value : 'auto';
|
|
39
|
+
for (let index = 0; index < displayColumns.length; index += 1) {
|
|
40
|
+
if (displayColumns[index].primary === 'true') {
|
|
41
|
+
metaDataObj.primary = displayColumns[index].value;
|
|
42
|
+
} else {
|
|
43
|
+
metaDataObj.secondary.push(displayColumns[index].value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return metaDataObj;
|
|
47
|
+
}
|
|
48
|
+
|
|
15
49
|
interface IOption {
|
|
16
50
|
key: string;
|
|
17
51
|
value: string;
|
|
@@ -59,7 +93,7 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
59
93
|
testId = '';
|
|
60
94
|
helperText: string;
|
|
61
95
|
hideLabel: any;
|
|
62
|
-
|
|
96
|
+
theDatasource: any[] | null;
|
|
63
97
|
fieldControl = new FormControl('', null);
|
|
64
98
|
fieldMetadata: any[];
|
|
65
99
|
localeContext = '';
|
|
@@ -85,8 +119,9 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
85
119
|
// Then, continue on with other initialization
|
|
86
120
|
|
|
87
121
|
// call updateSelf when initializing
|
|
88
|
-
// this.updateSelf();
|
|
89
122
|
this.checkAndUpdate();
|
|
123
|
+
// this should get called afer checkAndUpdate
|
|
124
|
+
this.getDatapageData();
|
|
90
125
|
|
|
91
126
|
if (this.formGroup$) {
|
|
92
127
|
// add control to formGroup
|
|
@@ -129,8 +164,6 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
129
164
|
updateSelf(): void {
|
|
130
165
|
// moved this from ngOnInit() and call this from there instead...
|
|
131
166
|
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as {{COMPONENT_CLASS_NAME}}Props;
|
|
132
|
-
let { listType, parameters, datasource = [], columns = [] } = this.configProps$;
|
|
133
|
-
const { deferDatasource, datasourceMetadata } = this.pConn$.getConfigProps() as {{COMPONENT_CLASS_NAME}}Props;
|
|
134
167
|
if (this.configProps$.value != undefined) {
|
|
135
168
|
this.value$ = this.configProps$.value;
|
|
136
169
|
}
|
|
@@ -140,7 +173,7 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
140
173
|
this.label$ = this.configProps$.label;
|
|
141
174
|
this.helperText = this.configProps$.helperText;
|
|
142
175
|
this.hideLabel = this.configProps$.hideLabel;
|
|
143
|
-
const
|
|
176
|
+
const datasource = this.configProps$.datasource;
|
|
144
177
|
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
145
178
|
setTimeout(() => {
|
|
146
179
|
if (this.configProps$.required != null) {
|
|
@@ -149,6 +182,11 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
149
182
|
this.cdRef.detectChanges();
|
|
150
183
|
});
|
|
151
184
|
|
|
185
|
+
if (!isEqual(datasource, this.theDatasource)) {
|
|
186
|
+
// inbound datasource is different, so update theDatasource
|
|
187
|
+
this.theDatasource = datasource || null;
|
|
188
|
+
}
|
|
189
|
+
|
|
152
190
|
if (this.configProps$.visibility != null) {
|
|
153
191
|
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
154
192
|
}
|
|
@@ -170,40 +208,17 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
170
208
|
|
|
171
209
|
this.componentReference = this.pConn$.getStateProps().value;
|
|
172
210
|
|
|
173
|
-
const optionsList = [...this.utils.getOptionList(this.configProps$, this.pConn$.getDataObject())];
|
|
174
|
-
optionsList?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
|
|
175
|
-
this.options$ = optionsList;
|
|
176
211
|
if (this.value$ === '' && !this.bReadonly$) {
|
|
177
212
|
this.value$ = 'Select';
|
|
178
213
|
}
|
|
179
214
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const { parameters: dataSourceParameters, propertyForDisplayText, propertyForValue } = datasourceMetadata.datasource;
|
|
185
|
-
parameters = this.flattenParameters(dataSourceParameters);
|
|
186
|
-
const displayProp = propertyForDisplayText?.startsWith('@P') ? propertyForDisplayText.substring(3) : propertyForDisplayText;
|
|
187
|
-
const valueProp = propertyForValue?.startsWith('@P') ? propertyForValue.substring(3) : propertyForValue;
|
|
188
|
-
columns = [
|
|
189
|
-
{
|
|
190
|
-
key: 'true',
|
|
191
|
-
setProperty: 'Associated property',
|
|
192
|
-
value: valueProp
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
display: 'true',
|
|
196
|
-
primary: 'true',
|
|
197
|
-
useForSearch: true,
|
|
198
|
-
value: displayProp
|
|
199
|
-
}
|
|
200
|
-
];
|
|
215
|
+
if (this.theDatasource) {
|
|
216
|
+
const optionsList = [...this.utils.getOptionList(this.configProps$, this.pConn$.getDataObject())];
|
|
217
|
+
optionsList?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
|
|
218
|
+
this.options$ = optionsList;
|
|
201
219
|
}
|
|
202
220
|
|
|
203
|
-
|
|
204
|
-
if (!this.displayMode$ && listType !== 'associated' && typeof datasource === 'string') {
|
|
205
|
-
this.getData(datasource, parameters, columns, context);
|
|
206
|
-
}
|
|
221
|
+
this.actionsApi = this.pConn$.getActionsApi();
|
|
207
222
|
|
|
208
223
|
this.propName = this.pConn$.getStateProps().value;
|
|
209
224
|
const className = this.pConn$.getCaseInfo().getClassName();
|
|
@@ -235,10 +250,43 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
235
250
|
}
|
|
236
251
|
}
|
|
237
252
|
|
|
253
|
+
getDatapageData() {
|
|
254
|
+
const configProps = this.pConn$.getConfigProps() as {{COMPONENT_CLASS_NAME}}Props;
|
|
255
|
+
let { listType, parameters, datasource = [], columns = [] } = configProps;
|
|
256
|
+
const { deferDatasource, datasourceMetadata } = configProps;
|
|
257
|
+
const context = this.pConn$.getContextName();
|
|
258
|
+
if (deferDatasource && datasourceMetadata?.datasource?.name) {
|
|
259
|
+
listType = 'datapage';
|
|
260
|
+
datasource = datasourceMetadata.datasource.name;
|
|
261
|
+
const { parameters: dataSourceParameters, propertyForDisplayText, propertyForValue } = datasourceMetadata.datasource;
|
|
262
|
+
parameters = flattenParameters(dataSourceParameters);
|
|
263
|
+
const displayProp = propertyForDisplayText?.startsWith('@P') ? propertyForDisplayText.substring(3) : propertyForDisplayText;
|
|
264
|
+
const valueProp = propertyForValue?.startsWith('@P') ? propertyForValue.substring(3) : propertyForValue;
|
|
265
|
+
columns = [
|
|
266
|
+
{
|
|
267
|
+
key: 'true',
|
|
268
|
+
setProperty: 'Associated property',
|
|
269
|
+
value: valueProp
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
display: 'true',
|
|
273
|
+
primary: 'true',
|
|
274
|
+
useForSearch: true,
|
|
275
|
+
value: displayProp
|
|
276
|
+
}
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
columns = preProcessColumns(columns) || [];
|
|
281
|
+
if (!this.displayMode$ && listType !== 'associated' && typeof datasource === 'string') {
|
|
282
|
+
this.getData(datasource, parameters, columns, context);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
238
286
|
getData(datasource, parameters, columns, context) {
|
|
239
287
|
this.dataPageService.getDataPageData(datasource, parameters, context).then((results: any) => {
|
|
240
288
|
const optionsData: any[] = [];
|
|
241
|
-
const displayColumn =
|
|
289
|
+
const displayColumn = getDisplayFieldsMetaData(columns);
|
|
242
290
|
results?.forEach(element => {
|
|
243
291
|
const val = element[displayColumn.primary]?.toString();
|
|
244
292
|
const obj = {
|
|
@@ -252,39 +300,6 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
252
300
|
});
|
|
253
301
|
}
|
|
254
302
|
|
|
255
|
-
flattenParameters(params = {}) {
|
|
256
|
-
const flatParams = {};
|
|
257
|
-
Object.keys(params).forEach(key => {
|
|
258
|
-
const { name, value: theVal } = params[key];
|
|
259
|
-
flatParams[name] = theVal;
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
return flatParams;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
preProcessColumns(columnList) {
|
|
266
|
-
return columnList.map(col => {
|
|
267
|
-
const tempColObj = { ...col };
|
|
268
|
-
tempColObj.value = col.value && col.value.startsWith('.') ? col.value.substring(1) : col.value;
|
|
269
|
-
return tempColObj;
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
getDisplayFieldsMetaData(columnList) {
|
|
274
|
-
const displayColumns = columnList.filter(col => col.display === 'true');
|
|
275
|
-
const metaDataObj: any = { key: '', primary: '', secondary: [] };
|
|
276
|
-
const keyCol = columnList.filter(col => col.key === 'true');
|
|
277
|
-
metaDataObj.key = keyCol.length > 0 ? keyCol[0].value : 'auto';
|
|
278
|
-
for (let index = 0; index < displayColumns.length; index += 1) {
|
|
279
|
-
if (displayColumns[index].primary === 'true') {
|
|
280
|
-
metaDataObj.primary = displayColumns[index].value;
|
|
281
|
-
} else {
|
|
282
|
-
metaDataObj.secondary.push(displayColumns[index].value);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return metaDataObj;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
303
|
isSelected(buttonValue: string): boolean {
|
|
289
304
|
return this.value$ === buttonValue;
|
|
290
305
|
}
|
package/tests/assets/sdk-a/components/create/override-sdk/field/currency/currency.component.html
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
matInput
|
|
14
14
|
currencyMask
|
|
15
15
|
[options]="{
|
|
16
|
-
prefix:
|
|
17
|
-
thousands:
|
|
18
|
-
decimal:
|
|
16
|
+
prefix: currencySymbol,
|
|
17
|
+
thousands: thousandSeparator,
|
|
18
|
+
decimal: decimalSeparator,
|
|
19
19
|
align: 'left',
|
|
20
20
|
nullable: true,
|
|
21
21
|
precision: decimalPrecision,
|
package/tests/assets/sdk-a/components/create/override-sdk/field/currency/currency.component.ts
CHANGED
|
@@ -52,9 +52,9 @@ export class CurrencyComponent implements OnInit, OnDestroy {
|
|
|
52
52
|
currencyOptions: Object = {};
|
|
53
53
|
|
|
54
54
|
fieldControl = new FormControl<number | null>(null, { updateOn: 'blur' });
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
currencySymbol: string;
|
|
56
|
+
thousandSeparator: string;
|
|
57
|
+
decimalSeparator: string;
|
|
58
58
|
inputMode: any;
|
|
59
59
|
decimalPrecision: number | undefined;
|
|
60
60
|
formattedValue: string;
|
|
@@ -136,9 +136,9 @@ export class CurrencyComponent implements OnInit, OnDestroy {
|
|
|
136
136
|
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
|
|
137
137
|
|
|
138
138
|
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
139
|
+
this.currencySymbol = theSymbols.theCurrencySymbol;
|
|
140
|
+
this.thousandSeparator = theSymbols.theDigitGroupSeparator;
|
|
141
|
+
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
142
142
|
this.formatter = this.configProps$.formatter;
|
|
143
143
|
|
|
144
144
|
if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
|
|
@@ -201,11 +201,14 @@ export class CurrencyComponent implements OnInit, OnDestroy {
|
|
|
201
201
|
const propName = this.pConn$?.getStateProps().value;
|
|
202
202
|
let value = event?.target?.value;
|
|
203
203
|
value = value?.substring(1);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
// replacing thousand separator with empty string as not required in api call
|
|
205
|
+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
|
|
206
|
+
let regExp = new RegExp(String.raw`${thousandSep}`, 'g');
|
|
207
|
+
value = value?.replace(regExp, '');
|
|
208
|
+
// replacing decimal separator with '.'
|
|
209
|
+
if (this.decimalSeparator !== '.') {
|
|
210
|
+
regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
|
|
211
|
+
value = value.replace(regExp, '.');
|
|
209
212
|
}
|
|
210
213
|
handleEvent(actionsApi, 'changeNblur', propName, value);
|
|
211
214
|
}
|
package/tests/assets/sdk-a/components/create/override-sdk/field/decimal/decimal.component.html
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
matInput
|
|
12
12
|
currencyMask
|
|
13
13
|
[options]="{
|
|
14
|
-
prefix:
|
|
15
|
-
thousands:
|
|
16
|
-
decimal:
|
|
14
|
+
prefix: currencySymbol,
|
|
15
|
+
thousands: thousandSeparator,
|
|
16
|
+
decimal: decimalSeparator,
|
|
17
17
|
align: 'left',
|
|
18
18
|
nullable: true,
|
|
19
19
|
precision: decimalPrecision,
|
package/tests/assets/sdk-a/components/create/override-sdk/field/decimal/decimal.component.ts
CHANGED
|
@@ -58,9 +58,9 @@ export class DecimalComponent implements OnInit, OnDestroy {
|
|
|
58
58
|
placeholder: string;
|
|
59
59
|
|
|
60
60
|
fieldControl = new FormControl<number | null>(null, null);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
decimalSeparator: string;
|
|
62
|
+
thousandSeparator: string;
|
|
63
|
+
currencySymbol = '';
|
|
64
64
|
decimalPrecision: number | undefined;
|
|
65
65
|
formatter;
|
|
66
66
|
formattedValue: any;
|
|
@@ -143,8 +143,8 @@ export class DecimalComponent implements OnInit, OnDestroy {
|
|
|
143
143
|
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
|
|
144
144
|
|
|
145
145
|
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
146
|
-
this.
|
|
147
|
-
this.
|
|
146
|
+
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
147
|
+
this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
|
|
148
148
|
|
|
149
149
|
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
|
|
150
150
|
this.formatter = this.configProps$.formatter;
|
|
@@ -183,9 +183,7 @@ export class DecimalComponent implements OnInit, OnDestroy {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
if (this.bReadonly$ && this.formatter === 'Currency') {
|
|
186
|
-
this.
|
|
187
|
-
} else {
|
|
188
|
-
this.currSym = '';
|
|
186
|
+
this.currencySymbol = theSymbols.theCurrencySymbol;
|
|
189
187
|
}
|
|
190
188
|
this.decimalPrecision = this.configProps$?.decimalPrecision ?? 2;
|
|
191
189
|
|
|
@@ -196,11 +194,16 @@ export class DecimalComponent implements OnInit, OnDestroy {
|
|
|
196
194
|
const actionsApi = this.pConn$?.getActionsApi();
|
|
197
195
|
const propName = this.pConn$?.getStateProps().value;
|
|
198
196
|
let value = event?.target?.value;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
value = value?.replace(
|
|
197
|
+
// replacing thousand separator with empty string as not required in api call
|
|
198
|
+
if (this.configProps$.showGroupSeparators) {
|
|
199
|
+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
|
|
200
|
+
const regExp = new RegExp(String.raw`${thousandSep}`, 'g');
|
|
201
|
+
value = value?.replace(regExp, '');
|
|
202
|
+
}
|
|
203
|
+
// replacing decimal separator with '.'
|
|
204
|
+
if (this.decimalSeparator !== '.') {
|
|
205
|
+
const regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
|
|
206
|
+
value = value.replace(regExp, '.');
|
|
204
207
|
}
|
|
205
208
|
handleEvent(actionsApi, 'changeNblur', propName, value);
|
|
206
209
|
}
|
package/tests/assets/sdk-a/components/create/override-sdk/field/percentage/percentage.component.html
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
[options]="{
|
|
14
14
|
prefix: '',
|
|
15
15
|
suffix: '%',
|
|
16
|
-
thousands:
|
|
17
|
-
decimal:
|
|
16
|
+
thousands: thousandSeparator,
|
|
17
|
+
decimal: decimalSeparator,
|
|
18
18
|
align: 'left',
|
|
19
19
|
nullable: true,
|
|
20
20
|
precision: decimalPrecision,
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
(change)="fieldOnChange()"
|
|
30
30
|
(blur)="fieldOnBlur($event)"
|
|
31
31
|
[readonly]="bReadonly$"
|
|
32
|
-
[value]="value$"
|
|
33
32
|
/>
|
|
34
33
|
<mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>
|
|
35
34
|
</mat-form-field>
|
package/tests/assets/sdk-a/components/create/override-sdk/field/percentage/percentage.component.ts
CHANGED
|
@@ -48,8 +48,8 @@ export class PercentageComponent implements OnInit, OnDestroy {
|
|
|
48
48
|
testId: string;
|
|
49
49
|
helperText: string;
|
|
50
50
|
placeholder: string;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
decimalSeparator: string;
|
|
52
|
+
thousandSeparator: string;
|
|
53
53
|
inputMode: any;
|
|
54
54
|
decimalPrecision: number | undefined;
|
|
55
55
|
fieldControl = new FormControl<number | null>(null, null);
|
|
@@ -121,14 +121,15 @@ export class PercentageComponent implements OnInit, OnDestroy {
|
|
|
121
121
|
const nValue: any = this.configProps$.value;
|
|
122
122
|
if (nValue) {
|
|
123
123
|
this.value$ = nValue;
|
|
124
|
+
this.fieldControl.setValue(nValue);
|
|
124
125
|
}
|
|
125
126
|
this.helperText = this.configProps$.helperText;
|
|
126
127
|
this.placeholder = this.configProps$.placeholder || '';
|
|
127
128
|
const showGroupSeparators = this.configProps$.showGroupSeparators;
|
|
128
129
|
|
|
129
130
|
const theSymbols = getCurrencyCharacters('');
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
131
|
+
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
132
|
+
this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
|
|
132
133
|
|
|
133
134
|
this.actionsApi = this.pConn$.getActionsApi();
|
|
134
135
|
this.propName = this.pConn$.getStateProps().value;
|
|
@@ -187,11 +188,16 @@ export class PercentageComponent implements OnInit, OnDestroy {
|
|
|
187
188
|
fieldOnBlur(event: any) {
|
|
188
189
|
let value = event?.target?.value;
|
|
189
190
|
value = value ? value.replace(/%/g, '') : '';
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
value = value
|
|
191
|
+
// replacing thousand separator with empty string as not required in api call
|
|
192
|
+
if (this.configProps$.showGroupSeparators) {
|
|
193
|
+
const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
|
|
194
|
+
const regExp = new RegExp(String.raw`${thousandSep}`, 'g');
|
|
195
|
+
value = value?.replace(regExp, '');
|
|
196
|
+
}
|
|
197
|
+
// replacing decimal separator with '.'
|
|
198
|
+
if (this.decimalSeparator !== '.') {
|
|
199
|
+
const regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
|
|
200
|
+
value = value.replace(regExp, '.');
|
|
195
201
|
}
|
|
196
202
|
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
|
|
197
203
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<div class="psdk-list-header">
|
|
2
2
|
<div>
|
|
3
|
+
<h3 *ngIf="label" class="label" style="font-weight: bold">
|
|
4
|
+
{{ label }} <span class="results-count">{{ getResultsText() }}</span>
|
|
5
|
+
</h3>
|
|
3
6
|
<mat-form-field class="psdk-search" *ngIf="bShowSearch$">
|
|
4
7
|
<mat-label><img class="psdk-icon-search" src="{{ searchIcon$ }}" /> <span class="psdk-search-label">Search</span> </mat-label>
|
|
5
8
|
<input matInput id="search" (keyup)="applySearch($event)" placeholder="" />
|