@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,20 +1,19 @@
|
|
|
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 { MatDatepickerModule } from '@angular/material/datepicker';
|
|
5
5
|
import { MatNativeDateModule } from '@angular/material/core';
|
|
6
6
|
import { MatInputModule } from '@angular/material/input';
|
|
7
7
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
8
8
|
import { MAT_DATE_FORMATS } from '@angular/material/core';
|
|
9
9
|
import { MomentDateModule } from '@angular/material-moment-adapter';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import { Utils } from '@pega/angular-sdk-components';
|
|
10
|
+
|
|
11
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
13
12
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
14
|
-
import {
|
|
15
|
-
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
13
|
+
import { getDateFormatInfo } from '@pega/angular-sdk-components';
|
|
16
14
|
import { format } from '@pega/angular-sdk-components';
|
|
17
15
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
16
|
+
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
18
17
|
|
|
19
18
|
interface DateProps extends PConnFieldProps {
|
|
20
19
|
// If any, enter additional props that only exist on Date here
|
|
@@ -55,153 +54,32 @@ class MyFormat {
|
|
|
55
54
|
],
|
|
56
55
|
providers: [{ provide: MAT_DATE_FORMATS, useClass: MyFormat }]
|
|
57
56
|
})
|
|
58
|
-
export class DateComponent implements OnInit, OnDestroy {
|
|
59
|
-
@Input() pConn$: typeof PConnect;
|
|
60
|
-
@Input() formGroup$: FormGroup;
|
|
61
|
-
|
|
62
|
-
// Used with AngularPConnect
|
|
63
|
-
angularPConnectData: AngularPConnectData = {};
|
|
57
|
+
export class DateComponent extends FieldBase implements OnInit, OnDestroy {
|
|
64
58
|
configProps$: DateProps;
|
|
65
59
|
|
|
66
|
-
label$ = '';
|
|
67
|
-
value$: any;
|
|
68
|
-
bRequired$ = false;
|
|
69
|
-
bReadonly$ = false;
|
|
70
|
-
bDisabled$ = false;
|
|
71
|
-
bVisible$ = true;
|
|
72
|
-
displayMode$?: string = '';
|
|
73
|
-
controlName$: string;
|
|
74
|
-
bHasForm$ = true;
|
|
75
|
-
componentReference = '';
|
|
76
|
-
testId = '';
|
|
77
|
-
helperText: string;
|
|
78
|
-
placeholder: string;
|
|
79
|
-
|
|
80
|
-
fieldControl = new FormControl('', null);
|
|
81
|
-
|
|
82
|
-
// Start with default dateFormatInfo
|
|
83
|
-
dateFormatInfo = dateFormatInfoDefault;
|
|
84
|
-
// and then update, as needed, based on locale, etc.
|
|
85
60
|
theDateFormat = getDateFormatInfo();
|
|
86
|
-
actionsApi: Object;
|
|
87
|
-
propName: string;
|
|
88
61
|
formattedValue$: any;
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
) {}
|
|
96
|
-
|
|
97
|
-
ngOnInit(): void {
|
|
98
|
-
this.dateFormatInfo = this.theDateFormat;
|
|
99
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
100
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
101
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
102
|
-
|
|
103
|
-
// Then, continue on with other initialization
|
|
104
|
-
// call updateSelf when initializing
|
|
105
|
-
// this.updateSelf();
|
|
106
|
-
this.checkAndUpdate();
|
|
107
|
-
|
|
108
|
-
if (this.formGroup$) {
|
|
109
|
-
// add control to formGroup
|
|
110
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
111
|
-
this.fieldControl.setValue(this.value$);
|
|
112
|
-
this.bHasForm$ = true;
|
|
113
|
-
} else {
|
|
114
|
-
this.bReadonly$ = true;
|
|
115
|
-
this.bHasForm$ = false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
ngOnDestroy(): void {
|
|
120
|
-
if (this.formGroup$) {
|
|
121
|
-
this.formGroup$.removeControl(this.controlName$);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (this.angularPConnectData.unsubscribeFn) {
|
|
125
|
-
this.angularPConnectData.unsubscribeFn();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Callback passed when subscribing to store change
|
|
130
|
-
onStateChange() {
|
|
131
|
-
this.checkAndUpdate();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
checkAndUpdate() {
|
|
135
|
-
// Should always check the bridge to see if the component should
|
|
136
|
-
// update itself (re-render)
|
|
137
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
138
|
-
|
|
139
|
-
// ONLY call updateSelf when the component should update
|
|
140
|
-
if (bUpdateSelf) {
|
|
141
|
-
this.updateSelf();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// updateSelf
|
|
146
|
-
updateSelf(): void {
|
|
147
|
-
// starting very simple...
|
|
148
|
-
// moved this from ngOnInit() and call this from there instead...
|
|
63
|
+
/**
|
|
64
|
+
* Updates the component when there are changes in the state.
|
|
65
|
+
*/
|
|
66
|
+
override updateSelf(): void {
|
|
67
|
+
// Resolve config properties
|
|
149
68
|
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as DateProps;
|
|
150
69
|
|
|
151
|
-
|
|
152
|
-
this.
|
|
153
|
-
this.label$ = this.configProps$.label;
|
|
154
|
-
this.displayMode$ = this.configProps$.displayMode;
|
|
155
|
-
this.helperText = this.configProps$.helperText;
|
|
156
|
-
this.placeholder = this.configProps$.placeholder || '';
|
|
157
|
-
|
|
158
|
-
this.actionsApi = this.pConn$.getActionsApi();
|
|
159
|
-
this.propName = this.pConn$.getStateProps().value;
|
|
160
|
-
|
|
161
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
162
|
-
setTimeout(() => {
|
|
163
|
-
if (this.configProps$.required != null) {
|
|
164
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
165
|
-
}
|
|
166
|
-
this.cdRef.detectChanges();
|
|
167
|
-
});
|
|
70
|
+
// Update component common properties
|
|
71
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
168
72
|
|
|
169
|
-
|
|
73
|
+
// Extract and normalize the value property
|
|
74
|
+
const { value } = this.configProps$;
|
|
75
|
+
this.value$ = value;
|
|
76
|
+
|
|
77
|
+
// Format value for display modes
|
|
78
|
+
if (['DISPLAY_ONLY', 'STACKED_LARGE_VAL'].includes(this.displayMode$)) {
|
|
170
79
|
this.formattedValue$ = format(this.value$, 'date', {
|
|
171
80
|
format: this.theDateFormat.dateFormatString
|
|
172
81
|
});
|
|
173
82
|
}
|
|
174
|
-
|
|
175
|
-
if (this.configProps$.visibility != null) {
|
|
176
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// disabled
|
|
180
|
-
if (this.configProps$.disabled != undefined) {
|
|
181
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (this.bDisabled$) {
|
|
185
|
-
this.fieldControl.disable();
|
|
186
|
-
} else {
|
|
187
|
-
this.fieldControl.enable();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (this.configProps$.readOnly != null) {
|
|
191
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
195
|
-
|
|
196
|
-
// trigger display of error message with field control
|
|
197
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
198
|
-
const timer = interval(100).subscribe(() => {
|
|
199
|
-
this.fieldControl.setErrors({ message: true });
|
|
200
|
-
this.fieldControl.markAsTouched();
|
|
201
|
-
|
|
202
|
-
timer.unsubscribe();
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
83
|
}
|
|
206
84
|
|
|
207
85
|
fieldOnDateChange(event: any) {
|
|
@@ -217,18 +95,20 @@ export class DateComponent implements OnInit, OnDestroy {
|
|
|
217
95
|
return this.fieldControl.status === 'INVALID';
|
|
218
96
|
}
|
|
219
97
|
|
|
220
|
-
getErrorMessage() {
|
|
221
|
-
let errMessage = '';
|
|
98
|
+
override getErrorMessage() {
|
|
222
99
|
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
223
100
|
if (this.fieldControl.hasError('message')) {
|
|
224
|
-
|
|
225
|
-
return errMessage;
|
|
101
|
+
return this.angularPConnectData.validateMessage ?? '';
|
|
226
102
|
}
|
|
103
|
+
|
|
227
104
|
if (this.fieldControl.hasError('required')) {
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
105
|
+
return 'You must enter a value';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (this.fieldControl.errors) {
|
|
109
|
+
return `${this.fieldControl.errors['matDatepickerParse'].text} is not a valid date value`;
|
|
231
110
|
}
|
|
232
|
-
|
|
111
|
+
|
|
112
|
+
return '';
|
|
233
113
|
}
|
|
234
114
|
}
|
|
@@ -1,20 +1,18 @@
|
|
|
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 { MatDatepickerModule } from '@angular/material/datepicker';
|
|
5
5
|
import { MatInputModule } from '@angular/material/input';
|
|
6
6
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
7
7
|
import { OwlDateTimeModule, OwlNativeDateTimeModule } from '@danielmoncada/angular-datetime-picker';
|
|
8
|
-
import { interval } from 'rxjs';
|
|
9
8
|
import dayjs from 'dayjs';
|
|
10
|
-
|
|
11
|
-
import {
|
|
9
|
+
|
|
10
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
12
11
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
13
|
-
import {
|
|
14
|
-
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
12
|
+
import { getDateFormatInfo } from '@pega/angular-sdk-components';
|
|
15
13
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
16
|
-
import { format } from '@pega/angular-sdk-components';
|
|
17
14
|
import { DateFormatters } from '@pega/angular-sdk-components';
|
|
15
|
+
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
18
16
|
|
|
19
17
|
interface DateTimeProps extends PConnFieldProps {
|
|
20
18
|
// If any, enter additional props that only exist on DateTime here
|
|
@@ -35,162 +33,61 @@ interface DateTimeProps extends PConnFieldProps {
|
|
|
35
33
|
forwardRef(() => ComponentMapperComponent)
|
|
36
34
|
]
|
|
37
35
|
})
|
|
38
|
-
export class DateTimeComponent implements OnInit, OnDestroy {
|
|
39
|
-
@Input() pConn$: typeof PConnect;
|
|
40
|
-
@Input() formGroup$: FormGroup;
|
|
41
|
-
|
|
42
|
-
// Used with AngularPConnect
|
|
43
|
-
angularPConnectData: AngularPConnectData = {};
|
|
36
|
+
export class DateTimeComponent extends FieldBase implements OnInit, OnDestroy {
|
|
44
37
|
configProps$: DateTimeProps;
|
|
45
38
|
|
|
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 = '';
|
|
57
|
-
helperText: string;
|
|
58
|
-
|
|
59
|
-
fieldControl = new FormControl('', null);
|
|
60
39
|
stepHour = 1;
|
|
61
40
|
stepMinute = 1;
|
|
62
41
|
stepSecond = 1;
|
|
63
42
|
public color = 'primary';
|
|
64
|
-
// Start with default dateFormatInfo
|
|
65
|
-
dateFormatInfo = dateFormatInfoDefault;
|
|
66
|
-
// and then update, as needed, based on locale, etc.
|
|
67
|
-
theDateFormat = getDateFormatInfo();
|
|
68
|
-
placeholder: string;
|
|
69
|
-
actionsApi: Object;
|
|
70
|
-
propName: string;
|
|
71
43
|
formattedValue$: any;
|
|
44
|
+
theDateFormat = getDateFormatInfo();
|
|
72
45
|
timezone = PCore.getEnvironmentInfo()?.getTimeZone();
|
|
46
|
+
override placeholder = `${this.theDateFormat.dateFormatStringLC}, hh:mm A`;
|
|
73
47
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
private cdRef: ChangeDetectorRef,
|
|
77
|
-
private utils: Utils
|
|
78
|
-
) {}
|
|
79
|
-
|
|
80
|
-
ngOnInit(): void {
|
|
81
|
-
this.placeholder = `${this.theDateFormat.dateFormatStringLC}, hh:mm A`;
|
|
82
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
83
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
84
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
85
|
-
// Then, continue on with other initialization
|
|
86
|
-
// call updateSelf when initializing
|
|
87
|
-
// this.updateSelf();
|
|
88
|
-
this.checkAndUpdate();
|
|
48
|
+
override ngOnInit(): void {
|
|
49
|
+
super.ngOnInit();
|
|
89
50
|
|
|
90
51
|
if (this.formGroup$) {
|
|
91
|
-
// add control to formGroup
|
|
92
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
93
52
|
let dateTimeValue = this.value$ ?? '';
|
|
94
53
|
|
|
95
54
|
if (this.value$) {
|
|
96
55
|
dateTimeValue = dayjs(DateFormatters?.convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
|
|
97
56
|
}
|
|
98
57
|
this.fieldControl.setValue(dateTimeValue);
|
|
99
|
-
this.bHasForm$ = true;
|
|
100
|
-
} else {
|
|
101
|
-
this.bReadonly$ = true;
|
|
102
|
-
this.bHasForm$ = false;
|
|
103
58
|
}
|
|
104
59
|
}
|
|
105
60
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Callback passed when subscribing to store change
|
|
116
|
-
onStateChange() {
|
|
117
|
-
this.checkAndUpdate();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
checkAndUpdate() {
|
|
121
|
-
// Should always check the bridge to see if the component should
|
|
122
|
-
// update itself (re-render)
|
|
123
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
61
|
+
/**
|
|
62
|
+
* Updates the component when there are changes in the state.
|
|
63
|
+
*/
|
|
64
|
+
override updateSelf(): void {
|
|
65
|
+
// Resolve config properties
|
|
66
|
+
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as DateTimeProps;
|
|
124
67
|
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
this.updateSelf();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
68
|
+
// Update component common properties
|
|
69
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
130
70
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// starting very simple...
|
|
134
|
-
// moved this from ngOnInit() and call this from there instead...
|
|
135
|
-
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as DateTimeProps;
|
|
71
|
+
// Extract the value property
|
|
72
|
+
const { value } = this.configProps$;
|
|
136
73
|
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
140
|
-
this.helperText = this.configProps$.helperText;
|
|
141
|
-
this.value$ = this.configProps$?.value;
|
|
142
|
-
let dateTimeValue = this.configProps$?.value ?? '';
|
|
74
|
+
// Update component properties
|
|
75
|
+
this.value$ = value;
|
|
76
|
+
let dateTimeValue = value ?? '';
|
|
143
77
|
if (this.value$) {
|
|
144
78
|
dateTimeValue = dayjs(DateFormatters?.convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
|
|
145
79
|
}
|
|
146
80
|
this.fieldControl.setValue(dateTimeValue);
|
|
147
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
148
|
-
setTimeout(() => {
|
|
149
|
-
if (this.configProps$.required != null) {
|
|
150
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
151
|
-
}
|
|
152
|
-
this.cdRef.detectChanges();
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
|
|
156
|
-
this.formattedValue$ = format(this.value$, 'datetime', {
|
|
157
|
-
format: `${this.theDateFormat.dateFormatString} hh:mm A`
|
|
158
|
-
});
|
|
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
81
|
|
|
176
|
-
if (this.
|
|
177
|
-
this.
|
|
82
|
+
if (['DISPLAY_ONLY', 'STACKED_LARGE_VAL'].includes(this.displayMode$)) {
|
|
83
|
+
this.formattedValue$ = this.generateDateTime(this.value$);
|
|
178
84
|
}
|
|
85
|
+
}
|
|
179
86
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// trigger display of error message with field control
|
|
186
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
187
|
-
const timer = interval(100).subscribe(() => {
|
|
188
|
-
this.fieldControl.setErrors({ message: true });
|
|
189
|
-
this.fieldControl.markAsTouched();
|
|
190
|
-
|
|
191
|
-
timer.unsubscribe();
|
|
192
|
-
});
|
|
193
|
-
}
|
|
87
|
+
generateDateTime(sVal): string {
|
|
88
|
+
if (!sVal) return '';
|
|
89
|
+
if (sVal.length === 10) return this.utils.generateDate(sVal, 'Date-Long-Custom-YYYY');
|
|
90
|
+
return this.utils.generateDateTime(sVal, 'DateTime-Long-YYYY-Custom');
|
|
194
91
|
}
|
|
195
92
|
|
|
196
93
|
fieldOnDateChange(event: any) {
|
|
@@ -203,19 +100,4 @@ export class DateTimeComponent implements OnInit, OnDestroy {
|
|
|
203
100
|
}
|
|
204
101
|
handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value);
|
|
205
102
|
}
|
|
206
|
-
|
|
207
|
-
getErrorMessage() {
|
|
208
|
-
let errMessage = '';
|
|
209
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
210
|
-
if (this.fieldControl.hasError('message')) {
|
|
211
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
212
|
-
return errMessage;
|
|
213
|
-
}
|
|
214
|
-
if (this.fieldControl.hasError('required')) {
|
|
215
|
-
errMessage = 'You must enter a value';
|
|
216
|
-
} else if (this.fieldControl.errors) {
|
|
217
|
-
errMessage = this.fieldControl.errors.toString();
|
|
218
|
-
}
|
|
219
|
-
return errMessage;
|
|
220
|
-
}
|
|
221
103
|
}
|