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