@pega/angular-sdk-overrides 0.25.1 → 0.25.2
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,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, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
4
|
import { MatInputModule } from '@angular/material/input';
|
|
5
5
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
6
|
import { NgxCurrencyDirective, NgxCurrencyInputMode } from 'ngx-currency';
|
|
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 { 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 DecimalProps extends PConnFieldProps {
|
|
17
16
|
// If any, enter additional props that only exist on Decimal here
|
|
@@ -35,176 +34,69 @@ interface DecimalProps extends PConnFieldProps {
|
|
|
35
34
|
forwardRef(() => ComponentMapperComponent)
|
|
36
35
|
]
|
|
37
36
|
})
|
|
38
|
-
export class DecimalComponent
|
|
39
|
-
@Input() pConn$: typeof PConnect;
|
|
40
|
-
@Input() formGroup$: FormGroup;
|
|
41
|
-
|
|
42
|
-
// Used with AngularPConnect
|
|
43
|
-
angularPConnectData: AngularPConnectData = {};
|
|
37
|
+
export class DecimalComponent extends FieldBase {
|
|
44
38
|
configProps$: DecimalProps;
|
|
39
|
+
override fieldControl = new FormControl<number | null>(null, null);
|
|
45
40
|
|
|
46
|
-
label$ = '';
|
|
47
|
-
value$: any;
|
|
48
|
-
bRequired$ = false;
|
|
49
|
-
bReadonly$ = false;
|
|
50
|
-
bDisabled$ = false;
|
|
51
|
-
bVisible$ = true;
|
|
52
|
-
displayMode$?: string = '';
|
|
53
|
-
controlName$: string;
|
|
54
|
-
bHasForm$ = true;
|
|
55
|
-
componentReference = '';
|
|
56
|
-
testId: string;
|
|
57
|
-
helperText: string;
|
|
58
|
-
placeholder: string;
|
|
59
|
-
|
|
60
|
-
fieldControl = new FormControl<number | null>(null, null);
|
|
61
41
|
decimalSeparator: string;
|
|
62
42
|
thousandSeparator: string;
|
|
63
43
|
currencySymbol = '';
|
|
64
44
|
decimalPrecision: number | undefined;
|
|
65
45
|
formatter;
|
|
66
46
|
formattedValue: any;
|
|
67
|
-
inputMode: any;
|
|
47
|
+
inputMode: any = NgxCurrencyInputMode.Natural;
|
|
68
48
|
suffix = '';
|
|
69
49
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
ngOnInit(): void {
|
|
77
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
78
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
79
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
80
|
-
|
|
81
|
-
// Then, continue on with other initialization
|
|
50
|
+
/**
|
|
51
|
+
* Updates the component when there are changes in the state.
|
|
52
|
+
*/
|
|
53
|
+
override updateSelf(): void {
|
|
54
|
+
// Resolve config properties
|
|
55
|
+
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as DecimalProps;
|
|
82
56
|
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
this.checkAndUpdate();
|
|
57
|
+
// Update common properties
|
|
58
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
86
59
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
60
|
+
// Extract and normalize the value property
|
|
61
|
+
const { value } = this.configProps$;
|
|
62
|
+
if (value) {
|
|
63
|
+
this.value$ = typeof value === 'string' ? parseFloat(value) : value;
|
|
90
64
|
this.fieldControl.setValue(this.value$);
|
|
91
|
-
this.bHasForm$ = true;
|
|
92
|
-
} else {
|
|
93
|
-
this.bReadonly$ = true;
|
|
94
|
-
this.bHasForm$ = false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
ngOnDestroy(): void {
|
|
99
|
-
if (this.formGroup$) {
|
|
100
|
-
this.formGroup$.removeControl(this.controlName$);
|
|
101
65
|
}
|
|
102
66
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
67
|
+
// updates decimal properties
|
|
68
|
+
this.updateDecimalProperties(this.configProps$);
|
|
106
69
|
}
|
|
107
70
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.updateSelf();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// updateSelf
|
|
125
|
-
updateSelf(): void {
|
|
126
|
-
// starting very simple...
|
|
127
|
-
|
|
128
|
-
// moved this from ngOnInit() and call this from there instead...
|
|
129
|
-
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as DecimalProps;
|
|
130
|
-
this.testId = this.configProps$.testId;
|
|
131
|
-
this.label$ = this.configProps$.label;
|
|
132
|
-
this.displayMode$ = this.configProps$.displayMode;
|
|
133
|
-
this.inputMode = NgxCurrencyInputMode.Natural;
|
|
134
|
-
let nValue: any = this.configProps$.value;
|
|
135
|
-
if (nValue) {
|
|
136
|
-
if (typeof nValue === 'string') {
|
|
137
|
-
nValue = parseFloat(nValue);
|
|
138
|
-
}
|
|
139
|
-
this.value$ = nValue;
|
|
140
|
-
this.fieldControl.setValue(this.value$);
|
|
141
|
-
}
|
|
142
|
-
this.helperText = this.configProps$.helperText;
|
|
143
|
-
this.placeholder = this.configProps$.placeholder || '';
|
|
144
|
-
const showGroupSeparators = this.configProps$.showGroupSeparators;
|
|
145
|
-
const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
|
|
146
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Updates decimal properties based on the provided configuration.
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} configProps - Configuration properties.
|
|
75
|
+
* @param {string} configProps.currencyISOCode - ISO code of the currency.
|
|
76
|
+
* @param {string} configProps.formatter - Formatter type (e.g., 'decimal', 'currency').
|
|
77
|
+
* @param {boolean} configProps.showGroupSeparators - Whether to show group separators.
|
|
78
|
+
*/
|
|
79
|
+
protected updateDecimalProperties(configProps): void {
|
|
80
|
+
const { currencyISOCode = '', formatter, showGroupSeparators } = configProps;
|
|
81
|
+
|
|
82
|
+
// Extract currency symbols and options
|
|
147
83
|
const theSymbols = getCurrencyCharacters(currencyISOCode);
|
|
148
84
|
this.decimalSeparator = theSymbols.theDecimalIndicator;
|
|
149
85
|
this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
|
|
150
86
|
|
|
151
87
|
const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
|
|
152
|
-
|
|
88
|
+
const formatterLower = formatter?.toLowerCase() || 'decimal';
|
|
89
|
+
this.formattedValue = format(this.value$, formatterLower, theCurrencyOptions);
|
|
153
90
|
|
|
154
|
-
if (this.formatter) {
|
|
155
|
-
this.formattedValue = format(this.value$, this.formatter.toLowerCase(), theCurrencyOptions);
|
|
156
|
-
} else {
|
|
157
|
-
this.formattedValue = format(this.value$, 'decimal', theCurrencyOptions);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
161
|
-
setTimeout(() => {
|
|
162
|
-
if (this.configProps$.required != null) {
|
|
163
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
164
|
-
}
|
|
165
|
-
this.cdRef.detectChanges();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
if (this.configProps$.visibility != null) {
|
|
169
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (this.configProps$.readOnly != null) {
|
|
173
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// disabled
|
|
177
|
-
if (this.configProps$.disabled != undefined) {
|
|
178
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (this.bDisabled$) {
|
|
182
|
-
this.fieldControl.disable();
|
|
183
|
-
} else {
|
|
184
|
-
this.fieldControl.enable();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (this.bReadonly$ && this.formatter === 'Currency') {
|
|
91
|
+
if (this.bReadonly$ && formatter === 'Currency') {
|
|
188
92
|
this.currencySymbol = theSymbols.theCurrencySymbol;
|
|
189
93
|
}
|
|
190
94
|
|
|
191
|
-
if (this.bReadonly$ &&
|
|
95
|
+
if (this.bReadonly$ && formatter === 'Percentage') {
|
|
192
96
|
this.suffix = '%';
|
|
193
97
|
}
|
|
194
98
|
|
|
195
99
|
this.decimalPrecision = this.configProps$?.decimalPrecision ?? 2;
|
|
196
|
-
|
|
197
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
198
|
-
|
|
199
|
-
// trigger display of error message with field control
|
|
200
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
201
|
-
const timer = interval(100).subscribe(() => {
|
|
202
|
-
this.fieldControl.setErrors({ message: true });
|
|
203
|
-
this.fieldControl.markAsTouched();
|
|
204
|
-
|
|
205
|
-
timer.unsubscribe();
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
100
|
}
|
|
209
101
|
|
|
210
102
|
fieldOnBlur(event: any) {
|
|
@@ -229,21 +121,4 @@ export class DecimalComponent implements OnInit, OnDestroy {
|
|
|
229
121
|
handleEvent(actionsApi, 'changeNblur', propName, value);
|
|
230
122
|
}
|
|
231
123
|
}
|
|
232
|
-
|
|
233
|
-
getErrorMessage() {
|
|
234
|
-
let errMessage = '';
|
|
235
|
-
|
|
236
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
237
|
-
if (this.fieldControl.hasError('message')) {
|
|
238
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
239
|
-
return errMessage;
|
|
240
|
-
}
|
|
241
|
-
if (this.fieldControl.hasError('required')) {
|
|
242
|
-
errMessage = 'You must enter a value';
|
|
243
|
-
} else if (this.fieldControl.errors) {
|
|
244
|
-
errMessage = this.fieldControl.errors.toString();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return errMessage;
|
|
248
|
-
}
|
|
249
124
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { Component, OnInit,
|
|
1
|
+
import { Component, OnInit, forwardRef, OnDestroy, Output, EventEmitter } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
4
|
import { MatOptionModule } from '@angular/material/core';
|
|
5
5
|
import { MatSelectModule } from '@angular/material/select';
|
|
6
6
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
7
|
-
import { interval } from 'rxjs';
|
|
8
7
|
import isEqual from 'fast-deep-equal';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import { Utils } from '@pega/angular-sdk-components';
|
|
8
|
+
|
|
9
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
12
10
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
13
11
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
14
12
|
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
@@ -70,67 +68,18 @@ interface DropdownProps extends PConnFieldProps {
|
|
|
70
68
|
styleUrls: ['./dropdown.component.scss'],
|
|
71
69
|
imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatSelectModule, MatOptionModule, forwardRef(() => ComponentMapperComponent)]
|
|
72
70
|
})
|
|
73
|
-
export class DropdownComponent implements OnInit, OnDestroy {
|
|
74
|
-
@
|
|
75
|
-
@Input() formGroup$: FormGroup;
|
|
71
|
+
export class DropdownComponent extends FieldBase implements OnInit, OnDestroy {
|
|
72
|
+
@Output() onRecordChange: EventEmitter<any> = new EventEmitter();
|
|
76
73
|
|
|
77
|
-
// Used with AngularPConnect
|
|
78
|
-
angularPConnectData: AngularPConnectData = {};
|
|
79
74
|
configProps$: DropdownProps;
|
|
80
75
|
|
|
81
|
-
label$ = '';
|
|
82
|
-
value$ = '';
|
|
83
|
-
bRequired$ = false;
|
|
84
|
-
bReadonly$ = false;
|
|
85
|
-
bDisabled$ = false;
|
|
86
|
-
bVisible$ = true;
|
|
87
|
-
displayMode$?: string = '';
|
|
88
|
-
controlName$: string;
|
|
89
|
-
bHasForm$ = true;
|
|
90
76
|
options$: IOption[];
|
|
91
|
-
componentReference = '';
|
|
92
|
-
testId = '';
|
|
93
|
-
helperText: string;
|
|
94
|
-
hideLabel: any;
|
|
95
77
|
theDatasource: any[] | null;
|
|
96
|
-
fieldControl = new FormControl('', null);
|
|
97
|
-
fieldMetadata: any[];
|
|
98
78
|
localeContext = '';
|
|
99
79
|
localeClass = '';
|
|
100
80
|
localeName = '';
|
|
101
81
|
localePath = '';
|
|
102
82
|
localizedValue = '';
|
|
103
|
-
actionsApi: Object;
|
|
104
|
-
propName: string;
|
|
105
|
-
|
|
106
|
-
constructor(
|
|
107
|
-
private angularPConnect: AngularPConnectService,
|
|
108
|
-
private cdRef: ChangeDetectorRef,
|
|
109
|
-
private utils: Utils,
|
|
110
|
-
private dataPageService: DatapageService
|
|
111
|
-
) {}
|
|
112
|
-
|
|
113
|
-
ngOnInit(): void {
|
|
114
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
115
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
116
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
117
|
-
|
|
118
|
-
// Then, continue on with other initialization
|
|
119
|
-
|
|
120
|
-
// call updateSelf when initializing
|
|
121
|
-
this.checkAndUpdate();
|
|
122
|
-
// this should get called afer checkAndUpdate
|
|
123
|
-
|
|
124
|
-
if (this.formGroup$) {
|
|
125
|
-
// add control to formGroup
|
|
126
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
127
|
-
this.fieldControl.setValue(this.value$);
|
|
128
|
-
this.bHasForm$ = true;
|
|
129
|
-
} else {
|
|
130
|
-
this.bReadonly$ = true;
|
|
131
|
-
this.bHasForm$ = false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
83
|
|
|
135
84
|
set options(options: IOption[]) {
|
|
136
85
|
this.options$ = options;
|
|
@@ -144,80 +93,34 @@ export class DropdownComponent implements OnInit, OnDestroy {
|
|
|
144
93
|
}
|
|
145
94
|
}
|
|
146
95
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.angularPConnectData.unsubscribeFn();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Callback passed when subscribing to store change
|
|
158
|
-
onStateChange() {
|
|
159
|
-
this.checkAndUpdate();
|
|
160
|
-
}
|
|
96
|
+
/**
|
|
97
|
+
* Updates the component when there are changes in the state.
|
|
98
|
+
*/
|
|
99
|
+
override updateSelf(): void {
|
|
100
|
+
// Resolve configuration properties
|
|
101
|
+
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as DropdownProps;
|
|
161
102
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// update itself (re-render)
|
|
165
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
103
|
+
// Update component common properties
|
|
104
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
166
105
|
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
this.updateSelf();
|
|
170
|
-
}
|
|
106
|
+
// Set component specific properties
|
|
107
|
+
this.updateDropdownProperties(this.configProps$);
|
|
171
108
|
}
|
|
172
109
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
110
|
+
/**
|
|
111
|
+
* Updates dropdown properties based on the provided configuration.
|
|
112
|
+
* @param configProps - Configuration properties
|
|
113
|
+
*/
|
|
114
|
+
updateDropdownProperties(configProps) {
|
|
115
|
+
const { value, fieldMetadata, datasource } = configProps;
|
|
180
116
|
|
|
181
|
-
this.
|
|
182
|
-
this.displayMode$ = this.configProps$.displayMode;
|
|
183
|
-
this.label$ = this.configProps$.label;
|
|
184
|
-
this.helperText = this.configProps$.helperText;
|
|
185
|
-
this.hideLabel = this.configProps$.hideLabel;
|
|
186
|
-
const datasource = this.configProps$.datasource;
|
|
187
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
188
|
-
setTimeout(() => {
|
|
189
|
-
if (this.configProps$.required != null) {
|
|
190
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
191
|
-
}
|
|
192
|
-
this.cdRef.detectChanges();
|
|
193
|
-
});
|
|
117
|
+
this.value$ = value;
|
|
194
118
|
|
|
195
119
|
if (!isEqual(datasource, this.theDatasource)) {
|
|
196
120
|
// inbound datasource is different, so update theDatasource
|
|
197
121
|
this.theDatasource = datasource || null;
|
|
198
122
|
}
|
|
199
123
|
|
|
200
|
-
if (this.configProps$.visibility != null) {
|
|
201
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// disabled
|
|
205
|
-
if (this.configProps$.disabled != undefined) {
|
|
206
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (this.bDisabled$) {
|
|
210
|
-
this.fieldControl.disable();
|
|
211
|
-
} else {
|
|
212
|
-
this.fieldControl.enable();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (this.configProps$.readOnly != null) {
|
|
216
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
220
|
-
|
|
221
124
|
if (this.value$ === '' && !this.bReadonly$) {
|
|
222
125
|
this.value$ = 'Select';
|
|
223
126
|
}
|
|
@@ -234,8 +137,7 @@ export class DropdownComponent implements OnInit, OnDestroy {
|
|
|
234
137
|
const className = this.pConn$.getCaseInfo().getClassName();
|
|
235
138
|
const refName = this.propName?.slice(this.propName.lastIndexOf('.') + 1);
|
|
236
139
|
|
|
237
|
-
|
|
238
|
-
const metaData = Array.isArray(this.fieldMetadata) ? this.fieldMetadata.filter(field => field?.classID === className)[0] : this.fieldMetadata;
|
|
140
|
+
const metaData = Array.isArray(fieldMetadata) ? fieldMetadata.filter(field => field?.classID === className)[0] : fieldMetadata;
|
|
239
141
|
|
|
240
142
|
let displayName = metaData?.datasource?.propertyForDisplayText;
|
|
241
143
|
displayName = displayName?.slice(displayName.lastIndexOf('.') + 1);
|
|
@@ -251,16 +153,8 @@ export class DropdownComponent implements OnInit, OnDestroy {
|
|
|
251
153
|
);
|
|
252
154
|
|
|
253
155
|
this.localizedValue = this.options$?.find(opt => opt.key === this.value$)?.value || this.localizedValue;
|
|
254
|
-
this.getDatapageData();
|
|
255
|
-
// trigger display of error message with field control
|
|
256
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
257
|
-
const timer = interval(100).subscribe(() => {
|
|
258
|
-
this.fieldControl.setErrors({ message: true });
|
|
259
|
-
this.fieldControl.markAsTouched();
|
|
260
156
|
|
|
261
|
-
|
|
262
|
-
});
|
|
263
|
-
}
|
|
157
|
+
this.getDatapageData();
|
|
264
158
|
}
|
|
265
159
|
|
|
266
160
|
getDatapageData() {
|
|
@@ -336,12 +230,13 @@ export class DropdownComponent implements OnInit, OnDestroy {
|
|
|
336
230
|
event.value = '';
|
|
337
231
|
}
|
|
338
232
|
handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value);
|
|
339
|
-
|
|
340
|
-
this.configProps$.onRecordChange(event);
|
|
341
|
-
}
|
|
233
|
+
|
|
342
234
|
this.pConn$.clearErrorMessages({
|
|
343
235
|
property: this.propName
|
|
344
236
|
});
|
|
237
|
+
if (this.onRecordChange) {
|
|
238
|
+
this.onRecordChange.emit(event.value);
|
|
239
|
+
}
|
|
345
240
|
}
|
|
346
241
|
|
|
347
242
|
getLocalizedOptionValue(opt: IOption) {
|
|
@@ -351,21 +246,4 @@ export class DropdownComponent implements OnInit, OnDestroy {
|
|
|
351
246
|
this.pConn$.getLocaleRuleNameFromKeys(this.localeClass, this.localeContext, this.localeName)
|
|
352
247
|
);
|
|
353
248
|
}
|
|
354
|
-
|
|
355
|
-
getErrorMessage() {
|
|
356
|
-
let errMessage = '';
|
|
357
|
-
|
|
358
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
359
|
-
if (this.fieldControl.hasError('message')) {
|
|
360
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
361
|
-
return errMessage;
|
|
362
|
-
}
|
|
363
|
-
if (this.fieldControl.hasError('required')) {
|
|
364
|
-
errMessage = 'You must enter a value';
|
|
365
|
-
} else if (this.fieldControl.errors) {
|
|
366
|
-
errMessage = this.fieldControl.errors.toString();
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
return errMessage;
|
|
370
|
-
}
|
|
371
249
|
}
|