@unifylib/ui-lib 1.0.3 → 1.1.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/ng-package.json +7 -7
- package/package.json +14 -12
- package/src/lib/base-model/SearchStrConfig.ts +12 -12
- package/src/lib/base-model/api-response.ts +23 -23
- package/src/lib/base-model/audit-log-entry.ts +7 -7
- package/src/lib/base-model/button-action-settings.ts +29 -25
- package/src/lib/base-model/column-def.model.ts +34 -34
- package/src/lib/base-model/do-action-request.ts +11 -11
- package/src/lib/base-model/feature-item.ts +9 -0
- package/src/lib/base-model/field-action.ts +7 -7
- package/src/lib/base-model/field-filter.model.ts +7 -14
- package/src/lib/base-model/field-info.ts +102 -98
- package/src/lib/base-model/field-predicate.model.ts +7 -7
- package/src/lib/base-model/filter-request.ts +27 -27
- package/src/lib/base-model/filter.model.ts +49 -49
- package/src/lib/base-model/get-items-list.ts +24 -24
- package/src/lib/base-model/index.ts +11 -11
- package/src/lib/base-model/items-total.model.ts +12 -0
- package/src/lib/base-model/line-item.model.ts +18 -0
- package/src/lib/base-model/lookupItem.ts +21 -21
- package/src/lib/base-model/null-snackmessage.ts +9 -9
- package/src/lib/base-model/page-info.ts +54 -51
- package/src/lib/base-model/report-request.model.ts +33 -33
- package/src/lib/base-model/response-envelop.model.ts +15 -15
- package/src/lib/base-model/snack-message.model.ts +14 -14
- package/src/lib/base-model/snackmessage-interface.ts +7 -7
- package/src/lib/base-model/table-column.interface.ts +29 -29
- package/src/lib/base-model/table-page-user-action.interface.ts +33 -33
- package/src/lib/base-model/workflow/workflow-steps.model.ts +9 -9
- package/src/lib/base-model/workflow/workflow.model.ts +52 -52
- package/src/lib/components/action-comment/action-comment.component.css +52 -0
- package/src/lib/components/action-comment/action-comment.component.html +47 -0
- package/src/lib/components/{rejection-comment → action-comment}/action-comment.component.spec.ts +23 -23
- package/src/lib/components/{rejection-comment → action-comment}/action-comment.component.ts +102 -86
- package/src/lib/components/action-confirmation/action-confirmation.component.css +46 -34
- package/src/lib/components/action-confirmation/action-confirmation.component.html +32 -18
- package/src/lib/components/action-confirmation/action-confirmation.component.spec.ts +23 -23
- package/src/lib/components/action-confirmation/action-confirmation.component.ts +58 -58
- package/src/lib/components/activity-report-form/activity-report-form.component.html +110 -109
- package/src/lib/components/activity-report-form/activity-report-form.component.scss +69 -0
- package/src/lib/components/activity-report-form/activity-report-form.component.spec.ts +25 -25
- package/src/lib/components/activity-report-form/activity-report-form.component.ts +616 -605
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.html +8 -0
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.scss +0 -0
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.spec.ts +25 -0
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.ts +55 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.html +36 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.scss +130 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.spec.ts +25 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.ts +186 -0
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.css +51 -51
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.html +23 -23
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.spec.ts +23 -23
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.ts +69 -69
- package/src/lib/components/audit-log-list/audit-log.component.html +26 -23
- package/src/lib/components/audit-log-list/audit-log.component.scss +50 -0
- package/src/lib/components/audit-log-list/audit-log.component.spec.ts +25 -25
- package/src/lib/components/audit-log-list/audit-log.component.ts +114 -116
- package/src/lib/components/auto-complete/auto-complete.component.css +55 -14
- package/src/lib/components/auto-complete/auto-complete.component.html +45 -29
- package/src/lib/components/auto-complete/auto-complete.component.spec.ts +23 -23
- package/src/lib/components/auto-complete/auto-complete.component.ts +331 -330
- package/src/lib/components/base-form/base-form.component.html +59 -58
- package/src/lib/components/base-form/base-form.component.scss +68 -0
- package/src/lib/components/base-form/base-form.component.spec.ts +25 -25
- package/src/lib/components/base-form/base-form.component.ts +323 -305
- package/src/lib/components/base-form-canvas/base-form-canvas.component.css +196 -22
- package/src/lib/components/base-form-canvas/base-form-canvas.component.html +1095 -1006
- package/src/lib/components/base-form-canvas/base-form-canvas.component.spec.ts +23 -23
- package/src/lib/components/base-form-canvas/base-form-canvas.component.ts +680 -573
- package/src/lib/components/base-input-dialog/base-input-dialog.component.css +67 -0
- package/src/lib/components/base-input-dialog/base-input-dialog.component.html +47 -42
- package/src/lib/components/base-input-dialog/base-input-dialog.component.spec.ts +23 -23
- package/src/lib/components/base-input-dialog/base-input-dialog.component.ts +77 -78
- package/src/lib/components/base-table/base-table.component.html +268 -242
- package/src/lib/components/base-table/base-table.component.scss +140 -31
- package/src/lib/components/base-table/base-table.component.spec.ts +25 -25
- package/src/lib/components/base-table/base-table.component.ts +621 -568
- package/src/lib/components/button-actions/button-actions.component.html +27 -28
- package/src/lib/components/button-actions/button-actions.component.scss +101 -6
- package/src/lib/components/button-actions/button-actions.component.spec.ts +23 -23
- package/src/lib/components/button-actions/button-actions.component.ts +70 -72
- package/src/lib/components/editable-base-table/editable-base-table.component.html +337 -372
- package/src/lib/components/editable-base-table/editable-base-table.component.scss +126 -44
- package/src/lib/components/editable-base-table/editable-base-table.component.spec.ts +25 -25
- package/src/lib/components/editable-base-table/editable-base-table.component.ts +579 -570
- package/src/lib/components/equation-builder/equation-builder.component.css +39 -0
- package/src/lib/components/equation-builder/equation-builder.component.html +31 -31
- package/src/lib/components/equation-builder/equation-builder.component.spec.ts +23 -23
- package/src/lib/components/equation-builder/equation-builder.component.ts +119 -121
- package/src/lib/components/item-line-editor/item-line-editor.component.html +102 -0
- package/src/lib/components/item-line-editor/item-line-editor.component.scss +152 -0
- package/src/lib/components/item-line-editor/item-line-editor.component.spec.ts +23 -0
- package/src/lib/components/item-line-editor/item-line-editor.component.ts +306 -0
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.css +19 -11
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.html +38 -38
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.spec.ts +23 -23
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.ts +315 -317
- package/src/lib/components/paginator/paginator.component.css +65 -25
- package/src/lib/components/paginator/paginator.component.html +30 -34
- package/src/lib/components/paginator/paginator.component.ts +87 -94
- package/src/lib/components/report-details-dialog/report-details-dialog.component.css +17 -17
- package/src/lib/components/report-details-dialog/report-details-dialog.component.html +16 -16
- package/src/lib/components/report-details-dialog/report-details-dialog.component.spec.ts +23 -23
- package/src/lib/components/report-details-dialog/report-details-dialog.component.ts +111 -113
- package/src/lib/components/report-form/report-form.component.html +92 -94
- package/src/lib/components/report-form/report-form.component.scss +51 -0
- package/src/lib/components/report-form/report-form.component.spec.ts +25 -25
- package/src/lib/components/report-form/report-form.component.ts +599 -588
- package/src/lib/components/search-bar/search-bar.component.html +51 -62
- package/src/lib/components/search-bar/search-bar.component.scss +63 -8
- package/src/lib/components/search-bar/search-bar.component.spec.ts +25 -25
- package/src/lib/components/search-bar/search-bar.component.ts +68 -70
- package/src/lib/components/section-form-canvas/section-form-canvas.component.html +43 -0
- package/src/lib/components/section-form-canvas/section-form-canvas.component.scss +81 -0
- package/src/lib/components/section-form-canvas/section-form-canvas.component.spec.ts +23 -0
- package/src/lib/components/section-form-canvas/section-form-canvas.component.ts +67 -0
- package/src/lib/components/shared/action-button/action-button.component.html +12 -0
- package/src/lib/components/shared/action-button/action-button.component.scss +45 -0
- package/src/lib/components/shared/action-button/action-button.component.ts +51 -0
- package/src/lib/components/shared/action-card/action-card.component.html +78 -0
- package/src/lib/components/shared/action-card/action-card.component.scss +238 -0
- package/src/lib/components/shared/action-card/action-card.component.ts +56 -0
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.css +135 -54
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.html +36 -22
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.spec.ts +23 -23
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.ts +71 -45
- package/src/lib/components/shared-list/shared-list.component.html +17 -17
- package/src/lib/components/shared-list/shared-list.component.spec.ts +23 -23
- package/src/lib/components/shared-list/shared-list.component.ts +53 -53
- package/src/lib/components/snackbar-static/snackbar-static.component.html +20 -0
- package/src/lib/components/snackbar-static/snackbar-static.component.scss +135 -0
- package/src/lib/components/snackbar-static/snackbar-static.component.ts +26 -0
- package/src/lib/components/title-bar/title-bar.component.html +35 -31
- package/src/lib/components/title-bar/title-bar.component.scss +126 -23
- package/src/lib/components/title-bar/title-bar.component.spec.ts +23 -23
- package/src/lib/components/title-bar/title-bar.component.ts +126 -119
- package/src/lib/services/backend-service.ts +287 -286
- package/src/lib/services/index.ts +3 -3
- package/src/lib/services/top-panel.ts +17 -17
- package/src/lib/services/trigger-form.service.ts +11 -11
- package/src/lib/share-module/shared-module.ts +10 -10
- package/src/lib/utils/base-utils.ts +102 -102
- package/src/lib/validators/date-range-validator.ts +31 -31
- package/src/lib/validators/index.ts +3 -3
- package/src/lib/validators/match-list.validator.ts +10 -10
- package/src/lib/validators/multi-email-validator.ts +15 -15
- package/src/public-api.ts +29 -21
- package/tsconfig.lib.json +15 -15
- package/tsconfig.lib.prod.json +11 -11
- package/tsconfig.spec.json +15 -15
- package/src/lib/components/rejection-comment/action-comment.component.css +0 -33
- package/src/lib/components/rejection-comment/action-comment.component.html +0 -46
- package/src/lib/styles/invoiceq-theme.scss +0 -252
- package/src/lib/styles/styles.scss +0 -1723
|
@@ -1,317 +1,315 @@
|
|
|
1
|
-
import {Component, ElementRef, EventEmitter, Input, Output, SimpleChanges, ViewChild} from '@angular/core';
|
|
2
|
-
import {ALL_ITEM, LookupItem} from "../../base-model";
|
|
3
|
-
import {MatAutocomplete, MatAutocompleteTrigger, MatOption} from "@angular/material/autocomplete";
|
|
4
|
-
import {Observable, of} from "rxjs";
|
|
5
|
-
import {FieldInfo} from "../../base-model";
|
|
6
|
-
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
7
|
-
import {BackendService} from "../../services";
|
|
8
|
-
import {TranslateService} from "@ngx-translate/core";
|
|
9
|
-
import {GetItemsList} from "../../base-model/get-items-list";
|
|
10
|
-
import {MatFormField} from "@angular/material/form-field";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.multiControl
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.multiControl.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
this.
|
|
133
|
-
this.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.
|
|
204
|
-
|
|
205
|
-
this.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
this.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
this.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
}
|
|
1
|
+
import {Component, ElementRef, EventEmitter, Input, Output, SimpleChanges, ViewChild} from '@angular/core';
|
|
2
|
+
import {ALL_ITEM, LookupItem} from "../../base-model";
|
|
3
|
+
import {MatAutocomplete, MatAutocompleteTrigger, MatOption} from "@angular/material/autocomplete";
|
|
4
|
+
import {Observable, of} from "rxjs";
|
|
5
|
+
import {FieldInfo} from "../../base-model";
|
|
6
|
+
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
7
|
+
import {BackendService} from "../../services";
|
|
8
|
+
import {TranslateService} from "@ngx-translate/core";
|
|
9
|
+
import {GetItemsList} from "../../base-model/get-items-list";
|
|
10
|
+
import {MatFormField} from "@angular/material/form-field";
|
|
11
|
+
import {MatChip, MatChipGrid, MatChipInput, MatChipListbox} from "@angular/material/chips";
|
|
12
|
+
import {AsyncPipe, NgForOf, NgIf} from "@angular/common";
|
|
13
|
+
import {MatIcon} from "@angular/material/icon";
|
|
14
|
+
import {MatInput} from "@angular/material/input";
|
|
15
|
+
import { MatLabel } from '@angular/material/form-field';
|
|
16
|
+
import {buildItemsList} from "../../utils/base-utils";
|
|
17
|
+
import {FilterRequest} from "../../base-model";
|
|
18
|
+
import {Filter} from "../../base-model";
|
|
19
|
+
import {RequireMatch} from "../../validators";
|
|
20
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
21
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@Component({
|
|
25
|
+
selector: 'app-multi-auto-complete',
|
|
26
|
+
standalone: true,
|
|
27
|
+
imports: [
|
|
28
|
+
MatFormField,
|
|
29
|
+
MatChip,
|
|
30
|
+
MatIconModule,
|
|
31
|
+
MatChipsModule,
|
|
32
|
+
NgForOf,
|
|
33
|
+
MatIcon,
|
|
34
|
+
ReactiveFormsModule,
|
|
35
|
+
MatAutocompleteTrigger,
|
|
36
|
+
MatChipInput,
|
|
37
|
+
MatInput,
|
|
38
|
+
MatAutocomplete,
|
|
39
|
+
MatOption,
|
|
40
|
+
AsyncPipe,
|
|
41
|
+
NgIf,
|
|
42
|
+
MatChipGrid,
|
|
43
|
+
MatChipListbox,
|
|
44
|
+
MatLabel
|
|
45
|
+
],
|
|
46
|
+
templateUrl: './multi-auto-complete.component.html',
|
|
47
|
+
styleUrl: './multi-auto-complete.component.css'
|
|
48
|
+
})
|
|
49
|
+
export class MultiAutoCompleteComponent {
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
@ViewChild('itemInput') itemInput: ElementRef<HTMLInputElement>;
|
|
52
|
+
@ViewChild('autocompleteTrigger') matACTrigger: MatAutocompleteTrigger;
|
|
53
|
+
|
|
54
|
+
lookupItems$: Observable<LookupItem[]> | undefined;
|
|
55
|
+
private lookupItems: LookupItem[] = [];
|
|
56
|
+
|
|
57
|
+
selectedItems: LookupItem[] = [];
|
|
58
|
+
cascadedIdz: number[] = [];
|
|
59
|
+
isRequired: boolean= false;
|
|
60
|
+
private timer: any;
|
|
61
|
+
|
|
62
|
+
@Input()// @ts-ignore
|
|
63
|
+
field: FieldInfo;
|
|
64
|
+
//
|
|
65
|
+
@Input()// @ts-ignore
|
|
66
|
+
form: FormGroup;
|
|
67
|
+
|
|
68
|
+
@Input()// @ts-ignore
|
|
69
|
+
defaultValue: any;
|
|
70
|
+
|
|
71
|
+
@Input()
|
|
72
|
+
pathParam: any;
|
|
73
|
+
|
|
74
|
+
@Input()
|
|
75
|
+
readonly : boolean=false;
|
|
76
|
+
|
|
77
|
+
@Output()
|
|
78
|
+
selectedValue: EventEmitter<LookupItem[]> = new EventEmitter();
|
|
79
|
+
|
|
80
|
+
question = 'Would you like to add ?"';
|
|
81
|
+
|
|
82
|
+
multiControl = new FormControl();
|
|
83
|
+
|
|
84
|
+
constructor(private backendService: BackendService, private translateService: TranslateService) {
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ngOnInit(): void {
|
|
88
|
+
// this.form = this.rootFormGroup.control;
|
|
89
|
+
this.selectedItems = [];
|
|
90
|
+
this.multiControl = new FormControl(this.form?.controls[this.field?.property]);
|
|
91
|
+
|
|
92
|
+
this.multiControl.enable();
|
|
93
|
+
this.updateFieldAttributes();
|
|
94
|
+
|
|
95
|
+
if (!this.field.acceptNewItem){
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
this.multiControl.setValidators([RequireMatch]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.multiControl.setValue(this.form?.controls[this.field?.property]?.value);
|
|
101
|
+
|
|
102
|
+
this.multiControl.valueChanges.subscribe( v => {
|
|
103
|
+
if (typeof v === 'string') {
|
|
104
|
+
clearTimeout(this.timer);
|
|
105
|
+
this.timer = setTimeout(() => {
|
|
106
|
+
this.filterLookupItems(v, null);}, 700);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// this.multiControl.valueChanges.subscribe(v => {
|
|
112
|
+
// if (typeof v === 'string') this.filterLookupItems(v, null);
|
|
113
|
+
// })
|
|
114
|
+
// this.filterAutoCompleteData(this.field.property);
|
|
115
|
+
|
|
116
|
+
this.getLookupData();
|
|
117
|
+
if (this.field.cascadedBy) {
|
|
118
|
+
this.form?.get(this.field.cascadedBy)?.valueChanges.subscribe(v => {
|
|
119
|
+
this.removeChildItemsIfCascadedByRemoved(v);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private updateFieldAttributes() {
|
|
126
|
+
if (this.field.readonly) {
|
|
127
|
+
this.multiControl.disable();
|
|
128
|
+
this.isRequired = false;
|
|
129
|
+
} else if (this.field.required) {
|
|
130
|
+
this.form?.controls[this.field?.property].setValidators([Validators.required]);
|
|
131
|
+
this.form?.controls[this.field?.property].updateValueAndValidity();
|
|
132
|
+
this.multiControl.setValidators([Validators.required]);
|
|
133
|
+
this.isRequired = true;
|
|
134
|
+
}
|
|
135
|
+
this.multiControl.updateValueAndValidity();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private removeChildItemsIfCascadedByRemoved(v) {
|
|
139
|
+
this.cascadedIdz = [];
|
|
140
|
+
v.forEach(a => {
|
|
141
|
+
this.cascadedIdz.push(a.id);
|
|
142
|
+
});
|
|
143
|
+
let toDeleteIdz = [];
|
|
144
|
+
this.selectedItems?.forEach(x => {
|
|
145
|
+
const del = this.cascadedIdz.findIndex(y => y === x[this.field.cascadedBy]?.id);
|
|
146
|
+
if (del < 0) {
|
|
147
|
+
toDeleteIdz.push(x['id']);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (toDeleteIdz) {
|
|
152
|
+
this.selectedItems = this.selectedItems.filter(s => !toDeleteIdz.includes(s.id));
|
|
153
|
+
this.form.get(this.field.property).patchValue(this.selectedItems, {emitEvent: true});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
ngOnChanges({defaultValue, field}: SimpleChanges): void {
|
|
158
|
+
this.patchLookupValue(defaultValue?.currentValue);
|
|
159
|
+
if (field?.currentValue) {
|
|
160
|
+
this.field = field.currentValue;
|
|
161
|
+
this.updateFieldAttributes();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private getLookupData() {
|
|
166
|
+
const listItems: GetItemsList = buildItemsList('', this.field.lookupApiPath);
|
|
167
|
+
|
|
168
|
+
const filterRequest: FilterRequest = new FilterRequest();
|
|
169
|
+
filterRequest.filters = [];
|
|
170
|
+
this.cascadedIdz = [];
|
|
171
|
+
if (this.field.cascadedBy) {
|
|
172
|
+
this.form.get(this.field.cascadedBy)?.value?.forEach(a => {
|
|
173
|
+
this.cascadedIdz.push(a.id);
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
if (this.field.cascadedBy && this.cascadedIdz?.length > 0) {
|
|
177
|
+
filterRequest.filters.push(new Filter({
|
|
178
|
+
key: 'id', fieldName: this.field.cascadedBy, label: '',
|
|
179
|
+
filterType: 'FILED_FILTER', operator: 'IN',
|
|
180
|
+
valueObject: this.cascadedIdz
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
filterRequest.columns = ['id','code','englishName','arabicName'];
|
|
185
|
+
this.backendService.getLookupItemsByMultiFilter(listItems, filterRequest).subscribe((resp => {
|
|
186
|
+
if (resp.valid) {
|
|
187
|
+
this.lookupItems = this.field.includeAllOption ? [ALL_ITEM].concat(resp.body) : resp.body;
|
|
188
|
+
if (!this.form.get('id')?.value) {
|
|
189
|
+
this.patchLookupValue(this.lookupItems?.find(l => l.defaultValue));
|
|
190
|
+
}
|
|
191
|
+
this.patchLookupValue(this.multiControl.value);
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
selected(value: any): void {
|
|
200
|
+
if (value.id !== -1 && this.selectedItems.findIndex(i => i.id === value.id) === -1) {
|
|
201
|
+
this.selectedItems?.push(value);
|
|
202
|
+
this.itemInput.nativeElement.value = '';
|
|
203
|
+
this.form.get(this.field.property)?.setValue(this.selectedItems);
|
|
204
|
+
// @ts-ignore
|
|
205
|
+
this.selectedValue.emit(this.selectedItems);
|
|
206
|
+
this.multiControl.setValue(null);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
displayFn(selected: any): string {
|
|
211
|
+
return selected ? selected.englishName : undefined;
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
isSelected(item: any): boolean {
|
|
215
|
+
return this.selectedItems?.some(selected => selected.id === item.id); // Use your unique identifier
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
_allowSelection(option: LookupItem): { [className: string]: boolean } {
|
|
219
|
+
return {
|
|
220
|
+
'prevent-selection': option.id === -1,
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
itemNameByLag(item: any): string {
|
|
225
|
+
// return item.arabicName;
|
|
226
|
+
return this.translateService.getDefaultLang() === 'en' ? item.englishName : item.arabicName
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private readonly _columns = ['id','code','englishName','arabicName'];
|
|
230
|
+
|
|
231
|
+
filterLookupItems(name: any, trigger: MatAutocompleteTrigger) {
|
|
232
|
+
if (trigger) {
|
|
233
|
+
trigger.openPanel();
|
|
234
|
+
}
|
|
235
|
+
if (name === undefined) {
|
|
236
|
+
name = '';
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const listItems: GetItemsList = buildItemsList(name, this.field.lookupApiPath);
|
|
240
|
+
|
|
241
|
+
const filterRequest: FilterRequest = new FilterRequest();
|
|
242
|
+
filterRequest.filters = this.field.lookupFilterList || [];
|
|
243
|
+
filterRequest.searchStr = name;
|
|
244
|
+
this.cascadedIdz = [];
|
|
245
|
+
if (this.field.cascadedBy) {
|
|
246
|
+
this.form.get(this.field.cascadedBy)?.value?.forEach(a => {
|
|
247
|
+
this.cascadedIdz.push(a.id);
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
if (this.field.cascadedBy && this.cascadedIdz?.length > 0) {
|
|
251
|
+
filterRequest.filters.push(new Filter({
|
|
252
|
+
key: 'id',joinObjectName: this.field.cascadedBy, fieldName: this.field.cascadedBy, label: '',
|
|
253
|
+
filterType: 'FILED_FILTER', operator: 'IN',
|
|
254
|
+
valueObject: this.cascadedIdz
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
filterRequest.columns = [...this._columns, ...(this.field.extraLookupsColumns ?? [])];
|
|
259
|
+
|
|
260
|
+
this.backendService.getLookupItemsByMultiFilter(listItems, filterRequest).subscribe(resp => {
|
|
261
|
+
// console.log('result -->', resp);
|
|
262
|
+
let items: LookupItem[] = [];
|
|
263
|
+
if (resp.valid) {
|
|
264
|
+
// resp.body.forEach(r => items.push(r));
|
|
265
|
+
items = resp.body.filter(item =>
|
|
266
|
+
// (item.englishName.toLowerCase().includes(name.toLowerCase()) ||
|
|
267
|
+
// item.arabicName.toLowerCase().includes(name.toLowerCase())) &&
|
|
268
|
+
this.selectedItems?.findIndex( i=> i.id ===item.id ) ===-1 );
|
|
269
|
+
if (!items?.length) {
|
|
270
|
+
this.field.acceptNewItem ?
|
|
271
|
+
items?.push(new LookupItem({id: -2, englishName: this.question + name, arabicName: this.question + name})):
|
|
272
|
+
items?.push(new LookupItem({id: -1, englishName: 'No match ...', arabicName: 'غير موجود ... '})) ;
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
this.field.acceptNewItem ?
|
|
277
|
+
items?.push(new LookupItem({id: -2, englishName: this.question + name, arabicName: this.question + name})):
|
|
278
|
+
items?.push(new LookupItem({id: -1, englishName: 'No match ...', arabicName: 'غير موجود ... '})) ;
|
|
279
|
+
}
|
|
280
|
+
this.lookupItems$ = of(items);
|
|
281
|
+
});
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private patchLookupValue(defaultValue: any) {
|
|
286
|
+
if (defaultValue) {
|
|
287
|
+
// this.form?.get(this.field.property)?.patchValue(defaultValue);
|
|
288
|
+
this.selectedItems = defaultValue;
|
|
289
|
+
this.multiControl.setValue(defaultValue);
|
|
290
|
+
this.multiControl.patchValue(defaultValue, {emitEvent: true});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
remove(item: LookupItem) {
|
|
295
|
+
const index = this.selectedItems.indexOf(item);
|
|
296
|
+
if (index >= 0) {
|
|
297
|
+
this.selectedItems.splice(index, 1);
|
|
298
|
+
this.form.get(this.field.property).patchValue(this.selectedItems, {emitEvent: true});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
getLabel() {
|
|
303
|
+
return this.translateService.instant(this.field.label);
|
|
304
|
+
}
|
|
305
|
+
onKeydown(event: KeyboardEvent, autocompleteTrigger: MatAutocompleteTrigger) {
|
|
306
|
+
if (event.key === 'Enter') {
|
|
307
|
+
this.filterLookupItems('', autocompleteTrigger);
|
|
308
|
+
autocompleteTrigger.openPanel();
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
getId() {
|
|
313
|
+
return this.field.property;
|
|
314
|
+
}
|
|
315
|
+
}
|