@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,14 +1,13 @@
|
|
|
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 { MatInputModule } from '@angular/material/input';
|
|
5
5
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import { Utils } from '@pega/angular-sdk-components';
|
|
6
|
+
|
|
7
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
9
8
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
10
|
-
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
11
9
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
10
|
+
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
12
11
|
|
|
13
12
|
interface EmailProps extends PConnFieldProps {
|
|
14
13
|
// If any, enter additional props that only exist on Email here
|
|
@@ -20,141 +19,22 @@ interface EmailProps extends PConnFieldProps {
|
|
|
20
19
|
styleUrls: ['./email.component.scss'],
|
|
21
20
|
imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, forwardRef(() => ComponentMapperComponent)]
|
|
22
21
|
})
|
|
23
|
-
export class EmailComponent implements OnInit, OnDestroy {
|
|
24
|
-
@Input() pConn$: typeof PConnect;
|
|
25
|
-
@Input() formGroup$: FormGroup;
|
|
26
|
-
|
|
27
|
-
// Used with AngularPConnect
|
|
28
|
-
angularPConnectData: AngularPConnectData = {};
|
|
22
|
+
export class EmailComponent extends FieldBase implements OnInit, OnDestroy {
|
|
29
23
|
configProps$: EmailProps;
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
bVisible$ = true;
|
|
37
|
-
displayMode$?: string = '';
|
|
38
|
-
controlName$: string;
|
|
39
|
-
bHasForm$ = true;
|
|
40
|
-
componentReference = '';
|
|
41
|
-
testId: string;
|
|
42
|
-
helperText: string;
|
|
43
|
-
placeholder: string;
|
|
44
|
-
|
|
45
|
-
fieldControl = new FormControl('', null);
|
|
46
|
-
actionsApi: Object;
|
|
47
|
-
propName: string;
|
|
48
|
-
|
|
49
|
-
constructor(
|
|
50
|
-
private angularPConnect: AngularPConnectService,
|
|
51
|
-
private cdRef: ChangeDetectorRef,
|
|
52
|
-
private utils: Utils
|
|
53
|
-
) {}
|
|
54
|
-
|
|
55
|
-
ngOnInit(): void {
|
|
56
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
57
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
58
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
59
|
-
|
|
60
|
-
// Then, continue on with other initialization
|
|
61
|
-
|
|
62
|
-
// call updateSelf when initializing
|
|
63
|
-
// this.updateSelf();
|
|
64
|
-
this.checkAndUpdate();
|
|
65
|
-
|
|
66
|
-
if (this.formGroup$) {
|
|
67
|
-
// add control to formGroup
|
|
68
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
69
|
-
this.fieldControl.setValue(this.value$);
|
|
70
|
-
this.bHasForm$ = true;
|
|
71
|
-
} else {
|
|
72
|
-
this.bReadonly$ = true;
|
|
73
|
-
this.bHasForm$ = false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
ngOnDestroy(): void {
|
|
78
|
-
if (this.formGroup$) {
|
|
79
|
-
this.formGroup$.removeControl(this.controlName$);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (this.angularPConnectData.unsubscribeFn) {
|
|
83
|
-
this.angularPConnectData.unsubscribeFn();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Callback passed when subscribing to store change
|
|
88
|
-
onStateChange() {
|
|
89
|
-
this.checkAndUpdate();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
checkAndUpdate() {
|
|
93
|
-
// Should always check the bridge to see if the component should
|
|
94
|
-
// update itself (re-render)
|
|
95
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
96
|
-
|
|
97
|
-
// ONLY call updateSelf when the component should update
|
|
98
|
-
if (bUpdateSelf) {
|
|
99
|
-
this.updateSelf();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// updateSelf
|
|
104
|
-
updateSelf(): void {
|
|
105
|
-
// moved this from ngOnInit() and call this from there instead...
|
|
25
|
+
/**
|
|
26
|
+
* Updates the component when there are changes in the state.
|
|
27
|
+
*/
|
|
28
|
+
override updateSelf(): void {
|
|
29
|
+
// Resolve configuration properties
|
|
106
30
|
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as EmailProps;
|
|
107
|
-
this.testId = this.configProps$.testId;
|
|
108
|
-
this.label$ = this.configProps$.label;
|
|
109
|
-
this.displayMode$ = this.configProps$.displayMode;
|
|
110
31
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
this.helperText = this.configProps$.helperText;
|
|
115
|
-
this.placeholder = this.configProps$.placeholder || '';
|
|
116
|
-
|
|
117
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
if (this.configProps$.required != null) {
|
|
120
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
121
|
-
}
|
|
122
|
-
this.cdRef.detectChanges();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
if (this.configProps$.visibility != null) {
|
|
126
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// disabled
|
|
130
|
-
if (this.configProps$.disabled != undefined) {
|
|
131
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (this.bDisabled$) {
|
|
135
|
-
this.fieldControl.disable();
|
|
136
|
-
} else {
|
|
137
|
-
this.fieldControl.enable();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (this.configProps$.readOnly != null) {
|
|
141
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
this.actionsApi = this.pConn$.getActionsApi();
|
|
145
|
-
this.propName = this.pConn$.getStateProps().value;
|
|
146
|
-
|
|
147
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
32
|
+
// Update component common properties
|
|
33
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
148
34
|
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.fieldControl.setErrors({ message: true });
|
|
153
|
-
this.fieldControl.markAsTouched();
|
|
154
|
-
|
|
155
|
-
timer.unsubscribe();
|
|
156
|
-
});
|
|
157
|
-
}
|
|
35
|
+
// Set component specific properties
|
|
36
|
+
const { value } = this.configProps$;
|
|
37
|
+
this.value$ = value;
|
|
158
38
|
}
|
|
159
39
|
|
|
160
40
|
fieldOnChange(event: any) {
|
|
@@ -162,8 +42,6 @@ export class EmailComponent implements OnInit, OnDestroy {
|
|
|
162
42
|
const isValueChanged = event.target.value.toString() !== oldVal.toString();
|
|
163
43
|
|
|
164
44
|
if (isValueChanged) {
|
|
165
|
-
const value = event?.target?.value;
|
|
166
|
-
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
|
|
167
45
|
this.pConn$.clearErrorMessages({
|
|
168
46
|
property: this.propName
|
|
169
47
|
});
|
|
@@ -179,21 +57,4 @@ export class EmailComponent implements OnInit, OnDestroy {
|
|
|
179
57
|
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
|
|
180
58
|
}
|
|
181
59
|
}
|
|
182
|
-
|
|
183
|
-
getErrorMessage() {
|
|
184
|
-
let errMessage = '';
|
|
185
|
-
|
|
186
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
187
|
-
if (this.fieldControl.hasError('message')) {
|
|
188
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
189
|
-
return errMessage;
|
|
190
|
-
}
|
|
191
|
-
if (this.fieldControl.hasError('required')) {
|
|
192
|
-
errMessage = 'You must enter a value';
|
|
193
|
-
} else if (this.fieldControl.errors) {
|
|
194
|
-
errMessage = this.fieldControl.errors.toString();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return errMessage;
|
|
198
|
-
}
|
|
199
60
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Directive, inject, Input, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { FormControl, FormGroup } from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
|
|
5
|
+
import { Utils } from '@pega/angular-sdk-components';
|
|
6
|
+
|
|
7
|
+
@Directive()
|
|
8
|
+
export class FieldBase implements OnInit, OnDestroy {
|
|
9
|
+
@Input() pConn$: typeof PConnect;
|
|
10
|
+
@Input() formGroup$: FormGroup;
|
|
11
|
+
|
|
12
|
+
protected angularPConnect = inject(AngularPConnectService);
|
|
13
|
+
protected utils = inject(Utils);
|
|
14
|
+
|
|
15
|
+
protected angularPConnectData: AngularPConnectData = {};
|
|
16
|
+
|
|
17
|
+
fieldControl: FormControl<any> = new FormControl('', null);
|
|
18
|
+
controlName$: string;
|
|
19
|
+
actionsApi: object;
|
|
20
|
+
propName: string;
|
|
21
|
+
|
|
22
|
+
bHasForm$ = true;
|
|
23
|
+
testId: string;
|
|
24
|
+
helperText: string;
|
|
25
|
+
placeholder: string;
|
|
26
|
+
value$: any = '';
|
|
27
|
+
label$ = '';
|
|
28
|
+
hideLabel = false;
|
|
29
|
+
bRequired$ = false;
|
|
30
|
+
bReadonly$ = false;
|
|
31
|
+
bDisabled$ = false;
|
|
32
|
+
bVisible$ = true;
|
|
33
|
+
displayMode$ = '';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Initializes the component, registers with AngularPConnect, and sets up form control.
|
|
37
|
+
*/
|
|
38
|
+
ngOnInit(): void {
|
|
39
|
+
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
40
|
+
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange.bind(this));
|
|
41
|
+
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
42
|
+
|
|
43
|
+
// call checkAndUpdate
|
|
44
|
+
this.checkAndUpdate();
|
|
45
|
+
|
|
46
|
+
if (this.formGroup$) {
|
|
47
|
+
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
48
|
+
this.fieldControl.setValue(this.value$);
|
|
49
|
+
this.bHasForm$ = true;
|
|
50
|
+
} else {
|
|
51
|
+
this.bReadonly$ = true;
|
|
52
|
+
this.bHasForm$ = false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.actionsApi = this.pConn$.getActionsApi();
|
|
56
|
+
this.propName = this.pConn$.getStateProps().value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cleans up the component by removing it from the form group and unsubscribing from any observables.
|
|
61
|
+
*/
|
|
62
|
+
ngOnDestroy(): void {
|
|
63
|
+
if (this.formGroup$) {
|
|
64
|
+
this.formGroup$.removeControl(this.controlName$);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (this.angularPConnectData.unsubscribeFn) {
|
|
68
|
+
this.angularPConnectData.unsubscribeFn();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Callback passed when subscribing to store change
|
|
73
|
+
onStateChange() {
|
|
74
|
+
this.checkAndUpdate();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Should always check the bridge to see if the component should update itself (re-render)
|
|
78
|
+
checkAndUpdate() {
|
|
79
|
+
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
80
|
+
|
|
81
|
+
// ONLY call updateSelf when the component should update
|
|
82
|
+
if (bUpdateSelf) {
|
|
83
|
+
this.updateSelf();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// will be overriden by child components
|
|
88
|
+
updateSelf(): void {}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Updates the component's common properties based on the provided configuration.
|
|
92
|
+
*
|
|
93
|
+
* @param configProps The configuration properties to update.
|
|
94
|
+
*/
|
|
95
|
+
protected updateComponentCommonProperties(configProps) {
|
|
96
|
+
// Extract properties from config
|
|
97
|
+
const { testId, label, hideLabel, displayMode = '', helperText, placeholder, required, visibility = true, disabled, readOnly } = configProps;
|
|
98
|
+
|
|
99
|
+
// Update component properties
|
|
100
|
+
this.testId = testId;
|
|
101
|
+
this.label$ = label;
|
|
102
|
+
this.hideLabel = hideLabel;
|
|
103
|
+
this.displayMode$ = displayMode;
|
|
104
|
+
this.helperText = helperText;
|
|
105
|
+
this.placeholder = placeholder || '';
|
|
106
|
+
|
|
107
|
+
// Convert boolean properties
|
|
108
|
+
this.bVisible$ = this.utils.getBooleanValue(visibility);
|
|
109
|
+
this.bRequired$ = this.utils.getBooleanValue(required);
|
|
110
|
+
this.bDisabled$ = this.utils.getBooleanValue(disabled);
|
|
111
|
+
this.bReadonly$ = this.utils.getBooleanValue(readOnly);
|
|
112
|
+
|
|
113
|
+
// Enable or disable field control
|
|
114
|
+
this.fieldControl[this.bDisabled$ ? 'disable' : 'enable']();
|
|
115
|
+
|
|
116
|
+
// Display error message if validation message exists
|
|
117
|
+
this.displayValidationMessage();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Displays the validation message if it exists.
|
|
122
|
+
*/
|
|
123
|
+
private displayValidationMessage(): void {
|
|
124
|
+
if (this.angularPConnectData.validateMessage) {
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
this.fieldControl.setErrors({ message: true });
|
|
127
|
+
this.fieldControl.markAsTouched();
|
|
128
|
+
}, 100);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Retrieves the error message for the current field control.
|
|
134
|
+
*
|
|
135
|
+
* @returns The error message, or an empty string if no error is found.
|
|
136
|
+
*/
|
|
137
|
+
getErrorMessage() {
|
|
138
|
+
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
139
|
+
if (this.fieldControl.hasError('message')) {
|
|
140
|
+
return this.angularPConnectData.validateMessage ?? '';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (this.fieldControl.hasError('required')) {
|
|
144
|
+
return 'You must enter a value';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return this.fieldControl.errors?.toString() ?? '';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -24,6 +24,10 @@ export class GroupComponent implements OnInit {
|
|
|
24
24
|
@Input() pConn$: typeof PConnect;
|
|
25
25
|
@Input() formGroup$: FormGroup;
|
|
26
26
|
|
|
27
|
+
// Used with AngularPConnect
|
|
28
|
+
angularPConnectData: AngularPConnectData = {};
|
|
29
|
+
configProps$: GroupProps;
|
|
30
|
+
|
|
27
31
|
arChildren$: any[];
|
|
28
32
|
visibility$?: boolean;
|
|
29
33
|
showHeading$?: boolean;
|
|
@@ -31,10 +35,6 @@ export class GroupComponent implements OnInit {
|
|
|
31
35
|
instructions$: string;
|
|
32
36
|
collapsible$: boolean;
|
|
33
37
|
|
|
34
|
-
// Used with AngularPConnect
|
|
35
|
-
angularPConnectData: AngularPConnectData = {};
|
|
36
|
-
configProps$: GroupProps;
|
|
37
|
-
|
|
38
38
|
constructor(private angularPConnect: AngularPConnectService) {}
|
|
39
39
|
|
|
40
40
|
ngOnInit(): void {
|
|
@@ -59,6 +59,9 @@ export class GroupComponent implements OnInit {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Updates the component when there are changes in the state.
|
|
64
|
+
*/
|
|
62
65
|
updateSelf(): void {
|
|
63
66
|
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as GroupProps;
|
|
64
67
|
this.arChildren$ = ReferenceComponent.normalizePConnArray(this.pConn$.getChildren());
|
|
@@ -1,14 +1,13 @@
|
|
|
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
|
-
|
|
7
|
-
import {
|
|
8
|
-
import { Utils } from '@pega/angular-sdk-components';
|
|
6
|
+
|
|
7
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
9
8
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
10
|
-
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
11
9
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
10
|
+
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
12
11
|
|
|
13
12
|
interface IntegerProps extends PConnFieldProps {
|
|
14
13
|
// If any, enter additional props that only exist on Integer here
|
|
@@ -20,143 +19,24 @@ interface IntegerProps extends PConnFieldProps {
|
|
|
20
19
|
styleUrls: ['./integer.component.scss'],
|
|
21
20
|
imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, forwardRef(() => ComponentMapperComponent)]
|
|
22
21
|
})
|
|
23
|
-
export class IntegerComponent
|
|
24
|
-
@Input() pConn$: typeof PConnect;
|
|
25
|
-
@Input() formGroup$: FormGroup;
|
|
26
|
-
|
|
27
|
-
// Used with AngularPConnect
|
|
28
|
-
angularPConnectData: AngularPConnectData = {};
|
|
22
|
+
export class IntegerComponent extends FieldBase {
|
|
29
23
|
configProps$: IntegerProps;
|
|
24
|
+
override fieldControl = new FormControl<number | null>(null, null);
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
bVisible$ = true;
|
|
37
|
-
displayMode$?: string = '';
|
|
38
|
-
controlName$: string;
|
|
39
|
-
bHasForm$ = true;
|
|
40
|
-
componentReference = '';
|
|
41
|
-
testId: string;
|
|
42
|
-
helperText: string;
|
|
43
|
-
placeholder: string;
|
|
44
|
-
|
|
45
|
-
fieldControl = new FormControl<number | null>(null, null);
|
|
46
|
-
actionsApi: Object;
|
|
47
|
-
propName: string;
|
|
48
|
-
|
|
49
|
-
constructor(
|
|
50
|
-
private angularPConnect: AngularPConnectService,
|
|
51
|
-
private cdRef: ChangeDetectorRef,
|
|
52
|
-
private utils: Utils
|
|
53
|
-
) {}
|
|
54
|
-
|
|
55
|
-
ngOnInit(): void {
|
|
56
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
57
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
58
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
59
|
-
|
|
60
|
-
// Then, continue on with other initialization
|
|
61
|
-
|
|
62
|
-
// call updateSelf when initializing
|
|
63
|
-
// this.updateSelf();
|
|
64
|
-
this.checkAndUpdate();
|
|
65
|
-
|
|
66
|
-
if (this.formGroup$) {
|
|
67
|
-
// add control to formGroup
|
|
68
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
69
|
-
this.fieldControl.setValue(this.value$);
|
|
70
|
-
this.bHasForm$ = true;
|
|
71
|
-
} else {
|
|
72
|
-
this.bReadonly$ = true;
|
|
73
|
-
this.bHasForm$ = false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
ngOnDestroy(): void {
|
|
78
|
-
if (this.formGroup$) {
|
|
79
|
-
this.formGroup$.removeControl(this.controlName$);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (this.angularPConnectData.unsubscribeFn) {
|
|
83
|
-
this.angularPConnectData.unsubscribeFn();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Callback passed when subscribing to store change
|
|
88
|
-
onStateChange() {
|
|
89
|
-
this.checkAndUpdate();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
checkAndUpdate() {
|
|
93
|
-
// Should always check the bridge to see if the component should
|
|
94
|
-
// update itself (re-render)
|
|
95
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
96
|
-
|
|
97
|
-
// ONLY call updateSelf when the component should update
|
|
98
|
-
if (bUpdateSelf) {
|
|
99
|
-
this.updateSelf();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// updateSelf
|
|
104
|
-
updateSelf(): void {
|
|
105
|
-
// moved this from ngOnInit() and call this from there instead...
|
|
26
|
+
/**
|
|
27
|
+
* Updates the component when there are changes in the state.
|
|
28
|
+
*/
|
|
29
|
+
override updateSelf(): void {
|
|
30
|
+
// Resolve configuration properties
|
|
106
31
|
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as IntegerProps;
|
|
107
|
-
this.testId = this.configProps$.testId;
|
|
108
|
-
this.label$ = this.configProps$.label;
|
|
109
|
-
this.displayMode$ = this.configProps$.displayMode;
|
|
110
|
-
let nValue: any = this.configProps$.value;
|
|
111
|
-
if (nValue) {
|
|
112
|
-
if (typeof nValue === 'string') {
|
|
113
|
-
nValue = parseInt(nValue, 10);
|
|
114
|
-
}
|
|
115
|
-
this.value$ = nValue;
|
|
116
|
-
}
|
|
117
|
-
this.helperText = this.configProps$.helperText;
|
|
118
|
-
this.placeholder = this.configProps$.placeholder || '';
|
|
119
|
-
|
|
120
|
-
this.actionsApi = this.pConn$.getActionsApi();
|
|
121
|
-
this.propName = this.pConn$.getStateProps().value;
|
|
122
|
-
|
|
123
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
124
|
-
setTimeout(() => {
|
|
125
|
-
if (this.configProps$.required != null) {
|
|
126
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
127
|
-
}
|
|
128
|
-
this.cdRef.detectChanges();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
if (this.configProps$.visibility != null) {
|
|
132
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// disabled
|
|
136
|
-
if (this.configProps$.disabled != undefined) {
|
|
137
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (this.bDisabled$) {
|
|
141
|
-
this.fieldControl.disable();
|
|
142
|
-
} else {
|
|
143
|
-
this.fieldControl.enable();
|
|
144
|
-
}
|
|
145
32
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
151
|
-
|
|
152
|
-
// trigger display of error message with field control
|
|
153
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
154
|
-
const timer = interval(100).subscribe(() => {
|
|
155
|
-
this.fieldControl.setErrors({ message: true });
|
|
156
|
-
this.fieldControl.markAsTouched();
|
|
33
|
+
// Update component common properties
|
|
34
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
157
35
|
|
|
158
|
-
|
|
159
|
-
|
|
36
|
+
// Extract and normalize the value property
|
|
37
|
+
const { value } = this.configProps$;
|
|
38
|
+
if (value) {
|
|
39
|
+
this.value$ = typeof value === 'string' ? parseInt(value, 10) : value;
|
|
160
40
|
}
|
|
161
41
|
}
|
|
162
42
|
|
|
@@ -180,23 +60,4 @@ export class IntegerComponent implements OnInit, OnDestroy {
|
|
|
180
60
|
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
|
|
181
61
|
}
|
|
182
62
|
}
|
|
183
|
-
|
|
184
|
-
getErrorMessage() {
|
|
185
|
-
// field control gets error message from here
|
|
186
|
-
|
|
187
|
-
let errMessage = '';
|
|
188
|
-
|
|
189
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
190
|
-
if (this.fieldControl.hasError('message')) {
|
|
191
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
192
|
-
return errMessage;
|
|
193
|
-
}
|
|
194
|
-
if (this.fieldControl.hasError('required')) {
|
|
195
|
-
errMessage = 'You must enter a value';
|
|
196
|
-
} else if (this.fieldControl.errors) {
|
|
197
|
-
errMessage = this.fieldControl.errors.toString();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return errMessage;
|
|
201
|
-
}
|
|
202
63
|
}
|