@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.
Files changed (160) hide show
  1. package/lib/designSystemExtension/alert/alert.component.scss +3 -3
  2. package/lib/designSystemExtension/banner/banner.component.scss +12 -2
  3. package/lib/designSystemExtension/material-case-summary/material-case-summary.component.html +6 -3
  4. package/lib/designSystemExtension/material-case-summary/material-case-summary.component.scss +5 -34
  5. package/lib/designSystemExtension/material-details/material-details.component.scss +0 -5
  6. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.html +2 -2
  7. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.scss +4 -3
  8. package/lib/designSystemExtension/material-summary-item/material-summary-item.component.scss +2 -17
  9. package/lib/designSystemExtension/material-utility/material-utility.component.scss +1 -2
  10. package/lib/designSystemExtension/material-vertical-tabs/material-vertical-tabs.component.scss +1 -1
  11. package/lib/designSystemExtension/operator/operator.component.html +1 -1
  12. package/lib/designSystemExtension/operator/operator.component.scss +3 -10
  13. package/lib/designSystemExtension/operator/operator.component.ts +0 -1
  14. package/lib/designSystemExtension/pulse/pulse.component.scss +2 -2
  15. package/lib/designSystemExtension/rich-text-editor/rich-text-editor.component.scss +0 -1
  16. package/lib/designSystemExtension/wss-quick-create/wss-quick-create.component.scss +16 -8
  17. package/lib/field/auto-complete/auto-complete.component.html +0 -1
  18. package/lib/field/auto-complete/auto-complete.component.ts +35 -172
  19. package/lib/field/cancel-alert/cancel-alert.component.html +8 -12
  20. package/lib/field/cancel-alert/cancel-alert.component.scss +2 -3
  21. package/lib/field/cancel-alert/cancel-alert.component.ts +24 -36
  22. package/lib/field/check-box/check-box.component.html +0 -1
  23. package/lib/field/check-box/check-box.component.scss +0 -1
  24. package/lib/field/check-box/check-box.component.ts +19 -149
  25. package/lib/field/currency/currency.component.ts +36 -168
  26. package/lib/field/date/date.component.html +1 -1
  27. package/lib/field/date/date.component.ts +30 -150
  28. package/lib/field/date-time/date-time.component.ts +31 -149
  29. package/lib/field/decimal/decimal.component.ts +38 -163
  30. package/lib/field/dropdown/dropdown.component.ts +29 -151
  31. package/lib/field/email/email.component.ts +16 -155
  32. package/lib/field/field.base.ts +149 -0
  33. package/lib/field/group/group.component.ts +7 -4
  34. package/lib/field/integer/integer.component.ts +18 -157
  35. package/lib/field/location/location.component.ts +1 -1
  36. package/lib/field/multiselect/multiselect.component.ts +46 -148
  37. package/lib/field/multiselect/utils.ts +55 -47
  38. package/lib/field/object-reference/object-reference.component.html +17 -0
  39. package/lib/field/object-reference/object-reference.component.scss +0 -0
  40. package/lib/field/object-reference/object-reference.component.spec.ts +22 -0
  41. package/lib/field/object-reference/object-reference.component.ts +237 -0
  42. package/lib/field/percentage/percentage.component.ts +37 -154
  43. package/lib/field/phone/phone.component.ts +28 -142
  44. package/lib/field/radio-buttons/radio-buttons.component.scss +4 -2
  45. package/lib/field/radio-buttons/radio-buttons.component.ts +35 -161
  46. package/lib/field/rich-text/rich-text.component.ts +19 -90
  47. package/lib/field/scalar-list/scalar-list.component.ts +17 -72
  48. package/lib/field/selectable-card/selectable-card.component.html +54 -24
  49. package/lib/field/selectable-card/selectable-card.component.scss +11 -0
  50. package/lib/field/selectable-card/selectable-card.component.ts +16 -52
  51. package/lib/field/semantic-link/semantic-link.component.html +4 -8
  52. package/lib/field/semantic-link/semantic-link.component.scss +0 -13
  53. package/lib/field/semantic-link/semantic-link.component.ts +165 -5
  54. package/lib/field/text/text.component.scss +0 -1
  55. package/lib/field/text-area/text-area.component.ts +18 -152
  56. package/lib/field/text-input/text-input.component.ts +16 -155
  57. package/lib/field/time/time.component.ts +17 -151
  58. package/lib/field/url/url.component.ts +16 -154
  59. package/lib/field/user-reference/user-reference.component.scss +0 -1
  60. package/lib/field/user-reference/user-reference.component.ts +2 -3
  61. package/lib/infra/Containers/flow-container/flow-container.component.ts +5 -7
  62. package/lib/infra/Containers/modal-view-container/modal-view-container.component.ts +5 -10
  63. package/lib/infra/Containers/view-container/helper.ts +35 -2
  64. package/lib/infra/Containers/view-container/view-container.component.ts +1 -1
  65. package/lib/infra/action-buttons/action-buttons.component.html +13 -8
  66. package/lib/infra/action-buttons/action-buttons.component.scss +23 -0
  67. package/lib/infra/action-buttons/action-buttons.component.ts +1 -2
  68. package/lib/infra/assignment/assignment.component.ts +8 -6
  69. package/lib/infra/assignment-card/assignment-card.component.html +1 -2
  70. package/lib/infra/assignment-card/assignment-card.component.scss +0 -4
  71. package/lib/infra/assignment-card/assignment-card.component.ts +21 -4
  72. package/lib/infra/defer-load/defer-load.component.html +6 -2
  73. package/lib/infra/defer-load/defer-load.component.ts +16 -10
  74. package/lib/infra/multi-step/multi-step.component.scss +1 -21
  75. package/lib/infra/navbar/navbar.component.html +25 -28
  76. package/lib/infra/navbar/navbar.component.scss +16 -4
  77. package/lib/infra/navbar/navbar.component.ts +8 -3
  78. package/lib/infra/root-container/root-container.component.scss +0 -1
  79. package/lib/infra/root-container/root-container.component.ts +1 -2
  80. package/lib/infra/stages/stages.component.html +2 -2
  81. package/lib/infra/stages/stages.component.scss +7 -35
  82. package/lib/infra/stages/stages.component.ts +4 -2
  83. package/lib/infra/view/view.component.html +1 -1
  84. package/lib/infra/view/view.component.ts +0 -2
  85. package/lib/template/advanced-search/advanced-search.component.html +12 -0
  86. package/lib/template/advanced-search/advanced-search.component.scss +0 -0
  87. package/lib/template/advanced-search/advanced-search.component.spec.ts +0 -0
  88. package/lib/template/advanced-search/advanced-search.component.ts +112 -0
  89. package/lib/template/advanced-search/advanced-search.service.ts +27 -0
  90. package/lib/template/advanced-search/search-group/persist-utils.ts +56 -0
  91. package/lib/template/advanced-search/search-groups/search-groups.component.html +32 -0
  92. package/lib/template/advanced-search/search-groups/search-groups.component.scss +0 -0
  93. package/lib/template/advanced-search/search-groups/search-groups.component.spec.ts +0 -0
  94. package/lib/template/advanced-search/search-groups/search-groups.component.ts +294 -0
  95. package/lib/template/advanced-search/search-groups/utils.ts +29 -0
  96. package/lib/template/app-shell/app-shell.component.html +4 -1
  97. package/lib/template/app-shell/app-shell.component.scss +0 -3
  98. package/lib/template/app-shell/app-shell.component.ts +46 -7
  99. package/lib/template/case-summary/case-summary.component.scss +0 -2
  100. package/lib/template/case-view/case-view.component.html +3 -3
  101. package/lib/template/case-view/case-view.component.scss +18 -10
  102. package/lib/template/case-view/case-view.component.ts +1 -1
  103. package/lib/template/data-reference/data-reference-advanced-search.service.ts +16 -0
  104. package/lib/template/data-reference/data-reference.component.html +11 -8
  105. package/lib/template/data-reference/data-reference.component.ts +346 -112
  106. package/lib/template/data-reference/search-form/search-form.component.html +39 -0
  107. package/lib/template/data-reference/search-form/search-form.component.scss +11 -0
  108. package/lib/template/data-reference/search-form/search-form.component.spec.ts +0 -0
  109. package/lib/template/data-reference/search-form/search-form.component.ts +167 -0
  110. package/lib/template/data-reference/search-form/tabsData.ts +160 -0
  111. package/lib/template/data-reference/utils.ts +92 -0
  112. package/lib/template/default-form/default-form.component.ts +10 -2
  113. package/lib/template/default-page/default-page.component.html +34 -0
  114. package/lib/template/default-page/default-page.component.scss +31 -0
  115. package/lib/template/default-page/default-page.component.spec.ts +24 -0
  116. package/lib/template/default-page/default-page.component.ts +64 -0
  117. package/lib/template/field-group-list/field-group-list.component.scss +0 -1
  118. package/lib/template/inline-dashboard-page/inline-dashboard-page.component.ts +1 -1
  119. package/lib/template/list-view/list-view.component.html +9 -4
  120. package/lib/template/list-view/list-view.component.scss +21 -21
  121. package/lib/template/list-view/list-view.component.ts +154 -84
  122. package/lib/template/list-view/utils.ts +25 -2
  123. package/lib/template/object-page/object-page.component.html +1 -0
  124. package/lib/template/object-page/object-page.component.scss +0 -0
  125. package/lib/template/object-page/object-page.component.spec.ts +22 -0
  126. package/lib/template/object-page/object-page.component.ts +14 -0
  127. package/lib/template/one-column-tab/one-column-tab.component.scss +1 -1
  128. package/lib/template/repeating-structures/repeating-structures.component.ts +0 -1
  129. package/lib/template/self-service-case-view/self-service-case-view.component.html +80 -0
  130. package/lib/template/self-service-case-view/self-service-case-view.component.scss +124 -0
  131. package/lib/template/self-service-case-view/self-service-case-view.component.spec.ts +24 -0
  132. package/lib/template/self-service-case-view/self-service-case-view.component.ts +216 -0
  133. package/lib/template/simple-table/simple-table.component.ts +0 -1
  134. package/lib/template/simple-table-manual/helpers.ts +2 -2
  135. package/lib/template/simple-table-manual/simple-table-manual.component.html +4 -4
  136. package/lib/template/simple-table-manual/simple-table-manual.component.scss +4 -14
  137. package/lib/template/simple-table-manual/simple-table-manual.component.ts +8 -4
  138. package/lib/template/single-reference-readonly/single-reference-readonly.component.html +4 -1
  139. package/lib/template/single-reference-readonly/single-reference-readonly.component.scss +21 -0
  140. package/lib/template/single-reference-readonly/single-reference-readonly.component.ts +104 -3
  141. package/lib/template/utils.ts +42 -0
  142. package/lib/template/wss-nav-bar/wss-nav-bar.component.html +5 -4
  143. package/lib/template/wss-nav-bar/wss-nav-bar.component.scss +2 -8
  144. package/lib/template/wss-nav-bar/wss-nav-bar.component.ts +1 -8
  145. package/lib/widget/app-announcement/app-announcement.component.html +1 -2
  146. package/lib/widget/app-announcement/app-announcement.component.scss +2 -2
  147. package/lib/widget/attachment/Attachment.types.ts +92 -0
  148. package/lib/widget/attachment/AttachmentUtils.ts +287 -0
  149. package/lib/widget/attachment/attachment.component.html +3 -3
  150. package/lib/widget/attachment/attachment.component.scss +2 -5
  151. package/lib/widget/attachment/attachment.component.ts +255 -254
  152. package/lib/widget/feed-container/feed-container.component.scss +3 -9
  153. package/lib/widget/feed-container/feed-container.component.ts +2 -2
  154. package/lib/widget/file-utility/file-utility.component.html +3 -3
  155. package/lib/widget/file-utility/file-utility.component.scss +5 -16
  156. package/lib/widget/list-utility/list-utility.component.scss +3 -5
  157. package/lib/widget/todo/todo.component.html +8 -5
  158. package/lib/widget/todo/todo.component.scss +10 -11
  159. package/lib/widget/todo/todo.component.ts +6 -2
  160. package/package.json +1 -1
@@ -1,20 +1,19 @@
1
- import { Component, OnInit, Input, ChangeDetectorRef, forwardRef, Inject, OnDestroy } from '@angular/core';
1
+ import { Component, OnInit, forwardRef, OnDestroy } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
- import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
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
- import { interval } from 'rxjs';
11
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
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 { dateFormatInfoDefault, getDateFormatInfo } from '@pega/angular-sdk-components';
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
- constructor(
91
- private angularPConnect: AngularPConnectService,
92
- private cdRef: ChangeDetectorRef,
93
- private utils: Utils,
94
- @Inject(MAT_DATE_FORMATS) private config: MyFormat
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
- this.value$ = this.configProps$.value;
152
- this.testId = this.configProps$.testId;
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
- if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
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
- errMessage = this.angularPConnectData.validateMessage ?? '';
225
- return errMessage;
101
+ return this.angularPConnectData.validateMessage ?? '';
226
102
  }
103
+
227
104
  if (this.fieldControl.hasError('required')) {
228
- errMessage = 'You must enter a value';
229
- } else if (this.fieldControl.errors) {
230
- errMessage = `${this.fieldControl.errors['matDatepickerParse'].text} is not a valid date value`;
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
- return errMessage;
111
+
112
+ return '';
233
113
  }
234
114
  }
@@ -1,20 +1,18 @@
1
- import { Component, OnInit, Input, ChangeDetectorRef, forwardRef, OnDestroy } from '@angular/core';
1
+ import { Component, OnInit, forwardRef, OnDestroy } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
- import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
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
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
11
- import { Utils } from '@pega/angular-sdk-components';
9
+
10
+ import { FieldBase } from '@pega/angular-sdk-components';
12
11
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
13
- import { dateFormatInfoDefault, getDateFormatInfo } from '@pega/angular-sdk-components';
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
- constructor(
75
- private angularPConnect: AngularPConnectService,
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
- ngOnDestroy(): void {
107
- if (this.formGroup$) {
108
- this.formGroup$.removeControl(this.controlName$);
109
- }
110
- if (this.angularPConnectData.unsubscribeFn) {
111
- this.angularPConnectData.unsubscribeFn();
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
- // ONLY call updateSelf when the component should update
126
- if (bUpdateSelf) {
127
- this.updateSelf();
128
- }
129
- }
68
+ // Update component common properties
69
+ this.updateComponentCommonProperties(this.configProps$);
130
70
 
131
- // updateSelf
132
- updateSelf(): void {
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
- this.label$ = this.configProps$.label;
138
- this.displayMode$ = this.configProps$.displayMode;
139
- this.testId = this.configProps$.testId;
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.configProps$.readOnly != null) {
177
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
82
+ if (['DISPLAY_ONLY', 'STACKED_LARGE_VAL'].includes(this.displayMode$)) {
83
+ this.formattedValue$ = this.generateDateTime(this.value$);
178
84
  }
85
+ }
179
86
 
180
- this.componentReference = this.pConn$.getStateProps().value;
181
-
182
- this.actionsApi = this.pConn$.getActionsApi();
183
- this.propName = this.pConn$.getStateProps().value;
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
  }