@pega/angular-sdk-overrides 0.25.1 → 0.25.3
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/lib/designSystemExtension/alert/alert.component.scss +3 -3
- package/lib/designSystemExtension/banner/banner.component.scss +12 -2
- package/lib/designSystemExtension/material-case-summary/material-case-summary.component.html +6 -3
- package/lib/designSystemExtension/material-case-summary/material-case-summary.component.scss +5 -34
- package/lib/designSystemExtension/material-details/material-details.component.scss +0 -5
- package/lib/designSystemExtension/material-details-fields/material-details-fields.component.html +2 -2
- package/lib/designSystemExtension/material-details-fields/material-details-fields.component.scss +4 -3
- package/lib/designSystemExtension/material-summary-item/material-summary-item.component.scss +2 -17
- package/lib/designSystemExtension/material-utility/material-utility.component.scss +1 -2
- package/lib/designSystemExtension/material-vertical-tabs/material-vertical-tabs.component.scss +1 -1
- package/lib/designSystemExtension/operator/operator.component.html +1 -1
- package/lib/designSystemExtension/operator/operator.component.scss +3 -10
- package/lib/designSystemExtension/operator/operator.component.ts +0 -1
- package/lib/designSystemExtension/pulse/pulse.component.scss +2 -2
- package/lib/designSystemExtension/rich-text-editor/rich-text-editor.component.scss +0 -1
- package/lib/designSystemExtension/wss-quick-create/wss-quick-create.component.scss +16 -8
- package/lib/field/auto-complete/auto-complete.component.html +0 -1
- package/lib/field/auto-complete/auto-complete.component.ts +35 -172
- package/lib/field/cancel-alert/cancel-alert.component.html +8 -12
- package/lib/field/cancel-alert/cancel-alert.component.scss +2 -3
- package/lib/field/cancel-alert/cancel-alert.component.ts +24 -36
- package/lib/field/check-box/check-box.component.html +0 -1
- package/lib/field/check-box/check-box.component.scss +0 -1
- package/lib/field/check-box/check-box.component.ts +19 -149
- package/lib/field/currency/currency.component.ts +36 -168
- package/lib/field/date/date.component.html +1 -1
- package/lib/field/date/date.component.ts +30 -150
- package/lib/field/date-time/date-time.component.ts +31 -149
- package/lib/field/decimal/decimal.component.ts +38 -163
- package/lib/field/dropdown/dropdown.component.ts +29 -151
- package/lib/field/email/email.component.ts +16 -155
- package/lib/field/field.base.ts +149 -0
- package/lib/field/group/group.component.ts +7 -4
- package/lib/field/integer/integer.component.ts +18 -157
- package/lib/field/location/location.component.ts +1 -1
- package/lib/field/multiselect/multiselect.component.ts +46 -148
- package/lib/field/multiselect/utils.ts +55 -47
- package/lib/field/object-reference/object-reference.component.html +17 -0
- package/lib/field/object-reference/object-reference.component.scss +0 -0
- package/lib/field/object-reference/object-reference.component.spec.ts +22 -0
- package/lib/field/object-reference/object-reference.component.ts +237 -0
- package/lib/field/percentage/percentage.component.ts +37 -154
- package/lib/field/phone/phone.component.ts +28 -142
- package/lib/field/radio-buttons/radio-buttons.component.scss +4 -2
- package/lib/field/radio-buttons/radio-buttons.component.ts +35 -161
- package/lib/field/rich-text/rich-text.component.ts +19 -90
- package/lib/field/scalar-list/scalar-list.component.ts +17 -72
- package/lib/field/selectable-card/selectable-card.component.html +54 -24
- package/lib/field/selectable-card/selectable-card.component.scss +11 -0
- package/lib/field/selectable-card/selectable-card.component.ts +16 -52
- package/lib/field/semantic-link/semantic-link.component.html +4 -8
- package/lib/field/semantic-link/semantic-link.component.scss +0 -13
- package/lib/field/semantic-link/semantic-link.component.ts +165 -5
- package/lib/field/text/text.component.scss +0 -1
- package/lib/field/text-area/text-area.component.ts +18 -152
- package/lib/field/text-input/text-input.component.ts +16 -155
- package/lib/field/time/time.component.ts +17 -151
- package/lib/field/url/url.component.ts +16 -154
- package/lib/field/user-reference/user-reference.component.scss +0 -1
- package/lib/field/user-reference/user-reference.component.ts +2 -3
- package/lib/infra/Containers/flow-container/flow-container.component.ts +5 -7
- package/lib/infra/Containers/modal-view-container/modal-view-container.component.ts +5 -10
- package/lib/infra/Containers/view-container/helper.ts +35 -2
- package/lib/infra/Containers/view-container/view-container.component.ts +1 -1
- package/lib/infra/action-buttons/action-buttons.component.html +13 -8
- package/lib/infra/action-buttons/action-buttons.component.scss +23 -0
- package/lib/infra/action-buttons/action-buttons.component.ts +1 -2
- package/lib/infra/assignment/assignment.component.ts +8 -6
- package/lib/infra/assignment-card/assignment-card.component.html +1 -2
- package/lib/infra/assignment-card/assignment-card.component.scss +0 -4
- package/lib/infra/assignment-card/assignment-card.component.ts +21 -4
- package/lib/infra/defer-load/defer-load.component.html +6 -2
- package/lib/infra/defer-load/defer-load.component.ts +16 -10
- package/lib/infra/multi-step/multi-step.component.scss +1 -21
- package/lib/infra/navbar/navbar.component.html +25 -28
- package/lib/infra/navbar/navbar.component.scss +16 -4
- package/lib/infra/navbar/navbar.component.ts +8 -3
- package/lib/infra/root-container/root-container.component.scss +0 -1
- package/lib/infra/root-container/root-container.component.ts +1 -2
- package/lib/infra/stages/stages.component.html +2 -2
- package/lib/infra/stages/stages.component.scss +7 -35
- package/lib/infra/stages/stages.component.ts +4 -2
- package/lib/infra/view/view.component.html +1 -1
- package/lib/infra/view/view.component.ts +0 -2
- package/lib/template/advanced-search/advanced-search.component.html +12 -0
- package/lib/template/advanced-search/advanced-search.component.scss +0 -0
- package/lib/template/advanced-search/advanced-search.component.spec.ts +0 -0
- package/lib/template/advanced-search/advanced-search.component.ts +112 -0
- package/lib/template/advanced-search/advanced-search.service.ts +27 -0
- package/lib/template/advanced-search/search-group/persist-utils.ts +56 -0
- package/lib/template/advanced-search/search-groups/search-groups.component.html +32 -0
- package/lib/template/advanced-search/search-groups/search-groups.component.scss +0 -0
- package/lib/template/advanced-search/search-groups/search-groups.component.spec.ts +0 -0
- package/lib/template/advanced-search/search-groups/search-groups.component.ts +294 -0
- package/lib/template/advanced-search/search-groups/utils.ts +29 -0
- package/lib/template/app-shell/app-shell.component.html +4 -1
- package/lib/template/app-shell/app-shell.component.scss +0 -3
- package/lib/template/app-shell/app-shell.component.ts +46 -7
- package/lib/template/case-summary/case-summary.component.scss +0 -2
- package/lib/template/case-view/case-view.component.html +3 -3
- package/lib/template/case-view/case-view.component.scss +18 -10
- package/lib/template/case-view/case-view.component.ts +1 -1
- package/lib/template/data-reference/data-reference-advanced-search.service.ts +16 -0
- package/lib/template/data-reference/data-reference.component.html +11 -8
- package/lib/template/data-reference/data-reference.component.ts +346 -112
- package/lib/template/data-reference/search-form/search-form.component.html +39 -0
- package/lib/template/data-reference/search-form/search-form.component.scss +11 -0
- package/lib/template/data-reference/search-form/search-form.component.spec.ts +0 -0
- package/lib/template/data-reference/search-form/search-form.component.ts +167 -0
- package/lib/template/data-reference/search-form/tabsData.ts +160 -0
- package/lib/template/data-reference/utils.ts +92 -0
- package/lib/template/default-form/default-form.component.ts +10 -2
- package/lib/template/default-page/default-page.component.html +34 -0
- package/lib/template/default-page/default-page.component.scss +31 -0
- package/lib/template/default-page/default-page.component.spec.ts +24 -0
- package/lib/template/default-page/default-page.component.ts +64 -0
- package/lib/template/field-group-list/field-group-list.component.scss +0 -1
- package/lib/template/inline-dashboard-page/inline-dashboard-page.component.ts +1 -1
- package/lib/template/list-view/list-view.component.html +9 -4
- package/lib/template/list-view/list-view.component.scss +21 -21
- package/lib/template/list-view/list-view.component.ts +154 -84
- package/lib/template/list-view/utils.ts +25 -2
- package/lib/template/object-page/object-page.component.html +1 -0
- package/lib/template/object-page/object-page.component.scss +0 -0
- package/lib/template/object-page/object-page.component.spec.ts +22 -0
- package/lib/template/object-page/object-page.component.ts +14 -0
- package/lib/template/one-column-tab/one-column-tab.component.scss +1 -1
- package/lib/template/repeating-structures/repeating-structures.component.ts +0 -1
- package/lib/template/self-service-case-view/self-service-case-view.component.html +80 -0
- package/lib/template/self-service-case-view/self-service-case-view.component.scss +124 -0
- package/lib/template/self-service-case-view/self-service-case-view.component.spec.ts +24 -0
- package/lib/template/self-service-case-view/self-service-case-view.component.ts +216 -0
- package/lib/template/simple-table/simple-table.component.ts +0 -1
- package/lib/template/simple-table-manual/helpers.ts +2 -2
- package/lib/template/simple-table-manual/simple-table-manual.component.html +4 -4
- package/lib/template/simple-table-manual/simple-table-manual.component.scss +4 -14
- package/lib/template/simple-table-manual/simple-table-manual.component.ts +8 -4
- package/lib/template/single-reference-readonly/single-reference-readonly.component.html +4 -1
- package/lib/template/single-reference-readonly/single-reference-readonly.component.scss +21 -0
- package/lib/template/single-reference-readonly/single-reference-readonly.component.ts +104 -3
- package/lib/template/utils.ts +42 -0
- package/lib/template/wss-nav-bar/wss-nav-bar.component.html +5 -4
- package/lib/template/wss-nav-bar/wss-nav-bar.component.scss +2 -8
- package/lib/template/wss-nav-bar/wss-nav-bar.component.ts +1 -8
- package/lib/widget/app-announcement/app-announcement.component.html +1 -2
- package/lib/widget/app-announcement/app-announcement.component.scss +2 -2
- package/lib/widget/attachment/Attachment.types.ts +92 -0
- package/lib/widget/attachment/AttachmentUtils.ts +287 -0
- package/lib/widget/attachment/attachment.component.html +3 -3
- package/lib/widget/attachment/attachment.component.scss +2 -5
- package/lib/widget/attachment/attachment.component.ts +255 -254
- package/lib/widget/feed-container/feed-container.component.scss +3 -9
- package/lib/widget/feed-container/feed-container.component.ts +2 -2
- package/lib/widget/file-utility/file-utility.component.html +3 -3
- package/lib/widget/file-utility/file-utility.component.scss +5 -16
- package/lib/widget/list-utility/list-utility.component.scss +3 -5
- package/lib/widget/todo/todo.component.html +8 -5
- package/lib/widget/todo/todo.component.scss +10 -11
- package/lib/widget/todo/todo.component.ts +6 -2
- package/package.json +1 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Component, OnInit,
|
|
1
|
+
import { Component, OnInit, forwardRef, OnDestroy } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
4
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
5
5
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
6
|
import { MatOptionModule } from '@angular/material/core';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import { Utils } from '@pega/angular-sdk-components';
|
|
7
|
+
|
|
8
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
10
9
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
11
10
|
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
12
11
|
import { deleteInstruction, insertInstruction, updateNewInstructions } from '@pega/angular-sdk-components';
|
|
@@ -36,29 +35,12 @@ interface CheckboxProps extends Omit<PConnFieldProps, 'value'> {
|
|
|
36
35
|
styleUrls: ['./check-box.component.scss'],
|
|
37
36
|
imports: [CommonModule, ReactiveFormsModule, MatCheckboxModule, MatFormFieldModule, MatOptionModule, forwardRef(() => ComponentMapperComponent)]
|
|
38
37
|
})
|
|
39
|
-
export class CheckBoxComponent implements OnInit, OnDestroy {
|
|
40
|
-
@Input() pConn$: typeof PConnect;
|
|
41
|
-
@Input() formGroup$: FormGroup;
|
|
42
|
-
|
|
43
|
-
// Used with AngularPConnect
|
|
44
|
-
angularPConnectData: AngularPConnectData = {};
|
|
38
|
+
export class CheckBoxComponent extends FieldBase implements OnInit, OnDestroy {
|
|
45
39
|
configProps$: CheckboxProps;
|
|
46
40
|
|
|
47
|
-
label$ = '';
|
|
48
|
-
value$: any = '';
|
|
49
41
|
caption$?: string = '';
|
|
50
|
-
testId = '';
|
|
51
42
|
showLabel$ = false;
|
|
52
43
|
isChecked$ = false;
|
|
53
|
-
bRequired$ = false;
|
|
54
|
-
bReadonly$ = false;
|
|
55
|
-
bDisabled$ = false;
|
|
56
|
-
bVisible$ = true;
|
|
57
|
-
displayMode$?: string = '';
|
|
58
|
-
controlName$: string;
|
|
59
|
-
bHasForm$ = true;
|
|
60
|
-
componentReference = '';
|
|
61
|
-
helperText: string;
|
|
62
44
|
trueLabel$?: string;
|
|
63
45
|
falseLabel$?: string;
|
|
64
46
|
|
|
@@ -70,86 +52,35 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
|
|
|
70
52
|
selectedvalues: any;
|
|
71
53
|
referenceList: string;
|
|
72
54
|
listOfCheckboxes: any[] = [];
|
|
73
|
-
actionsApi: Object;
|
|
74
|
-
propName: string;
|
|
75
55
|
variant?: string;
|
|
76
56
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
private angularPConnect: AngularPConnectService,
|
|
81
|
-
private cdRef: ChangeDetectorRef,
|
|
82
|
-
private utils: Utils
|
|
83
|
-
) {}
|
|
84
|
-
|
|
85
|
-
ngOnInit(): void {
|
|
86
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
87
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
88
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
89
|
-
|
|
90
|
-
// Then, continue on with other initialization
|
|
91
|
-
|
|
92
|
-
// call updateSelf when initializing
|
|
93
|
-
// this.updateSelf();
|
|
94
|
-
this.checkAndUpdate();
|
|
57
|
+
// Override ngOnInit method
|
|
58
|
+
override ngOnInit(): void {
|
|
59
|
+
super.ngOnInit();
|
|
95
60
|
|
|
96
61
|
if (this.selectionMode === 'multi' && this.referenceList?.length > 0 && !this.bReadonly$) {
|
|
97
62
|
this.pConn$.setReferenceList(this.selectionList);
|
|
98
63
|
updateNewInstructions(this.pConn$, this.selectionList);
|
|
99
64
|
}
|
|
100
|
-
|
|
101
|
-
if (this.formGroup$) {
|
|
102
|
-
// add control to formGroup
|
|
103
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
104
|
-
this.fieldControl.setValue(this.value$);
|
|
105
|
-
this.bHasForm$ = true;
|
|
106
|
-
} else {
|
|
107
|
-
this.bReadonly$ = true;
|
|
108
|
-
this.bHasForm$ = false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
ngOnDestroy(): void {
|
|
113
|
-
if (this.formGroup$) {
|
|
114
|
-
this.formGroup$.removeControl(this.controlName$);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (this.angularPConnectData.unsubscribeFn) {
|
|
118
|
-
this.angularPConnectData.unsubscribeFn();
|
|
119
|
-
}
|
|
120
65
|
}
|
|
121
66
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
checkAndUpdate() {
|
|
128
|
-
// Should always check the bridge to see if the component should
|
|
129
|
-
// update itself (re-render)
|
|
130
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
131
|
-
|
|
132
|
-
// ONLY call updateSelf when the component should update
|
|
133
|
-
if (bUpdateSelf) {
|
|
134
|
-
this.updateSelf();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// updateSelf
|
|
139
|
-
updateSelf(): void {
|
|
67
|
+
/**
|
|
68
|
+
* Updates the component when there are changes in the state.
|
|
69
|
+
*/
|
|
70
|
+
override updateSelf(): void {
|
|
140
71
|
// moved this from ngOnInit() and call this from there instead...
|
|
141
72
|
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as CheckboxProps;
|
|
142
73
|
|
|
143
|
-
|
|
144
|
-
this.
|
|
145
|
-
|
|
74
|
+
// Update component common properties
|
|
75
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
76
|
+
|
|
146
77
|
if (this.label$ != '') {
|
|
147
78
|
this.showLabel$ = true;
|
|
148
79
|
}
|
|
149
|
-
|
|
150
|
-
this.actionsApi = this.pConn$.getActionsApi();
|
|
151
|
-
this.propName = this.pConn$.getStateProps().value;
|
|
152
80
|
this.variant = this.configProps$.variant;
|
|
81
|
+
if (this.bReadonly$) {
|
|
82
|
+
this.fieldControl?.disable();
|
|
83
|
+
}
|
|
153
84
|
|
|
154
85
|
// multi case
|
|
155
86
|
this.selectionMode = this.configProps$.selectionMode;
|
|
@@ -176,54 +107,10 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
|
|
|
176
107
|
}
|
|
177
108
|
|
|
178
109
|
this.caption$ = this.configProps$.caption;
|
|
179
|
-
this.helperText = this.configProps$.helperText;
|
|
180
110
|
this.trueLabel$ = this.configProps$.trueLabel || 'Yes';
|
|
181
111
|
this.falseLabel$ = this.configProps$.falseLabel || 'No';
|
|
182
112
|
|
|
183
|
-
|
|
184
|
-
setTimeout(() => {
|
|
185
|
-
if (this.configProps$.required != null) {
|
|
186
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
187
|
-
}
|
|
188
|
-
this.cdRef.detectChanges();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
if (this.configProps$.visibility != null) {
|
|
192
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// disabled
|
|
196
|
-
if (this.configProps$.disabled != undefined) {
|
|
197
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (this.configProps$.readOnly != null) {
|
|
201
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (this.bDisabled$ || this.bReadonly$) {
|
|
205
|
-
this.fieldControl.disable();
|
|
206
|
-
} else {
|
|
207
|
-
this.fieldControl.enable();
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
211
|
-
|
|
212
|
-
// eslint-disable-next-line sonarjs/no-redundant-boolean
|
|
213
|
-
if (this.value$ === 'true' || this.value$ == true) {
|
|
214
|
-
this.isChecked$ = true;
|
|
215
|
-
} else {
|
|
216
|
-
this.isChecked$ = false;
|
|
217
|
-
}
|
|
218
|
-
// trigger display of error message with field control
|
|
219
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
220
|
-
const timer = interval(100).subscribe(() => {
|
|
221
|
-
this.fieldControl.setErrors({ message: true });
|
|
222
|
-
this.fieldControl.markAsTouched();
|
|
223
|
-
|
|
224
|
-
timer.unsubscribe();
|
|
225
|
-
});
|
|
226
|
-
}
|
|
113
|
+
this.isChecked$ = this.value$ === 'true' || this.value$ == true;
|
|
227
114
|
}
|
|
228
115
|
}
|
|
229
116
|
|
|
@@ -261,21 +148,4 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
|
|
|
261
148
|
context: ''
|
|
262
149
|
});
|
|
263
150
|
}
|
|
264
|
-
|
|
265
|
-
getErrorMessage() {
|
|
266
|
-
let errMessage = '';
|
|
267
|
-
|
|
268
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
269
|
-
if (this.fieldControl.hasError('message')) {
|
|
270
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
271
|
-
return errMessage;
|
|
272
|
-
}
|
|
273
|
-
if (this.fieldControl.hasError('required')) {
|
|
274
|
-
errMessage = 'You must enter a value';
|
|
275
|
-
} else if (this.fieldControl.errors) {
|
|
276
|
-
errMessage = this.fieldControl.errors.toString();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return errMessage;
|
|
280
|
-
}
|
|
281
151
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { Component,
|
|
1
|
+
import { Component, forwardRef } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { FormControl,
|
|
3
|
+
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
4
4
|
import { MatInputModule } from '@angular/material/input';
|
|
5
5
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
|
-
import { interval } from 'rxjs';
|
|
7
6
|
import { NgxCurrencyDirective, NgxCurrencyInputMode } from 'ngx-currency';
|
|
8
|
-
|
|
9
|
-
import {
|
|
7
|
+
|
|
8
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
10
9
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
11
10
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
12
11
|
import { getCurrencyCharacters, getCurrencyOptions } from '@pega/angular-sdk-components';
|
|
13
|
-
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
14
12
|
import { format } from '@pega/angular-sdk-components';
|
|
13
|
+
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
15
14
|
|
|
16
15
|
interface CurrrencyProps extends PConnFieldProps {
|
|
17
16
|
// If any, enter additional props that only exist on Currency here
|
|
@@ -26,173 +25,59 @@ interface CurrrencyProps extends PConnFieldProps {
|
|
|
26
25
|
styleUrls: ['./currency.component.scss'],
|
|
27
26
|
imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, NgxCurrencyDirective, forwardRef(() => ComponentMapperComponent)]
|
|
28
27
|
})
|
|
29
|
-
export class CurrencyComponent
|
|
30
|
-
@Input() pConn$: typeof PConnect;
|
|
31
|
-
@Input() formGroup$: FormGroup;
|
|
32
|
-
|
|
33
|
-
// Used with AngularPConnect
|
|
34
|
-
angularPConnectData: AngularPConnectData = {};
|
|
28
|
+
export class CurrencyComponent extends FieldBase {
|
|
35
29
|
configProps$: CurrrencyProps;
|
|
30
|
+
override fieldControl = new FormControl<number | null>(null, { updateOn: 'blur' });
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
value$: any;
|
|
39
|
-
bRequired$ = false;
|
|
40
|
-
bReadonly$ = false;
|
|
41
|
-
bDisabled$ = false;
|
|
42
|
-
bVisible$ = true;
|
|
43
|
-
displayMode$?: string = '';
|
|
44
|
-
controlName$: string;
|
|
45
|
-
bHasForm$ = true;
|
|
46
|
-
componentReference = '';
|
|
47
|
-
testId: string;
|
|
48
|
-
helperText: string;
|
|
49
|
-
placeholder: string;
|
|
50
|
-
currencyISOCode = 'USD';
|
|
51
|
-
currencyOptions: Object = {};
|
|
52
|
-
|
|
53
|
-
fieldControl = new FormControl<number | null>(null, { updateOn: 'blur' });
|
|
32
|
+
currencyOptions: object = {};
|
|
54
33
|
currencySymbol: string;
|
|
55
34
|
thousandSeparator: string;
|
|
56
35
|
decimalSeparator: string;
|
|
57
|
-
inputMode: any;
|
|
58
36
|
decimalPrecision: number | undefined;
|
|
59
37
|
formattedValue: string;
|
|
60
38
|
formatter;
|
|
39
|
+
inputMode = NgxCurrencyInputMode.Natural;
|
|
61
40
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
ngOnInit(): void {
|
|
69
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
70
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
71
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
72
|
-
|
|
73
|
-
// Then, continue on with other initialization
|
|
41
|
+
/**
|
|
42
|
+
* Updates the component when there are changes in the state.
|
|
43
|
+
*/
|
|
44
|
+
override updateSelf(): void {
|
|
45
|
+
// Resolve configuration properties
|
|
46
|
+
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as CurrrencyProps;
|
|
74
47
|
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
this.checkAndUpdate();
|
|
48
|
+
// Update component common properties
|
|
49
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
78
50
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
// Extract and normalize the value property
|
|
52
|
+
const { value } = this.configProps$;
|
|
53
|
+
if (value) {
|
|
54
|
+
this.value$ = typeof value === 'string' ? parseFloat(value) : value;
|
|
82
55
|
this.fieldControl.setValue(this.value$);
|
|
83
|
-
this.bHasForm$ = true;
|
|
84
|
-
} else {
|
|
85
|
-
this.bReadonly$ = true;
|
|
86
|
-
this.bHasForm$ = false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
ngOnDestroy(): void {
|
|
91
|
-
if (this.formGroup$) {
|
|
92
|
-
this.formGroup$.removeControl(this.controlName$);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (this.angularPConnectData.unsubscribeFn) {
|
|
96
|
-
this.angularPConnectData.unsubscribeFn();
|
|
97
56
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Callback passed when subscribing to store change
|
|
101
|
-
onStateChange() {
|
|
102
|
-
this.checkAndUpdate();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
checkAndUpdate() {
|
|
106
|
-
// Should always check the bridge to see if the component should
|
|
107
|
-
// update itself (re-render)
|
|
108
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
109
57
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
this.updateSelf();
|
|
113
|
-
}
|
|
58
|
+
// update currency properties
|
|
59
|
+
this.updateCurrencyProperties(this.configProps$);
|
|
114
60
|
}
|
|
115
61
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
let nValue: any = this.configProps$.value;
|
|
127
|
-
if (nValue) {
|
|
128
|
-
if (typeof nValue === 'string') {
|
|
129
|
-
nValue = parseFloat(nValue);
|
|
130
|
-
}
|
|
131
|
-
this.value$ = nValue;
|
|
132
|
-
this.fieldControl.setValue(this.value$);
|
|
133
|
-
}
|
|
134
|
-
this.helperText = this.configProps$.helperText;
|
|
135
|
-
this.placeholder = this.configProps$.placeholder || '';
|
|
136
|
-
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
|
|
62
|
+
/**
|
|
63
|
+
* Updates the currency properties
|
|
64
|
+
*
|
|
65
|
+
* @param {Object} configProps - Configuration properties.
|
|
66
|
+
* @param {boolean} configProps.allowDecimals - Whether to allow decimal values.
|
|
67
|
+
* @param {string} configProps.currencyISOCode - The ISO code of the currency.
|
|
68
|
+
* @param {string} configProps.formatter - The formatter type (e.g., 'currency').
|
|
69
|
+
*/
|
|
70
|
+
protected updateCurrencyProperties(configProps): void {
|
|
71
|
+
const { allowDecimals, currencyISOCode = 'USD', formatter } = configProps;
|
|
137
72
|
|
|
138
73
|
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
139
74
|
this.currencySymbol = theSymbols.theCurrencySymbol;
|
|
140
75
|
this.thousandSeparator = theSymbols.theDigitGroupSeparator;
|
|
141
76
|
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
142
|
-
this.
|
|
77
|
+
this.decimalPrecision = allowDecimals ? 2 : 0;
|
|
143
78
|
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
if (this.formatter) {
|
|
147
|
-
this.formattedValue = format(this.value$, this.formatter.toLowerCase(), theCurrencyOptions);
|
|
148
|
-
} else {
|
|
149
|
-
this.formattedValue = format(this.value$, 'currency', theCurrencyOptions);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
154
|
-
setTimeout(() => {
|
|
155
|
-
if (this.configProps$.required != null) {
|
|
156
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
157
|
-
}
|
|
158
|
-
this.cdRef.detectChanges();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
if (this.configProps$.visibility != null) {
|
|
162
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// disabled
|
|
166
|
-
if (this.configProps$.disabled != undefined) {
|
|
167
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (this.bDisabled$) {
|
|
171
|
-
this.fieldControl.disable();
|
|
172
|
-
} else {
|
|
173
|
-
this.fieldControl.enable();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (this.configProps$.readOnly != null) {
|
|
177
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (this.configProps$.currencyISOCode != null) {
|
|
181
|
-
this.currencyISOCode = this.configProps$.currencyISOCode;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
this.decimalPrecision = this.configProps$?.allowDecimals ? 2 : 0;
|
|
185
|
-
|
|
186
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
187
|
-
|
|
188
|
-
// trigger display of error message with field control
|
|
189
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
190
|
-
const timer = interval(100).subscribe(() => {
|
|
191
|
-
this.fieldControl.setErrors({ message: true });
|
|
192
|
-
this.fieldControl.markAsTouched();
|
|
193
|
-
|
|
194
|
-
timer.unsubscribe();
|
|
195
|
-
});
|
|
79
|
+
if (['DISPLAY_ONLY', 'STACKED_LARGE_VAL'].includes(this.displayMode$)) {
|
|
80
|
+
this.formattedValue = format(this.value$, formatter ? formatter.toLowerCase() : 'currency', getCurrencyOptions(currencyISOCode));
|
|
196
81
|
}
|
|
197
82
|
}
|
|
198
83
|
|
|
@@ -217,21 +102,4 @@ export class CurrencyComponent implements OnInit, OnDestroy {
|
|
|
217
102
|
handleEvent(actionsApi, 'changeNblur', propName, value);
|
|
218
103
|
}
|
|
219
104
|
}
|
|
220
|
-
|
|
221
|
-
getErrorMessage() {
|
|
222
|
-
let errMessage = '';
|
|
223
|
-
|
|
224
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
225
|
-
if (this.fieldControl.hasError('message')) {
|
|
226
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
227
|
-
return errMessage;
|
|
228
|
-
}
|
|
229
|
-
if (this.fieldControl.hasError('required')) {
|
|
230
|
-
errMessage = 'You must enter a value';
|
|
231
|
-
} else if (this.fieldControl.errors) {
|
|
232
|
-
errMessage = this.fieldControl.errors.toString();
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return errMessage;
|
|
236
|
-
}
|
|
237
105
|
}
|