@pega/dx-component-builder-sdk 25.1.11 → 25.1.12
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/package.json +1 -1
- package/src/tasks/create/templates/SDK-Angular/field/Boolean/boolean.component.ts.mustache +18 -149
- package/src/tasks/create/templates/SDK-Angular/field/Date/date.component.html.mustache +1 -1
- package/src/tasks/create/templates/SDK-Angular/field/Date/date.component.ts.mustache +29 -150
- package/src/tasks/create/templates/SDK-Angular/field/DateTime/date-time.component.ts.mustache +31 -149
- package/src/tasks/create/templates/SDK-Angular/field/Decimal/decimal.component.ts.mustache +37 -163
- package/src/tasks/create/templates/SDK-Angular/field/Decimal-Currency/decimal-currency.component.ts.mustache +34 -169
- package/src/tasks/create/templates/SDK-Angular/field/Decimal-Percentage/decimal-percentage.component.ts.mustache +36 -154
- package/src/tasks/create/templates/SDK-Angular/field/Integer/integer.component.ts.mustache +18 -157
- package/src/tasks/create/templates/SDK-Angular/field/Picklist/picklist.component.ts.mustache +24 -148
- package/src/tasks/create/templates/SDK-Angular/field/Picklist-Autocomplete/demo.stories.tsx.mustache +7 -2
- package/src/tasks/create/templates/SDK-Angular/field/Picklist-Autocomplete/picklist-autocomplete.component.ts.mustache +28 -162
- package/src/tasks/create/templates/SDK-Angular/field/Picklist-RadioButtons/picklist-radio-buttons.component.ts.mustache +35 -161
- package/src/tasks/create/templates/SDK-Angular/field/Text/text.component.ts.mustache +29 -144
- package/src/tasks/create/templates/SDK-Angular/field/Text-Email/text-email.component.ts.mustache +15 -155
- package/src/tasks/create/templates/SDK-Angular/field/Text-Input/text.component.ts.mustache +15 -155
- package/src/tasks/create/templates/SDK-Angular/field/Text-Paragraph/text-paragraph.component.ts.mustache +18 -152
- package/src/tasks/create/templates/SDK-Angular/field/Text-Phone/text-phone.component.ts.mustache +29 -142
- package/src/tasks/create/templates/SDK-Angular/field/Text-URL/text-url.component.ts.mustache +16 -154
- package/src/tasks/create/templates/SDK-Angular/field/TimeOfDay/time-of-day.component.ts.mustache +17 -151
- package/src/tasks/create/templates/SDK-Angular/template/DETAILS/details.component.ts.mustache +0 -1
- package/src/tasks/create/templates/SDK-Angular/template/DETAILS-region/details.component.ts.mustache +0 -1
- package/src/tasks/create/templates/SDK-Angular/template/FORM/form.component.ts.mustache +10 -3
- package/src/tasks/create/templates/SDK-Angular/template/FORM-region/form.component.ts.mustache +0 -1
- package/src/tasks/create/templates/SDK-Angular/template/PAGE/page.component.ts.mustache +0 -1
- package/src/tasks/create/templates/SDK-Angular/widget/CASE/case.component.ts.mustache +0 -1
- package/src/tasks/create/templates/SDK-Angular/widget/PAGE/page.component.ts.mustache +0 -1
- package/src/tasks/create/templates/SDK-Angular/widget/PAGE-CASE/page-case.component.html.mustache +2 -2
- package/src/tasks/create/templates/SDK-Angular/widget/PAGE-CASE/page-case.component.ts.mustache +4 -4
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/PConnProps.d.ts +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/create-nonce.ts +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/demo.stories.tsx +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/event-utils.ts +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/index.tsx +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/mock.ts +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/styles.ts +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/suggestions-handler.ts +0 -0
- /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/textformat-utils.tsx +0 -0
package/src/tasks/create/templates/SDK-Angular/field/Picklist/picklist.component.ts.mustache
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { Component, OnInit,
|
|
1
|
+
import { Component, OnInit, forwardRef, OnDestroy, Output, EventEmitter } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
4
|
import { MatOptionModule } from '@angular/material/core';
|
|
5
5
|
import { MatSelectModule } from '@angular/material/select';
|
|
6
6
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
7
|
-
import { interval } from 'rxjs';
|
|
8
7
|
import isEqual from 'fast-deep-equal';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import { Utils } from '@pega/angular-sdk-components';
|
|
8
|
+
|
|
9
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
12
10
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
13
11
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
14
12
|
import { PConnFieldProps } from '@pega/angular-sdk-components';
|
|
@@ -70,68 +68,18 @@ interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
|
|
|
70
68
|
styleUrls: ['./{{COMPONENT_CLASS_NAME_KEBAB}}.component.scss'],
|
|
71
69
|
imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatSelectModule, MatOptionModule, forwardRef(() => ComponentMapperComponent)]
|
|
72
70
|
})
|
|
73
|
-
export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
74
|
-
@Input() pConn$: typeof PConnect;
|
|
75
|
-
@Input() formGroup$: FormGroup;
|
|
71
|
+
export class {{COMPONENT_CLASS_NAME}}Component extends FieldBase implements OnInit, OnDestroy {
|
|
76
72
|
@Output() onRecordChange: EventEmitter<any> = new EventEmitter();
|
|
77
73
|
|
|
78
|
-
// Used with AngularPConnect
|
|
79
|
-
angularPConnectData: AngularPConnectData = {};
|
|
80
74
|
configProps$: {{COMPONENT_CLASS_NAME}}Props;
|
|
81
75
|
|
|
82
|
-
label$ = '';
|
|
83
|
-
value$ = '';
|
|
84
|
-
bRequired$ = false;
|
|
85
|
-
bReadonly$ = false;
|
|
86
|
-
bDisabled$ = false;
|
|
87
|
-
bVisible$ = true;
|
|
88
|
-
displayMode$?: string = '';
|
|
89
|
-
controlName$: string;
|
|
90
|
-
bHasForm$ = true;
|
|
91
76
|
options$: IOption[];
|
|
92
|
-
componentReference = '';
|
|
93
|
-
testId = '';
|
|
94
|
-
helperText: string;
|
|
95
|
-
hideLabel: any;
|
|
96
77
|
theDatasource: any[] | null;
|
|
97
|
-
fieldControl = new FormControl('', null);
|
|
98
|
-
fieldMetadata: any[];
|
|
99
78
|
localeContext = '';
|
|
100
79
|
localeClass = '';
|
|
101
80
|
localeName = '';
|
|
102
81
|
localePath = '';
|
|
103
82
|
localizedValue = '';
|
|
104
|
-
actionsApi: object;
|
|
105
|
-
propName: string;
|
|
106
|
-
|
|
107
|
-
constructor(
|
|
108
|
-
private angularPConnect: AngularPConnectService,
|
|
109
|
-
private cdRef: ChangeDetectorRef,
|
|
110
|
-
private utils: Utils,
|
|
111
|
-
private dataPageService: DatapageService
|
|
112
|
-
) {}
|
|
113
|
-
|
|
114
|
-
ngOnInit(): void {
|
|
115
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
116
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
117
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
118
|
-
|
|
119
|
-
// Then, continue on with other initialization
|
|
120
|
-
|
|
121
|
-
// call updateSelf when initializing
|
|
122
|
-
this.checkAndUpdate();
|
|
123
|
-
// this should get called afer checkAndUpdate
|
|
124
|
-
|
|
125
|
-
if (this.formGroup$) {
|
|
126
|
-
// add control to formGroup
|
|
127
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
128
|
-
this.fieldControl.setValue(this.value$);
|
|
129
|
-
this.bHasForm$ = true;
|
|
130
|
-
} else {
|
|
131
|
-
this.bReadonly$ = true;
|
|
132
|
-
this.bHasForm$ = false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
83
|
|
|
136
84
|
set options(options: IOption[]) {
|
|
137
85
|
this.options$ = options;
|
|
@@ -145,80 +93,34 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
145
93
|
}
|
|
146
94
|
}
|
|
147
95
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.angularPConnectData.unsubscribeFn();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Callback passed when subscribing to store change
|
|
159
|
-
onStateChange() {
|
|
160
|
-
this.checkAndUpdate();
|
|
161
|
-
}
|
|
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 {{COMPONENT_CLASS_NAME}}Props;
|
|
162
102
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// update itself (re-render)
|
|
166
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
103
|
+
// Update component common properties
|
|
104
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
167
105
|
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
this.updateSelf();
|
|
171
|
-
}
|
|
106
|
+
// Set component specific properties
|
|
107
|
+
this.updateDropdownProperties(this.configProps$);
|
|
172
108
|
}
|
|
173
109
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
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;
|
|
181
116
|
|
|
182
|
-
this.
|
|
183
|
-
this.displayMode$ = this.configProps$.displayMode;
|
|
184
|
-
this.label$ = this.configProps$.label;
|
|
185
|
-
this.helperText = this.configProps$.helperText;
|
|
186
|
-
this.hideLabel = this.configProps$.hideLabel;
|
|
187
|
-
const datasource = this.configProps$.datasource;
|
|
188
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
189
|
-
setTimeout(() => {
|
|
190
|
-
if (this.configProps$.required != null) {
|
|
191
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
192
|
-
}
|
|
193
|
-
this.cdRef.detectChanges();
|
|
194
|
-
});
|
|
117
|
+
this.value$ = value;
|
|
195
118
|
|
|
196
119
|
if (!isEqual(datasource, this.theDatasource)) {
|
|
197
120
|
// inbound datasource is different, so update theDatasource
|
|
198
121
|
this.theDatasource = datasource || null;
|
|
199
122
|
}
|
|
200
123
|
|
|
201
|
-
if (this.configProps$.visibility != null) {
|
|
202
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// disabled
|
|
206
|
-
if (this.configProps$.disabled != undefined) {
|
|
207
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (this.bDisabled$) {
|
|
211
|
-
this.fieldControl.disable();
|
|
212
|
-
} else {
|
|
213
|
-
this.fieldControl.enable();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (this.configProps$.readOnly != null) {
|
|
217
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
221
|
-
|
|
222
124
|
if (this.value$ === '' && !this.bReadonly$) {
|
|
223
125
|
this.value$ = 'Select';
|
|
224
126
|
}
|
|
@@ -235,8 +137,7 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
235
137
|
const className = this.pConn$.getCaseInfo().getClassName();
|
|
236
138
|
const refName = this.propName?.slice(this.propName.lastIndexOf('.') + 1);
|
|
237
139
|
|
|
238
|
-
|
|
239
|
-
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;
|
|
240
141
|
|
|
241
142
|
let displayName = metaData?.datasource?.propertyForDisplayText;
|
|
242
143
|
displayName = displayName?.slice(displayName.lastIndexOf('.') + 1);
|
|
@@ -252,16 +153,8 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
252
153
|
);
|
|
253
154
|
|
|
254
155
|
this.localizedValue = this.options$?.find(opt => opt.key === this.value$)?.value || this.localizedValue;
|
|
255
|
-
this.getDatapageData();
|
|
256
|
-
// trigger display of error message with field control
|
|
257
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
258
|
-
const timer = interval(100).subscribe(() => {
|
|
259
|
-
this.fieldControl.setErrors({ message: true });
|
|
260
|
-
this.fieldControl.markAsTouched();
|
|
261
156
|
|
|
262
|
-
|
|
263
|
-
});
|
|
264
|
-
}
|
|
157
|
+
this.getDatapageData();
|
|
265
158
|
}
|
|
266
159
|
|
|
267
160
|
getDatapageData() {
|
|
@@ -353,21 +246,4 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
353
246
|
this.pConn$.getLocaleRuleNameFromKeys(this.localeClass, this.localeContext, this.localeName)
|
|
354
247
|
);
|
|
355
248
|
}
|
|
356
|
-
|
|
357
|
-
getErrorMessage() {
|
|
358
|
-
let errMessage = '';
|
|
359
|
-
|
|
360
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
361
|
-
if (this.fieldControl.hasError('message')) {
|
|
362
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
363
|
-
return errMessage;
|
|
364
|
-
}
|
|
365
|
-
if (this.fieldControl.hasError('required')) {
|
|
366
|
-
errMessage = 'You must enter a value';
|
|
367
|
-
} else if (this.fieldControl.errors) {
|
|
368
|
-
errMessage = this.fieldControl.errors.toString();
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
return errMessage;
|
|
372
|
-
}
|
|
373
249
|
}
|
package/src/tasks/create/templates/SDK-Angular/field/Picklist-Autocomplete/demo.stories.tsx.mustache
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
-
import { moduleMetadata } from '@storybook/angular';
|
|
2
|
+
import { moduleMetadata, applicationConfig } from '@storybook/angular';
|
|
3
3
|
import { FormBuilder } from '@angular/forms';
|
|
4
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
4
5
|
import { DatapageService } from '@pega/angular-sdk-components';
|
|
5
6
|
import { configProps, stateProps } from './mock';
|
|
6
7
|
|
|
@@ -14,7 +15,11 @@ const meta: Meta<{{COMPONENT_CLASS_NAME}}Component> = {
|
|
|
14
15
|
title: '{{COMPONENT_CLASS_NAME}}',
|
|
15
16
|
decorators: [
|
|
16
17
|
moduleMetadata({
|
|
17
|
-
|
|
18
|
+
providers: [{ provide: DatapageService, useClass: MockingDatapageService }]
|
|
19
|
+
}),
|
|
20
|
+
|
|
21
|
+
applicationConfig({
|
|
22
|
+
providers: [provideHttpClient()]
|
|
18
23
|
})
|
|
19
24
|
],
|
|
20
25
|
component: {{COMPONENT_CLASS_NAME}}Component,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Component,
|
|
1
|
+
import { Component, EventEmitter, OnInit, Output, forwardRef, inject } from '@angular/core';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
4
|
import { MatOptionModule } from '@angular/material/core';
|
|
5
5
|
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
6
6
|
import { MatInputModule } from '@angular/material/input';
|
|
7
7
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
8
|
-
import {
|
|
8
|
+
import { Observable } from 'rxjs';
|
|
9
9
|
import { map, startWith } from 'rxjs/operators';
|
|
10
|
-
|
|
11
|
-
import {
|
|
10
|
+
|
|
11
|
+
import { FieldBase } from '@pega/angular-sdk-components';
|
|
12
12
|
import { ComponentMapperComponent } from '@pega/angular-sdk-components';
|
|
13
13
|
import { DatapageService } from '@pega/angular-sdk-components';
|
|
14
14
|
import { handleEvent } from '@pega/angular-sdk-components';
|
|
@@ -42,69 +42,26 @@ interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
|
|
|
42
42
|
MatAutocompleteModule,
|
|
43
43
|
MatOptionModule,
|
|
44
44
|
forwardRef(() => ComponentMapperComponent)
|
|
45
|
-
]
|
|
45
|
+
],
|
|
46
|
+
providers: [DatapageService]
|
|
46
47
|
})
|
|
47
|
-
export class {{COMPONENT_CLASS_NAME}}Component implements OnInit
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
export class {{COMPONENT_CLASS_NAME}}Component extends FieldBase implements OnInit {
|
|
49
|
+
protected dataPageService = inject(DatapageService);
|
|
50
|
+
|
|
50
51
|
@Output() onRecordChange: EventEmitter<any> = new EventEmitter();
|
|
51
52
|
|
|
52
|
-
// Used with AngularPConnect
|
|
53
|
-
angularPConnectData: AngularPConnectData = {};
|
|
54
53
|
configProps$: {{COMPONENT_CLASS_NAME}}Props;
|
|
55
54
|
|
|
56
|
-
label$ = '';
|
|
57
|
-
value$ = '';
|
|
58
|
-
bRequired$ = false;
|
|
59
|
-
bReadonly$ = false;
|
|
60
|
-
bDisabled$ = false;
|
|
61
|
-
bVisible$ = true;
|
|
62
|
-
displayMode$?: string = '';
|
|
63
|
-
controlName$: string;
|
|
64
|
-
bHasForm$ = true;
|
|
65
55
|
options$: any[];
|
|
66
|
-
componentReference = '';
|
|
67
|
-
testId: string;
|
|
68
56
|
listType: string;
|
|
69
57
|
columns = [];
|
|
70
|
-
helperText: string;
|
|
71
|
-
placeholder: string;
|
|
72
|
-
|
|
73
|
-
fieldControl = new FormControl('', null);
|
|
74
58
|
parameters: {};
|
|
75
|
-
hideLabel: boolean;
|
|
76
59
|
filteredOptions: Observable<any[]>;
|
|
77
60
|
filterValue = '';
|
|
78
|
-
actionsApi: object;
|
|
79
|
-
propName: string;
|
|
80
|
-
|
|
81
|
-
constructor(
|
|
82
|
-
private angularPConnect: AngularPConnectService,
|
|
83
|
-
private cdRef: ChangeDetectorRef,
|
|
84
|
-
private utils: Utils,
|
|
85
|
-
private dataPageService: DatapageService
|
|
86
|
-
) {}
|
|
87
|
-
|
|
88
|
-
async ngOnInit(): Promise<void> {
|
|
89
|
-
// First thing in initialization is registering and subscribing to the AngularPConnect service
|
|
90
|
-
this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
|
|
91
|
-
this.controlName$ = this.angularPConnect.getComponentID(this);
|
|
92
|
-
|
|
93
|
-
// Then, continue on with other initialization
|
|
94
61
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (this.formGroup$) {
|
|
100
|
-
// add control to formGroup
|
|
101
|
-
this.formGroup$.addControl(this.controlName$, this.fieldControl);
|
|
102
|
-
this.fieldControl.setValue(this.value$);
|
|
103
|
-
this.bHasForm$ = true;
|
|
104
|
-
} else {
|
|
105
|
-
this.bReadonly$ = true;
|
|
106
|
-
this.bHasForm$ = false;
|
|
107
|
-
}
|
|
62
|
+
// Override ngOnInit method
|
|
63
|
+
override async ngOnInit(): Promise<void> {
|
|
64
|
+
super.ngOnInit();
|
|
108
65
|
|
|
109
66
|
this.filteredOptions = this.fieldControl.valueChanges.pipe(
|
|
110
67
|
startWith(''),
|
|
@@ -119,54 +76,32 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
119
76
|
this.fieldControl.setValue(this.value$);
|
|
120
77
|
}
|
|
121
78
|
|
|
122
|
-
ngOnDestroy(): void {
|
|
123
|
-
if (this.formGroup$) {
|
|
124
|
-
this.formGroup$.removeControl(this.controlName$);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (this.angularPConnectData.unsubscribeFn) {
|
|
128
|
-
this.angularPConnectData.unsubscribeFn();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
79
|
private _filter(value: string): string[] {
|
|
133
80
|
const filterVal = (value || this.filterValue).toLowerCase();
|
|
134
81
|
return this.options$?.filter(option => option.value?.toLowerCase().includes(filterVal));
|
|
135
82
|
}
|
|
136
83
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// Should always check the bridge to see if the component should
|
|
144
|
-
// update itself (re-render)
|
|
145
|
-
const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
|
|
146
|
-
|
|
147
|
-
// ONLY call updateSelf when the component should update
|
|
148
|
-
if (bUpdateSelf) {
|
|
149
|
-
await this.updateSelf();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
84
|
+
/**
|
|
85
|
+
* Updates the component when there are changes in the state.
|
|
86
|
+
*/
|
|
87
|
+
override async updateSelf(): Promise<void> {
|
|
88
|
+
// Resolve configuration properties
|
|
89
|
+
this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as {{COMPONENT_CLASS_NAME}}Props;
|
|
152
90
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// starting very simple...
|
|
91
|
+
// Update component common properties
|
|
92
|
+
this.updateComponentCommonProperties(this.configProps$);
|
|
156
93
|
|
|
157
|
-
//
|
|
158
|
-
|
|
94
|
+
// Set component specific properties
|
|
95
|
+
const { value, listType, parameters } = this.configProps$;
|
|
159
96
|
|
|
160
|
-
if (
|
|
161
|
-
const index = this.options$?.findIndex(element => element.key ===
|
|
162
|
-
this.value$ = index > -1 ? this.options$[index].value :
|
|
97
|
+
if (value != undefined) {
|
|
98
|
+
const index = this.options$?.findIndex(element => element.key === value);
|
|
99
|
+
this.value$ = index > -1 ? this.options$[index].value : value;
|
|
163
100
|
this.fieldControl.setValue(this.value$);
|
|
164
101
|
}
|
|
165
102
|
|
|
166
|
-
this.
|
|
167
|
-
|
|
168
|
-
this.actionsApi = this.pConn$.getActionsApi();
|
|
169
|
-
this.propName = this.pConn$.getStateProps().value;
|
|
103
|
+
this.listType = listType;
|
|
104
|
+
this.parameters = parameters;
|
|
170
105
|
|
|
171
106
|
const context = this.pConn$.getContextName();
|
|
172
107
|
const { columns, datasource } = this.generateColumnsAndDataSource();
|
|
@@ -174,34 +109,7 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
174
109
|
if (columns) {
|
|
175
110
|
this.columns = this.preProcessColumns(columns);
|
|
176
111
|
}
|
|
177
|
-
// timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
|
|
178
|
-
setTimeout(() => {
|
|
179
|
-
if (this.configProps$.required != null) {
|
|
180
|
-
this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
|
|
181
|
-
}
|
|
182
|
-
this.cdRef.detectChanges();
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
if (this.configProps$.visibility != null) {
|
|
186
|
-
this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// disabled
|
|
190
|
-
if (this.configProps$.disabled != undefined) {
|
|
191
|
-
this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
|
|
192
|
-
}
|
|
193
112
|
|
|
194
|
-
if (this.bDisabled$) {
|
|
195
|
-
this.fieldControl.disable();
|
|
196
|
-
} else {
|
|
197
|
-
this.fieldControl.enable();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (this.configProps$.readOnly != null) {
|
|
201
|
-
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
this.componentReference = this.pConn$.getStateProps().value;
|
|
205
113
|
if (this.listType === 'associated') {
|
|
206
114
|
const optionsList = this.utils.getOptionList(this.configProps$, this.pConn$.getDataObject('')); // 1st arg empty string until typedef marked correctly
|
|
207
115
|
this.setOptions(optionsList);
|
|
@@ -211,27 +119,6 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
211
119
|
const results = await this.dataPageService.getDataPageData(datasource, this.parameters, context);
|
|
212
120
|
this.fillOptions(results);
|
|
213
121
|
}
|
|
214
|
-
|
|
215
|
-
// trigger display of error message with field control
|
|
216
|
-
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
|
|
217
|
-
const timer = interval(100).subscribe(() => {
|
|
218
|
-
this.fieldControl.setErrors({ message: true });
|
|
219
|
-
this.fieldControl.markAsTouched();
|
|
220
|
-
|
|
221
|
-
timer.unsubscribe();
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
setPropertyValuesFromProps() {
|
|
227
|
-
this.testId = this.configProps$.testId;
|
|
228
|
-
this.label$ = this.configProps$.label;
|
|
229
|
-
this.placeholder = this.configProps$.placeholder || '';
|
|
230
|
-
this.displayMode$ = this.configProps$.displayMode;
|
|
231
|
-
this.listType = this.configProps$.listType;
|
|
232
|
-
this.hideLabel = this.configProps$.hideLabel;
|
|
233
|
-
this.helperText = this.configProps$.helperText;
|
|
234
|
-
this.parameters = this.configProps$?.parameters;
|
|
235
122
|
}
|
|
236
123
|
|
|
237
124
|
generateColumnsAndDataSource() {
|
|
@@ -313,10 +200,6 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
313
200
|
}
|
|
314
201
|
|
|
315
202
|
fieldOnChange(event: Event) {
|
|
316
|
-
// this works - this.pConn$.setValue( this.componentReference, `property: ${this.componentReference}`);
|
|
317
|
-
// this works - this.pConn$.setValue( this.componentReference, this.fieldControl.value);
|
|
318
|
-
// PConnect wants to use changeHandler for onChange
|
|
319
|
-
// this.angularPConnect.changeHandler( this, event);
|
|
320
203
|
const value = (event.target as HTMLInputElement).value;
|
|
321
204
|
this.filterValue = value;
|
|
322
205
|
handleEvent(this.actionsApi, 'change', this.propName, value);
|
|
@@ -337,21 +220,4 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
|
|
|
337
220
|
this.onRecordChange.emit(value);
|
|
338
221
|
}
|
|
339
222
|
}
|
|
340
|
-
|
|
341
|
-
getErrorMessage() {
|
|
342
|
-
let errMessage = '';
|
|
343
|
-
|
|
344
|
-
// look for validation messages for json, pre-defined or just an error pushed from workitem (400)
|
|
345
|
-
if (this.fieldControl.hasError('message')) {
|
|
346
|
-
errMessage = this.angularPConnectData.validateMessage ?? '';
|
|
347
|
-
return errMessage;
|
|
348
|
-
}
|
|
349
|
-
if (this.fieldControl.hasError('required')) {
|
|
350
|
-
errMessage = 'You must enter a value';
|
|
351
|
-
} else if (this.fieldControl.errors) {
|
|
352
|
-
errMessage = this.fieldControl.errors.toString();
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return errMessage;
|
|
356
|
-
}
|
|
357
223
|
}
|