@pepperi-addons/ngx-lib 0.2.58-beta.1 → 0.2.59

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 (163) hide show
  1. package/attachment/attachment.component.d.ts +0 -1
  2. package/attachment/pepperi-addons-ngx-lib-attachment.metadata.json +1 -1
  3. package/bundles/pepperi-addons-ngx-lib-attachment.umd.js +1 -6
  4. package/bundles/pepperi-addons-ngx-lib-attachment.umd.js.map +1 -1
  5. package/bundles/pepperi-addons-ngx-lib-checkbox.umd.js +0 -3
  6. package/bundles/pepperi-addons-ngx-lib-checkbox.umd.js.map +1 -1
  7. package/bundles/pepperi-addons-ngx-lib-color.umd.js +1 -6
  8. package/bundles/pepperi-addons-ngx-lib-color.umd.js.map +1 -1
  9. package/bundles/pepperi-addons-ngx-lib-date.umd.js +0 -3
  10. package/bundles/pepperi-addons-ngx-lib-date.umd.js.map +1 -1
  11. package/bundles/pepperi-addons-ngx-lib-form.umd.js +15 -18
  12. package/bundles/pepperi-addons-ngx-lib-form.umd.js.map +1 -1
  13. package/bundles/pepperi-addons-ngx-lib-image.umd.js +1 -6
  14. package/bundles/pepperi-addons-ngx-lib-image.umd.js.map +1 -1
  15. package/bundles/pepperi-addons-ngx-lib-images-filmstrip.umd.js +1 -6
  16. package/bundles/pepperi-addons-ngx-lib-images-filmstrip.umd.js.map +1 -1
  17. package/bundles/pepperi-addons-ngx-lib-quantity-selector.umd.js +1 -6
  18. package/bundles/pepperi-addons-ngx-lib-quantity-selector.umd.js.map +1 -1
  19. package/bundles/pepperi-addons-ngx-lib-rich-html-textarea.umd.js +1 -6
  20. package/bundles/pepperi-addons-ngx-lib-rich-html-textarea.umd.js.map +1 -1
  21. package/bundles/pepperi-addons-ngx-lib-select.umd.js +1 -6
  22. package/bundles/pepperi-addons-ngx-lib-select.umd.js.map +1 -1
  23. package/bundles/pepperi-addons-ngx-lib-separator.umd.js +0 -8
  24. package/bundles/pepperi-addons-ngx-lib-separator.umd.js.map +1 -1
  25. package/bundles/pepperi-addons-ngx-lib-signature.umd.js +1 -6
  26. package/bundles/pepperi-addons-ngx-lib-signature.umd.js.map +1 -1
  27. package/bundles/pepperi-addons-ngx-lib-smart-filters.umd.js +173 -1432
  28. package/bundles/pepperi-addons-ngx-lib-smart-filters.umd.js.map +1 -1
  29. package/bundles/pepperi-addons-ngx-lib-textarea.umd.js +1 -6
  30. package/bundles/pepperi-addons-ngx-lib-textarea.umd.js.map +1 -1
  31. package/bundles/pepperi-addons-ngx-lib-textbox.umd.js +2 -4
  32. package/bundles/pepperi-addons-ngx-lib-textbox.umd.js.map +1 -1
  33. package/bundles/pepperi-addons-ngx-lib.umd.js +101 -85
  34. package/bundles/pepperi-addons-ngx-lib.umd.js.map +1 -1
  35. package/color/color.component.d.ts +0 -1
  36. package/color/pepperi-addons-ngx-lib-color.metadata.json +1 -1
  37. package/core/common/services/color.service.d.ts +3 -3
  38. package/core/customization/customization.service.d.ts +0 -1
  39. package/esm2015/attachment/attachment.component.js +2 -7
  40. package/esm2015/checkbox/checkbox.component.js +1 -4
  41. package/esm2015/color/color.component.js +2 -7
  42. package/esm2015/color/public-api.js +1 -2
  43. package/esm2015/core/common/services/color.service.js +101 -83
  44. package/esm2015/core/customization/customization.service.js +2 -4
  45. package/esm2015/date/date.component.js +1 -4
  46. package/esm2015/form/internal-button.component.js +17 -20
  47. package/esm2015/image/image.component.js +2 -7
  48. package/esm2015/images-filmstrip/images-filmstrip.component.js +2 -7
  49. package/esm2015/quantity-selector/quantity-selector.component.js +2 -7
  50. package/esm2015/rich-html-textarea/rich-html-textarea.component.js +2 -7
  51. package/esm2015/select/select.component.js +2 -7
  52. package/esm2015/separator/separator.component.js +1 -9
  53. package/esm2015/signature/signature.component.js +2 -7
  54. package/esm2015/smart-filters/boolean-filter/boolean-filter.component.js +2 -12
  55. package/esm2015/smart-filters/common/model/base-filter-component.js +10 -40
  56. package/esm2015/smart-filters/common/model/creator.js +2 -8
  57. package/esm2015/smart-filters/common/model/field.js +1 -12
  58. package/esm2015/smart-filters/common/model/operator.js +8 -8
  59. package/esm2015/smart-filters/common/model/type.js +1 -1
  60. package/esm2015/smart-filters/date-filter/date-filter.component.js +2 -45
  61. package/esm2015/smart-filters/multi-select-filter/multi-select-filter.component.js +14 -53
  62. package/esm2015/smart-filters/number-filter/number-filter.component.js +2 -25
  63. package/esm2015/smart-filters/pepperi-addons-ngx-lib-smart-filters.js +1 -8
  64. package/esm2015/smart-filters/public-api.js +1 -2
  65. package/esm2015/smart-filters/smart-filters.module.js +2 -14
  66. package/esm2015/textarea/textarea.component.js +2 -7
  67. package/esm2015/textbox/textbox.component.js +3 -5
  68. package/fesm2015/pepperi-addons-ngx-lib-attachment.js +1 -6
  69. package/fesm2015/pepperi-addons-ngx-lib-attachment.js.map +1 -1
  70. package/fesm2015/pepperi-addons-ngx-lib-checkbox.js +0 -3
  71. package/fesm2015/pepperi-addons-ngx-lib-checkbox.js.map +1 -1
  72. package/fesm2015/pepperi-addons-ngx-lib-color.js +1 -6
  73. package/fesm2015/pepperi-addons-ngx-lib-color.js.map +1 -1
  74. package/fesm2015/pepperi-addons-ngx-lib-date.js +0 -3
  75. package/fesm2015/pepperi-addons-ngx-lib-date.js.map +1 -1
  76. package/fesm2015/pepperi-addons-ngx-lib-form.js +15 -18
  77. package/fesm2015/pepperi-addons-ngx-lib-form.js.map +1 -1
  78. package/fesm2015/pepperi-addons-ngx-lib-image.js +1 -6
  79. package/fesm2015/pepperi-addons-ngx-lib-image.js.map +1 -1
  80. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.js +1 -6
  81. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.js.map +1 -1
  82. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.js +1 -6
  83. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.js.map +1 -1
  84. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.js +1 -6
  85. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.js.map +1 -1
  86. package/fesm2015/pepperi-addons-ngx-lib-select.js +1 -6
  87. package/fesm2015/pepperi-addons-ngx-lib-select.js.map +1 -1
  88. package/fesm2015/pepperi-addons-ngx-lib-separator.js +0 -8
  89. package/fesm2015/pepperi-addons-ngx-lib-separator.js.map +1 -1
  90. package/fesm2015/pepperi-addons-ngx-lib-signature.js +1 -6
  91. package/fesm2015/pepperi-addons-ngx-lib-signature.js.map +1 -1
  92. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.js +128 -1293
  93. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.js.map +1 -1
  94. package/fesm2015/pepperi-addons-ngx-lib-textarea.js +1 -6
  95. package/fesm2015/pepperi-addons-ngx-lib-textarea.js.map +1 -1
  96. package/fesm2015/pepperi-addons-ngx-lib-textbox.js +2 -4
  97. package/fesm2015/pepperi-addons-ngx-lib-textbox.js.map +1 -1
  98. package/fesm2015/pepperi-addons-ngx-lib.js +101 -85
  99. package/fesm2015/pepperi-addons-ngx-lib.js.map +1 -1
  100. package/form/internal-button.component.d.ts +1 -0
  101. package/image/image.component.d.ts +0 -1
  102. package/image/pepperi-addons-ngx-lib-image.metadata.json +1 -1
  103. package/images-filmstrip/images-filmstrip.component.d.ts +0 -1
  104. package/images-filmstrip/pepperi-addons-ngx-lib-images-filmstrip.metadata.json +1 -1
  105. package/package.json +1 -1
  106. package/pepperi-addons-ngx-lib.metadata.json +1 -1
  107. package/quantity-selector/pepperi-addons-ngx-lib-quantity-selector.metadata.json +1 -1
  108. package/quantity-selector/quantity-selector.component.d.ts +0 -1
  109. package/rich-html-textarea/pepperi-addons-ngx-lib-rich-html-textarea.metadata.json +1 -1
  110. package/rich-html-textarea/rich-html-textarea.component.d.ts +0 -1
  111. package/select/pepperi-addons-ngx-lib-select.metadata.json +1 -1
  112. package/select/select.component.d.ts +0 -1
  113. package/separator/pepperi-addons-ngx-lib-separator.metadata.json +1 -1
  114. package/signature/pepperi-addons-ngx-lib-signature.metadata.json +1 -1
  115. package/signature/signature.component.d.ts +0 -1
  116. package/smart-filters/boolean-filter/boolean-filter.component.d.ts +1 -5
  117. package/smart-filters/common/model/base-filter-component.d.ts +1 -10
  118. package/smart-filters/common/model/field.d.ts +0 -4
  119. package/smart-filters/common/model/operator.d.ts +0 -1
  120. package/smart-filters/common/model/type.d.ts +2 -2
  121. package/smart-filters/date-filter/date-filter.component.d.ts +1 -8
  122. package/smart-filters/multi-select-filter/multi-select-filter.component.d.ts +0 -6
  123. package/smart-filters/number-filter/number-filter.component.d.ts +0 -5
  124. package/smart-filters/pepperi-addons-ngx-lib-smart-filters.d.ts +0 -7
  125. package/smart-filters/pepperi-addons-ngx-lib-smart-filters.metadata.json +1 -1
  126. package/smart-filters/public-api.d.ts +0 -1
  127. package/src/assets/i18n/en.ngx-lib.json +1 -2
  128. package/src/core/style/abstracts/mixins.scss +3 -3
  129. package/src/core/style/components/general.scss +2 -4
  130. package/textarea/pepperi-addons-ngx-lib-textarea.metadata.json +1 -1
  131. package/textarea/textarea.component.d.ts +0 -1
  132. package/theming.scss +0 -4
  133. package/esm2015/smart-filters/filter-builder/common/model/filter.js +0 -2
  134. package/esm2015/smart-filters/filter-builder/common/model/legacy.js +0 -2
  135. package/esm2015/smart-filters/filter-builder/common/model/operator-unit.js +0 -42
  136. package/esm2015/smart-filters/filter-builder/common/model/operator.js +0 -207
  137. package/esm2015/smart-filters/filter-builder/common/model/type-map.js +0 -27
  138. package/esm2015/smart-filters/filter-builder/common/model/type.js +0 -6
  139. package/esm2015/smart-filters/filter-builder/common/pipes/filter-item-counter.pipe.js +0 -18
  140. package/esm2015/smart-filters/filter-builder/common/services/output-filter.service.js +0 -132
  141. package/esm2015/smart-filters/filter-builder/common/services/type-convertor.service.js +0 -44
  142. package/esm2015/smart-filters/filter-builder/filter-builder-item/filter-builder-item.component.js +0 -106
  143. package/esm2015/smart-filters/filter-builder/filter-builder-section/filter-builder-section.component.js +0 -50
  144. package/esm2015/smart-filters/filter-builder/filter-builder.component.js +0 -65
  145. package/esm2015/smart-filters/filter-builder/filter-builder.service.js +0 -261
  146. package/esm2015/smart-filters/index.js +0 -5
  147. package/esm2015/smart-filters/text-filter/text-filter.component.js +0 -79
  148. package/smart-filters/filter-builder/common/model/filter.d.ts +0 -6
  149. package/smart-filters/filter-builder/common/model/legacy.d.ts +0 -23
  150. package/smart-filters/filter-builder/common/model/operator-unit.d.ts +0 -13
  151. package/smart-filters/filter-builder/common/model/operator.d.ts +0 -21
  152. package/smart-filters/filter-builder/common/model/type-map.d.ts +0 -12
  153. package/smart-filters/filter-builder/common/model/type.d.ts +0 -4
  154. package/smart-filters/filter-builder/common/pipes/filter-item-counter.pipe.d.ts +0 -5
  155. package/smart-filters/filter-builder/common/services/output-filter.service.d.ts +0 -52
  156. package/smart-filters/filter-builder/common/services/type-convertor.service.d.ts +0 -10
  157. package/smart-filters/filter-builder/filter-builder-item/filter-builder-item.component.d.ts +0 -32
  158. package/smart-filters/filter-builder/filter-builder-section/filter-builder-section.component.d.ts +0 -22
  159. package/smart-filters/filter-builder/filter-builder-section/filter-builder-section.component.theme.scss +0 -6
  160. package/smart-filters/filter-builder/filter-builder.component.d.ts +0 -22
  161. package/smart-filters/filter-builder/filter-builder.service.d.ts +0 -90
  162. package/smart-filters/index.d.ts +0 -1
  163. package/smart-filters/text-filter/text-filter.component.d.ts +0 -17
@@ -1,7 +1,5 @@
1
- import * as i0 from '@angular/core';
2
- import { EventEmitter, Component, ChangeDetectionStrategy, ElementRef, Input, Output, Injectable, Directive, ViewContainerRef, Injector, ComponentFactoryResolver, Renderer2, ViewChild, Pipe, NgModule } from '@angular/core';
1
+ import { EventEmitter, Component, ChangeDetectionStrategy, ElementRef, Input, Output, Directive, ViewContainerRef, Injector, ComponentFactoryResolver, Renderer2, ViewChild, NgModule } from '@angular/core';
3
2
  import { CommonModule } from '@angular/common';
4
- import * as i1 from '@angular/forms';
5
3
  import { Validators, FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms';
6
4
  import { FlexLayoutModule } from '@angular/flex-layout';
7
5
  import { MatCommonModule } from '@angular/material/core';
@@ -19,10 +17,9 @@ import { PepDateModule } from '@pepperi-addons/ngx-lib/date';
19
17
  import { PepSelectModule } from '@pepperi-addons/ngx-lib/select';
20
18
  import { PepTextboxModule } from '@pepperi-addons/ngx-lib/textbox';
21
19
  import { PepSearchModule } from '@pepperi-addons/ngx-lib/search';
22
- import { PepButtonModule } from '@pepperi-addons/ngx-lib/button';
23
20
  import { pepIconNumberMinus, pepIconNumberPlus, PepIconModule, PepIconRegistry } from '@pepperi-addons/ngx-lib/icon';
21
+ import { Subject } from 'rxjs';
24
22
  import { takeUntil, distinctUntilChanged, startWith, map } from 'rxjs/operators';
25
- import { Subject, BehaviorSubject } from 'rxjs';
26
23
  import { TranslateService } from '@ngx-translate/core';
27
24
 
28
25
  class PepSmartFiltersComponent {
@@ -180,7 +177,7 @@ PepFilterActionsComponent.propDecorators = {
180
177
 
181
178
  class IPepSmartFilterOperator {
182
179
  }
183
- const Equals$1 = {
180
+ const Equals = {
184
181
  id: 'eq',
185
182
  name: 'EQUAL',
186
183
  short: '=',
@@ -194,7 +191,7 @@ const Equals$1 = {
194
191
  // 'select',
195
192
  ],
196
193
  };
197
- const NotEqual$1 = {
194
+ const NotEqual = {
198
195
  id: 'neq',
199
196
  name: 'NOT_EQUAL',
200
197
  short: '<>',
@@ -207,7 +204,7 @@ const NotEqual$1 = {
207
204
  // 'select',
208
205
  ],
209
206
  };
210
- const LessThan$1 = {
207
+ const LessThan = {
211
208
  id: 'lt',
212
209
  name: 'LESS_THEN',
213
210
  short: '<',
@@ -219,7 +216,7 @@ const LessThan$1 = {
219
216
  // short: '<=',
220
217
  // type: ['number'],
221
218
  // };
222
- const GreaterThan$1 = {
219
+ const GreaterThan = {
223
220
  id: 'gt',
224
221
  name: 'GREATER_THEN',
225
222
  short: '>',
@@ -231,18 +228,18 @@ const GreaterThan$1 = {
231
228
  // short: '>=',
232
229
  // type: ['number'],
233
230
  // };
234
- const NumberRange$1 = {
231
+ const NumberRange = {
235
232
  id: 'numberRange',
236
233
  name: 'NUMBER_RANGE',
237
234
  short: 'Range',
238
235
  componentType: ['number'],
239
236
  };
240
- const Contains$1 = {
241
- id: 'contains',
242
- name: 'CONTAINS',
243
- short: 'Contains',
244
- componentType: ['text'],
245
- };
237
+ // const Contains: Operator = {
238
+ // id: 'contains',
239
+ // name: 'Contains',
240
+ // short: 'Contains',
241
+ // type: ['text'],
242
+ // };
246
243
  // const BeginsWith: Operator = {
247
244
  // id: 'beginsWith',
248
245
  // name: 'Begins With',
@@ -267,177 +264,135 @@ const Contains$1 = {
267
264
  // short: 'Before',
268
265
  // type: ['date'],
269
266
  // };
270
- const InTheLast$1 = {
267
+ const InTheLast = {
271
268
  id: 'inTheLast',
272
269
  name: 'IN_THE_LAST',
273
270
  short: 'In the last',
274
271
  componentType: ['date'],
275
272
  };
276
- const Today$1 = {
273
+ const Today = {
277
274
  id: 'today',
278
275
  name: 'TODAY',
279
276
  short: 'Today',
280
277
  componentType: ['date'],
281
278
  };
282
- const ThisWeek$1 = {
279
+ const ThisWeek = {
283
280
  id: 'thisWeek',
284
281
  name: 'THIS_WEEK',
285
282
  short: 'This week',
286
283
  componentType: ['date'],
287
284
  };
288
- const ThisMonth$1 = {
285
+ const ThisMonth = {
289
286
  id: 'thisMonth',
290
287
  name: 'THIS_MONTH',
291
288
  short: 'This month',
292
289
  componentType: ['date'],
293
290
  };
294
- const DateRange$1 = {
291
+ const DateRange = {
295
292
  id: 'dateRange',
296
293
  name: 'DATE_RANGE',
297
294
  short: 'Range',
298
295
  componentType: ['date'],
299
296
  };
300
- const DueIn$1 = {
297
+ const DueIn = {
301
298
  id: 'dueIn',
302
299
  name: 'DUE_IN',
303
300
  short: 'Due in',
304
301
  componentType: ['date'],
305
302
  };
306
- const On$1 = {
303
+ const On = {
307
304
  id: 'on',
308
305
  name: 'ON',
309
306
  short: 'On',
310
307
  componentType: ['date'],
311
308
  };
312
- const NotInTheLast$1 = {
309
+ const NotInTheLast = {
313
310
  id: 'notInTheLast',
314
311
  name: 'NOT_IN_THE_LAST',
315
312
  short: 'Not in the last',
316
313
  componentType: ['date'],
317
314
  };
318
- const NotDueIn$1 = {
315
+ const NotDueIn = {
319
316
  id: 'notDueIn',
320
317
  name: 'NOT_DUE_IN',
321
318
  short: 'Not due in',
322
319
  componentType: ['date'],
323
320
  };
324
- const IsEmpty$1 = {
321
+ const IsEmpty = {
325
322
  id: 'isEmpty',
326
323
  name: 'IS_EMPTY',
327
324
  short: 'Is empty',
328
325
  componentType: ['date'],
329
326
  };
330
- const IsNotEmpty$1 = {
327
+ const IsNotEmpty = {
331
328
  id: 'isNotEmpty',
332
329
  name: 'IS_NOT_EMPTY',
333
330
  short: 'Is not empty',
334
331
  componentType: ['date'],
335
332
  };
336
- const In$1 = {
333
+ const In = {
337
334
  id: 'in',
338
335
  name: 'IN',
339
336
  short: 'In',
340
337
  componentType: ['multi-select'],
341
338
  };
342
339
  const PepSmartFilterOperators = {
343
- Equals: Equals$1,
344
- NotEqual: NotEqual$1,
345
- LessThan: LessThan$1,
340
+ Equals: Equals,
341
+ NotEqual: NotEqual,
342
+ LessThan: LessThan,
346
343
  // LessThanOrEquals: LessThanOrEquals,
347
- GreaterThan: GreaterThan$1,
344
+ GreaterThan: GreaterThan,
348
345
  // GreaterThanOrEquals: GreaterThanOrEquals,
349
- NumberRange: NumberRange$1,
350
- Contains: Contains$1,
346
+ NumberRange: NumberRange,
347
+ // Contains: Contains,
351
348
  // BeginsWith: BeginsWith,
352
349
  // EndsWith: EndsWith,
353
350
  // After: After,
354
351
  // Before: Before,
355
- InTheLast: InTheLast$1,
356
- Today: Today$1,
357
- ThisWeek: ThisWeek$1,
358
- ThisMonth: ThisMonth$1,
359
- DateRange: DateRange$1,
360
- DueIn: DueIn$1,
361
- On: On$1,
362
- NotInTheLast: NotInTheLast$1,
363
- NotDueIn: NotDueIn$1,
364
- IsEmpty: IsEmpty$1,
365
- IsNotEmpty: IsNotEmpty$1,
366
- In: In$1,
352
+ InTheLast: InTheLast,
353
+ Today: Today,
354
+ ThisWeek: ThisWeek,
355
+ ThisMonth: ThisMonth,
356
+ DateRange: DateRange,
357
+ DueIn: DueIn,
358
+ On: On,
359
+ NotInTheLast: NotInTheLast,
360
+ NotDueIn: NotDueIn,
361
+ IsEmpty: IsEmpty,
362
+ IsNotEmpty: IsNotEmpty,
363
+ In: In,
367
364
  };
368
365
  class IPepSmartFilterOperatorUnit {
369
366
  }
370
- const Days$1 = {
367
+ const Days = {
371
368
  id: 'days',
372
369
  name: 'DAYS',
373
370
  componentType: ['date'],
374
371
  };
375
- const Weeks$1 = {
372
+ const Weeks = {
376
373
  id: 'weeks',
377
374
  name: 'WEEKS',
378
375
  componentType: ['date'],
379
376
  };
380
- const Months$1 = {
377
+ const Months = {
381
378
  id: 'months',
382
379
  name: 'MONTHS',
383
380
  componentType: ['date'],
384
381
  };
385
- const Years$1 = {
382
+ const Years = {
386
383
  id: 'years',
387
384
  name: 'YEARS',
388
385
  componentType: ['date'],
389
386
  };
390
387
  const PepSmartFilterOperatorUnits = {
391
- Days: Days$1,
392
- Weeks: Weeks$1,
393
- Months: Months$1,
394
- Years: Years$1,
388
+ Days: Days,
389
+ Weeks: Weeks,
390
+ Months: Months,
391
+ Years: Years,
395
392
  };
396
393
 
397
- class PepTypeConvertorService {
398
- constructor() {
399
- this._operators = [];
400
- this._booleans = [];
401
- this.initOperators();
402
- this.initBooleans();
403
- }
404
- get operators() {
405
- return this._operators;
406
- }
407
- get booleans() {
408
- return this._booleans;
409
- }
410
- initOperators() {
411
- this._operators.push({
412
- key: 'AND',
413
- value: 'And'
414
- });
415
- this._operators.push({
416
- key: 'OR',
417
- value: 'Or'
418
- });
419
- }
420
- initBooleans() {
421
- this._booleans.push({
422
- key: 'True',
423
- value: 'True'
424
- });
425
- this._booleans.push({
426
- key: 'False',
427
- value: 'False'
428
- });
429
- }
430
- }
431
- PepTypeConvertorService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PepTypeConvertorService_Factory() { return new PepTypeConvertorService(); }, token: PepTypeConvertorService, providedIn: "root" });
432
- PepTypeConvertorService.decorators = [
433
- { type: Injectable, args: [{
434
- providedIn: 'root',
435
- },] }
436
- ];
437
- PepTypeConvertorService.ctorParameters = () => [];
438
-
439
394
  class BaseFilterComponent {
440
- constructor(viewContainerRef, injector, resolver, builder, translate, validator, renderer, typeConvertorService) {
395
+ constructor(viewContainerRef, injector, resolver, builder, translate, validator, renderer) {
441
396
  this.viewContainerRef = viewContainerRef;
442
397
  this.injector = injector;
443
398
  this.resolver = resolver;
@@ -445,12 +400,7 @@ class BaseFilterComponent {
445
400
  this.translate = translate;
446
401
  this.validator = validator;
447
402
  this.renderer = renderer;
448
- this.typeConvertorService = typeConvertorService;
449
403
  this._fieldIdWithNoDots = '';
450
- this.emitOnChange = false;
451
- this.inline = false;
452
- this.showActionButtons = true;
453
- this.renderTitle = true;
454
404
  this.filterClear = new EventEmitter();
455
405
  this.filterChange = new EventEmitter();
456
406
  this.OPERATORS_TRANSLATION_PREFIX = 'SMART_FILTERS.OPERATORS';
@@ -472,10 +422,6 @@ class BaseFilterComponent {
472
422
  get filter() {
473
423
  return this._filter;
474
424
  }
475
- set parentForm(form) {
476
- this._parentForm = form;
477
- this.updateParentForm();
478
- }
479
425
  set operator(operator) {
480
426
  var _a;
481
427
  if ((operator === null || operator === void 0 ? void 0 : operator.id) != ((_a = this._operator) === null || _a === void 0 ? void 0 : _a.id)) {
@@ -496,7 +442,10 @@ class BaseFilterComponent {
496
442
  }
497
443
  set operatorUnit(operatorUnit) {
498
444
  // Validate operator unit
499
- if (operatorUnit) {
445
+ if (operatorUnit === undefined) {
446
+ this._operatorUnit = undefined;
447
+ }
448
+ else {
500
449
  const index = this.operatorUnits.findIndex((ou) => ou.id === operatorUnit.id);
501
450
  if (index >= 0) {
502
451
  this._operatorUnit = this.operatorUnits[index];
@@ -505,9 +454,6 @@ class BaseFilterComponent {
505
454
  this._operatorUnit = this.operatorUnits[0];
506
455
  }
507
456
  }
508
- else {
509
- this._operatorUnit = undefined;
510
- }
511
457
  }
512
458
  get operatorUnit() {
513
459
  return this._operatorUnit;
@@ -536,14 +482,12 @@ class BaseFilterComponent {
536
482
  const formValue = {};
537
483
  formValue[this.firstControlKey] = [];
538
484
  formValue[this.secondControlKey] = [];
539
- // this.form.patchValue(formValue);
485
+ // this.form.patchValue(formValue);
540
486
  this.form = this.builder.group(formValue);
541
487
  // this.form[this.firstControlKey] = [];
542
488
  // this.form[this.secondControlKey] = [];
543
489
  this.setupOperators();
544
- if (this.showActionButtons) {
545
- this.createActionsComponent();
546
- }
490
+ this.createActionsComponent();
547
491
  }
548
492
  setupOperators() {
549
493
  var _a, _b;
@@ -587,16 +531,6 @@ class BaseFilterComponent {
587
531
  this.clearFilter(false);
588
532
  }
589
533
  }
590
- updateParentForm() {
591
- this._parentForm.setControl('fieldId', this.builder.control(this.field.id));
592
- this._parentForm.setControl('fieldType', this.builder.control(this.field.type));
593
- this._parentForm.setControl('operator', this.builder.control(this.operator));
594
- this._parentForm.setControl('operatorUnit', this.builder.control(this.operatorUnit));
595
- this._parentForm.setControl('values', this.builder.group({
596
- first: this.firstControl,
597
- second: this.secondControl
598
- }));
599
- }
600
534
  getDestroyer() {
601
535
  return takeUntil(this._destroyed);
602
536
  }
@@ -660,9 +594,7 @@ class BaseFilterComponent {
660
594
  ngOnDestroy() {
661
595
  this._destroyed.next();
662
596
  this._destroyed.complete();
663
- if (this.showActionButtons) {
664
- this.actionsContainerRef.destroy();
665
- }
597
+ this.actionsContainerRef.destroy();
666
598
  }
667
599
  }
668
600
  BaseFilterComponent.decorators = [
@@ -675,98 +607,16 @@ BaseFilterComponent.ctorParameters = () => [
675
607
  { type: FormBuilder },
676
608
  { type: TranslateService },
677
609
  { type: PepValidatorService },
678
- { type: Renderer2 },
679
- { type: PepTypeConvertorService }
610
+ { type: Renderer2 }
680
611
  ];
681
612
  BaseFilterComponent.propDecorators = {
682
613
  field: [{ type: Input }],
683
614
  filter: [{ type: Input }],
684
- parentForm: [{ type: Input }],
685
- emitOnChange: [{ type: Input }],
686
- inline: [{ type: Input }],
687
- showActionButtons: [{ type: Input }],
688
- renderTitle: [{ type: Input }],
689
615
  filterClear: [{ type: Output }],
690
616
  filterChange: [{ type: Output }]
691
617
  };
692
618
 
693
- class PepTextFilterComponent extends BaseFilterComponent {
694
- constructor() {
695
- super(...arguments);
696
- this.chooseTypeOptions = [];
697
- this.operatorWidth = '38%';
698
- this.firstControlWidth = '62%';
699
- }
700
- ngOnInit() {
701
- this.firstControl.valueChanges
702
- .pipe(this.getDestroyer(), distinctUntilChanged())
703
- .subscribe(() => {
704
- this.setFieldsStateAndValidators();
705
- });
706
- }
707
- // Override
708
- getDefaultOperator() {
709
- return PepSmartFilterOperators.Equals;
710
- }
711
- // Override
712
- getFilterValue() {
713
- const filterValue = {
714
- first: this.firstControl.value,
715
- };
716
- if (this.operator === PepSmartFilterOperators.NumberRange) {
717
- filterValue['second'] = this.secondControl.value;
718
- }
719
- return filterValue;
720
- }
721
- // Override
722
- loadOperatorsOptions() {
723
- this.chooseTypeOptions = this.operators.map((operator) => {
724
- return {
725
- key: operator.id,
726
- value: this.translate.instant(`${this.OPERATORS_TRANSLATION_PREFIX}.${operator.name}`),
727
- };
728
- });
729
- }
730
- // Override
731
- setFieldsStateAndValidators() {
732
- if (this.operator === PepSmartFilterOperators.NumberRange) {
733
- const firstValidators = [Validators.required];
734
- if (this.secondControl.value) {
735
- firstValidators.push(this.validator.isLessThan(this.secondControl));
736
- }
737
- this.firstControl.setValidators(firstValidators);
738
- }
739
- else {
740
- super.setFieldsStateAndValidators();
741
- }
742
- }
743
- onOperatorChanged(value) {
744
- const operator = Object.values(PepSmartFilterOperators).find((operator) => operator.id === value);
745
- this.operator = operator;
746
- if (this._parentForm) {
747
- this.updateParentForm();
748
- }
749
- if (this.emitOnChange) {
750
- this.applyFilter();
751
- }
752
- }
753
- onValueChanged() {
754
- if (this.emitOnChange) {
755
- this.applyFilter();
756
- }
757
- }
758
- }
759
- PepTextFilterComponent.decorators = [
760
- { type: Component, args: [{
761
- selector: 'pep-text-filter',
762
- template: "<div [formGroup]=\"form\" [fxLayout]=\"inline ? 'row' : 'column'\" [fxLayoutGap]=\"inline ? '.5rem' : '0rem'\">\n <pep-select [fxFlex]=\"inline ? operatorWidth : null\" [key]=\"'typeOperator'\" [value]=\"operator.id\"\n [label]=\"'SMART_FILTERS.TYPE' | translate\" [renderTitle]=\"renderTitle\" [emptyOption]=\"false\"\n [options]=\"chooseTypeOptions\" (valueChange)=\"onOperatorChanged($event)\">\n </pep-select>\n <pep-textbox [fxFlex]=\"inline ? firstControlWidth : null\" [form]=\"form\" [key]=\"firstControlKey\"\n [label]=\"'SMART_FILTERS.AMOUNT' | translate\" [renderError]=\"false\" [renderTitle]=\"renderTitle\"\n [type]=\"field.type\" [formattedValue]=\"firstControl?.value || ''\" [value]=\"firstControl?.value || ''\"\n (valueChange)=\"onValueChanged()\">\n </pep-textbox>\n</div>",
763
- styles: [""]
764
- },] }
765
- ];
766
-
767
619
  class PepBooleanFilterComponent extends BaseFilterComponent {
768
- ngOnInit() {
769
- }
770
620
  // Override
771
621
  getDefaultOperator() {
772
622
  return PepSmartFilterOperators.Equals;
@@ -776,19 +626,11 @@ class PepBooleanFilterComponent extends BaseFilterComponent {
776
626
  const filterValue = { first: this.firstControl.value || false };
777
627
  return filterValue;
778
628
  }
779
- onRadioChanged() {
780
- }
781
- onValueChanged(value) {
782
- this.firstControl.setValue(value);
783
- if (this.emitOnChange) {
784
- this.applyFilter();
785
- }
786
- }
787
629
  }
788
630
  PepBooleanFilterComponent.decorators = [
789
631
  { type: Component, args: [{
790
632
  selector: 'pep-boolean-filter',
791
- template: "<ng-container *ngIf=\"inline\">\n <pep-select [value]=\"firstControl?.value || ''\" xAlignment=\"left\" [options]=\"typeConvertorService.booleans\"\n [renderTitle]=\"renderTitle\" [emptyOption]=\"true\" (valueChange)=\"onValueChanged($event)\">\n </pep-select>\n\n</ng-container>\n\n<div *ngIf=\"!inline\" [formGroup]=\"form\">\n <mat-radio-group class=\"radio-group\" [formControlName]=\"firstControlKey\" (change)=\"onRadioChanged()\">\n <mat-radio-button class=\"pep-radio-button md pep-input no-default-background\" value=\"true\">\n {{ 'CHECKBOX.TRUE' | translate }}\n </mat-radio-button>\n <mat-radio-button class=\"pep-radio-button md pep-input no-default-background\" value=\"false\">\n {{ 'CHECKBOX.FALSE' | translate }}\n </mat-radio-button>\n </mat-radio-group>\n</div>",
633
+ template: "<div [formGroup]=\"form\">\n <mat-radio-group class=\"radio-group\" [formControlName]=\"firstControlKey\">\n <mat-radio-button class=\"pep-radio-button md pep-input no-default-background\" value=\"true\">\n {{ 'CHECKBOX.TRUE' | translate }}\n </mat-radio-button>\n <mat-radio-button class=\"pep-radio-button md pep-input no-default-background\" value=\"false\">\n {{ 'CHECKBOX.FALSE' | translate }}\n </mat-radio-button>\n </mat-radio-group>\n</div>",
792
634
  styles: [".radio-group{display:flex;flex-direction:column}.radio-group .pep-radio-button.pep-input{height:2.25rem;display:flex}"]
793
635
  },] }
794
636
  ];
@@ -800,11 +642,6 @@ class PepDateFilterComponent extends BaseFilterComponent {
800
642
  this.chooseTimeOptions = [];
801
643
  this.chooseTimeUnitOptions = [];
802
644
  }
803
- ngOnInit() {
804
- if (this.inline) {
805
- this.setControlsWidth();
806
- }
807
- }
808
645
  // Override
809
646
  getDefaultOperator() {
810
647
  return PepSmartFilterOperators.InTheLast;
@@ -877,58 +714,20 @@ class PepDateFilterComponent extends BaseFilterComponent {
877
714
  super.setFieldsStateAndValidators();
878
715
  }
879
716
  }
880
- setControlsWidth() {
881
- if (this.operator === PepSmartFilterOperators.Today ||
882
- this.operator === PepSmartFilterOperators.ThisWeek ||
883
- this.operator === PepSmartFilterOperators.ThisMonth ||
884
- this.operator === PepSmartFilterOperators.IsEmpty ||
885
- this.operator === PepSmartFilterOperators.IsNotEmpty) {
886
- this.operatorWidth = 'auto';
887
- this.fieldsWidth = '0%';
888
- }
889
- else if (this.operator === PepSmartFilterOperators.On) {
890
- this.operatorWidth = '38%';
891
- this.fieldsWidth = '62%';
892
- }
893
- else {
894
- this.operatorWidth = '30%';
895
- this.fieldsWidth = '70%';
896
- }
897
- }
898
717
  onOperatorChanged(value) {
899
718
  const operator = Object.values(PepSmartFilterOperators).find((operator) => operator.id === value);
900
719
  this.operator = operator;
901
720
  this.operatorUnit = this.getDefaultOperatorUnit();
902
- if (this.inline) {
903
- this.setControlsWidth();
904
- }
905
- if (this._parentForm) {
906
- this.updateParentForm();
907
- }
908
- if (this.emitOnChange) {
909
- this.applyFilter();
910
- }
911
721
  }
912
722
  onTimeUnitChanged(value) {
913
723
  const operatorUnit = Object.values(PepSmartFilterOperatorUnits).find((operatorUnit) => operatorUnit.id === value);
914
724
  this.operatorUnit = operatorUnit;
915
- if (this._parentForm) {
916
- this.updateParentForm();
917
- }
918
- if (this.emitOnChange) {
919
- this.applyFilter();
920
- }
921
- }
922
- onDateValueChanged() {
923
- if (this.emitOnChange) {
924
- this.applyFilter();
925
- }
926
725
  }
927
726
  }
928
727
  PepDateFilterComponent.decorators = [
929
728
  { type: Component, args: [{
930
729
  selector: 'pep-date-filter',
931
- template: "<div [formGroup]=\"form\" [fxLayout]=\"inline ? 'row' : 'column'\" [fxLayoutGap]=\"inline ? '.5rem' : '0rem'\">\n <ng-container>\n <pep-select [key]=\"'timeOperator'\" [value]=\"operator.id\" [label]=\"'SMART_FILTERS.CHOOSE_TIME' | translate\"\n [renderTitle]=\"renderTitle\" [emptyOption]=\"false\" [options]=\"chooseTimeOptions\"\n [fxFlex]=\"inline ? operatorWidth : null\" (valueChange)=\"onOperatorChanged($event)\">\n </pep-select>\n </ng-container>\n <div *ngIf=\"operator === PepSmartFilterOperators.InTheLast ||\n operator === PepSmartFilterOperators.NotInTheLast ||\n operator === PepSmartFilterOperators.DueIn ||\n operator === PepSmartFilterOperators.NotDueIn\" fxLayout=\"row\" fxLayout.xs=\"column\"\n [fxLayoutGap]=\"inline ? '.5rem' : '1rem'\" [fxFlex]=\"inline ? fieldsWidth : null\">\n <!-- Amount -->\n <pep-textbox [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.AMOUNT' | translate\"\n [renderError]=\"false\" [renderTitle]=\"renderTitle\" fxFlex=\"50%\" [type]=\"'int'\"\n [formattedValue]=\"firstControl?.value || ''\" [value]=\"firstControl?.value || ''\"\n (valueChange)=\"onDateValueChanged()\">\n </pep-textbox>\n <!-- Time unit -->\n <pep-select [form]=\"form\" [key]=\"'timeUnit'\" [value]=\"operatorUnit?.id\"\n [label]=\"'SMART_FILTERS.TIME_UNIT' | translate\" [renderTitle]=\"renderTitle\" fxFlex=\"50%\"\n [emptyOption]=\"false\" [options]=\"chooseTimeUnitOptions\" (valueChange)=\"onTimeUnitChanged($event)\">\n </pep-select>\n </div>\n <div pepRtlDirection *ngIf=\"operator === PepSmartFilterOperators.DateRange\" fxLayout=\"row\" fxLayout.xs=\"column\"\n [fxLayoutGap]=\"inline ? '.5rem' : '1rem'\" [fxFlex]=\"inline ? fieldsWidth : null\">\n <!-- Start date -->\n <pep-date [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.START_DATE' | translate\"\n [renderError]=\"false\" [renderTitle]=\"renderTitle\" fxFlex=\"50%\"\n [type]=\"field.type === 'date' ? 'date' : 'datetime'\" [value]=\"firstControl?.value || ''\"\n [maxDateValue]=\"secondControl?.value\" (valueChange)=\"onDateValueChanged()\">\n </pep-date>\n <!-- End date -->\n <pep-date [form]=\"form\" [key]=\"secondControlKey\" [label]=\"'SMART_FILTERS.END_DATE' | translate\"\n [renderError]=\"false\" [renderTitle]=\"renderTitle\" fxFlex=\"50%\"\n [type]=\"field.type === 'date' ? 'date' : 'datetime'\" [value]=\"secondControl?.value || ''\"\n [minDateValue]=\"firstControl?.value\" (valueChange)=\"onDateValueChanged()\">\n </pep-date>\n </div>\n <ng-container *ngIf=\"operator === PepSmartFilterOperators.On\">\n <!-- Choose a date -->\n <pep-date [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.CHOOSE_DATE' | translate\"\n [renderError]=\"false\" [renderTitle]=\"renderTitle\" [type]=\"field.type === 'date' ? 'date' : 'datetime'\"\n [fxFlex]=\"inline ? fieldsWidth : null\" [value]=\"firstControl?.value || ''\"\n (valueChange)=\"onDateValueChanged()\">\n </pep-date>\n </ng-container>\n</div>",
730
+ template: "<div [formGroup]=\"form\">\n <ng-container>\n <pep-select [key]=\"'timeOperator'\" [value]=\"operator.id\" [label]=\"'SMART_FILTERS.CHOOSE_TIME' | translate\"\n [emptyOption]=\"false\" [options]=\"chooseTimeOptions\" (valueChange)=\"onOperatorChanged($event)\">\n </pep-select>\n </ng-container>\n\n <div *ngIf=\"operator === PepSmartFilterOperators.InTheLast ||\n operator === PepSmartFilterOperators.NotInTheLast ||\n operator === PepSmartFilterOperators.DueIn ||\n operator === PepSmartFilterOperators.NotDueIn\" fxLayout=\"row\" fxLayout.xs=\"column\" fxLayoutGap=\"1rem\">\n <!-- Amount -->\n <pep-textbox [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.AMOUNT' | translate\"\n [renderError]=\"false\" fxFlex=\"50%\" [type]=\"'int'\" [formattedValue]=\"firstControl.value\"\n [value]=\"firstControl.value\">\n </pep-textbox>\n <!-- Time unit -->\n <pep-select [form]=\"form\" [key]=\"'timeUnit'\" [value]=\"operatorUnit?.id\"\n [label]=\"'SMART_FILTERS.TIME_UNIT' | translate\" fxFlex=\"50%\" [emptyOption]=\"false\"\n [options]=\"chooseTimeUnitOptions\" (valueChange)=\"onTimeUnitChanged($event)\">\n </pep-select>\n </div>\n <div pepRtlDirection *ngIf=\"operator === PepSmartFilterOperators.DateRange\" fxLayout=\"row\" fxLayout.xs=\"column\"\n fxLayoutGap=\"1rem\">\n <!-- Start date -->\n <pep-date [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.START_DATE' | translate\"\n [renderError]=\"false\" fxFlex=\"50%\" [type]=\"field.type === 'date' ? 'date' : 'datetime'\"\n [value]=\"firstControl.value\" [maxDateValue]=\"secondControl.value\">\n </pep-date>\n <!-- End date -->\n <pep-date [form]=\"form\" [key]=\"secondControlKey\" [label]=\"'SMART_FILTERS.END_DATE' | translate\"\n [renderError]=\"false\" fxFlex=\"50%\" [type]=\"field.type === 'date' ? 'date' : 'datetime'\"\n [value]=\"secondControl.value\" [minDateValue]=\"firstControl.value\">\n </pep-date>\n </div>\n <ng-container *ngIf=\"operator === PepSmartFilterOperators.On\">\n <!-- Choose a date -->\n <pep-date [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.CHOOSE_DATE' | translate\"\n [renderError]=\"false\" [type]=\"field.type === 'date' ? 'date' : 'datetime'\" [value]=\"firstControl.value\">\n </pep-date>\n </ng-container>\n</div>",
932
731
  styles: [""]
933
732
  },] }
934
733
  ];
@@ -943,36 +742,12 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
943
742
  super(...arguments);
944
743
  this.options = [];
945
744
  this.searchControl = new FormControl();
946
- //inline props
947
- this.selected = '';
948
- this.inlineOptions = [];
949
745
  this.MAX_OPTIONS_TO_SHOW = 6.35;
950
746
  this.numberOptionsToShowSearch = 10;
951
747
  }
952
748
  ngOnInit() {
953
- super.ngOnInit;
954
- if (this.inline) {
955
- this.inlineControlInit();
956
- }
957
- else {
958
- this.noneInlineControlInit();
959
- }
960
- }
961
- ngAfterViewInit() {
962
- // Calc for the first time.
963
- this.calcOptionsHeight(this.options.length);
964
- }
965
- inlineControlInit() {
966
- var _a, _b, _c, _d;
967
- //load options from field
968
- this.inlineOptions = ((_b = (_a = this.field) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.length) > 0 ? this.field.options : [];
969
- // Init the selected values from first value.
970
- if (((_d = (_c = this.firstControl) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.length) > 0) {
971
- this.selected = this.firstControl.value.join(';');
972
- }
973
- }
974
- noneInlineControlInit() {
975
749
  var _a;
750
+ super.ngOnInit;
976
751
  if (((_a = this.field.options) === null || _a === void 0 ? void 0 : _a.length) > 0) {
977
752
  this.options = this.field.options.map((opt) => {
978
753
  return { value: opt.value, count: opt.count, selected: false };
@@ -1003,6 +778,10 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
1003
778
  }, 125);
1004
779
  });
1005
780
  }
781
+ ngAfterViewInit() {
782
+ // Calc for the first time.
783
+ this.calcOptionsHeight(this.options.length);
784
+ }
1006
785
  initOptionsSelectedValues(selectedValues) {
1007
786
  this.options.forEach((opt) => {
1008
787
  const isValueSelected = selectedValues && selectedValues.includes(opt.value);
@@ -1030,20 +809,13 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
1030
809
  }
1031
810
  // Override
1032
811
  getFilterValue() {
1033
- if (this.inline) {
1034
- return {
1035
- first: this.firstControl.value
1036
- };
1037
- }
1038
- else {
1039
- const selectedValues = this.options
1040
- .filter((opt) => opt.selected)
1041
- .map((opt) => opt.value);
1042
- const filterValue = {
1043
- first: selectedValues,
1044
- };
1045
- return selectedValues.length > 0 ? filterValue : null;
1046
- }
812
+ const selectedValues = this.options
813
+ .filter((opt) => opt.selected)
814
+ .map((opt) => opt.value);
815
+ const filterValue = {
816
+ first: selectedValues,
817
+ };
818
+ return selectedValues.length > 0 ? filterValue : null;
1047
819
  }
1048
820
  // Override
1049
821
  initFilter() {
@@ -1054,23 +826,11 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
1054
826
  option.selected = event.checked;
1055
827
  this.firstControl.setValue(this.options.filter((opt) => opt.selected).map((opt) => opt.value), { emitEvent: false });
1056
828
  }
1057
- onMultiSelectChanged(value) {
1058
- if (value) {
1059
- const selected = value.split(';');
1060
- this.firstControl.setValue(selected);
1061
- }
1062
- else {
1063
- this.firstControl.setValue(null);
1064
- }
1065
- if (this.emitOnChange) {
1066
- this.applyFilter();
1067
- }
1068
- }
1069
829
  }
1070
830
  PepMultiSelectFilterComponent.decorators = [
1071
831
  { type: Component, args: [{
1072
832
  selector: 'pep-multi-select-filter',
1073
- template: "<ng-container *ngIf=\"inline\">\n <pep-select [key]=\"'multi1'\" [label]=\"'Pepperi Multi Select'\" [type]=\"'multi'\" [value]=\"selected\"\n [xAlignment]=\"'left'\" [renderTitle]=\"renderTitle\" [options]='inlineOptions'\n (valueChange)=\"onMultiSelectChanged($event)\">\n </pep-select>\n</ng-container>\n<div *ngIf=\"!inline\" [formGroup]=\"form\">\n <pep-search *ngIf=\"options?.length > numberOptionsToShowSearch\" [searchControl]=\"searchControl\"\n [triggerOn]=\"'keydown'\" [shrinkInSmallScreen]=\"false\"></pep-search>\n <div pepRtlClass class=\"multi-select-options pep-border-top pep-border-bottom\"\n [ngClass]=\"{'with-no-search': options?.length <= numberOptionsToShowSearch}\">\n <div #optionsContainer class=\"flip-scroll\" pepRtlClass>\n <virtual-scroller #scroll [items]=\"filteredOptions$ | async\" [parentScroll]=\"optionsContainer\">\n <mat-checkbox *ngFor=\"let opt of scroll.viewPortItems\"\n class=\"pep-checkbox-container pep-input no-default-background md\" [title]=\"opt.value\"\n [checked]=\"opt.selected\" (change)=\"onOptionChange(opt, $event)\">\n <div class=\"title\">\n <span class=\"body-sm ellipsis\">{{ opt.value }}</span>\n <span *ngIf=\"opt.count\" class=\"color-dimmed body-xs ellipsis\">({{opt.count}})</span>\n </div>\n </mat-checkbox>\n <ng-container *ngIf=\"scroll.viewPortItems?.length === 0\">\n <span class=\"no-options body-sm ellipsis\" [title]=\"field.name\">\n {{ ( options.length > 0 ? \"SMART_FILTERS.NO_SEARCH_RESULTS\" : \"SMART_FILTERS.NO_OPTIONS\") |\n translate }}\n </span>\n </ng-container>\n </virtual-scroller>\n </div>\n </div>\n</div>",
833
+ template: "<div [formGroup]=\"form\">\n <pep-search *ngIf=\"options?.length > numberOptionsToShowSearch\" [searchControl]=\"searchControl\"\n [triggerOn]=\"'keydown'\" [shrinkInSmallScreen]=\"false\"></pep-search>\n <div pepRtlClass class=\"multi-select-options pep-border-top pep-border-bottom\"\n [ngClass]=\"{'with-no-search': options?.length <= numberOptionsToShowSearch}\">\n <div #optionsContainer class=\"flip-scroll\" pepRtlClass>\n <virtual-scroller #scroll [items]=\"filteredOptions$ | async\" [parentScroll]=\"optionsContainer\">\n <mat-checkbox *ngFor=\"let opt of scroll.viewPortItems\"\n class=\"pep-checkbox-container pep-input no-default-background md\" [title]=\"opt.value\"\n [checked]=\"opt.selected\" (change)=\"onOptionChange(opt, $event)\">\n <div class=\"title\">\n <span class=\"body-sm ellipsis\">{{ opt.value }}</span>\n <span *ngIf=\"opt.count\" class=\"color-dimmed body-xs ellipsis\">({{opt.count}})</span>\n </div>\n </mat-checkbox>\n <ng-container *ngIf=\"scroll.viewPortItems?.length === 0\">\n <span class=\"no-options body-sm ellipsis\" [title]=\"field.name\">\n {{ ( options.length > 0 ? \"SMART_FILTERS.NO_SEARCH_RESULTS\" : \"SMART_FILTERS.NO_OPTIONS\") |\n translate }}\n </span>\n </ng-container>\n </virtual-scroller>\n </div>\n </div>\n</div>",
1074
834
  styles: [".multi-select-options{margin:.5rem calc(.25rem * -1) 0;margin:var(--pep-spacing-sm,.5rem) calc(var(--pep-spacing-xs, .25rem) * -1) 0}.multi-select-options.with-no-search{margin:calc(.5rem * -1) calc(.25rem * -1) 0;margin:calc(var(--pep-spacing-sm, .5rem) * -1) calc(var(--pep-spacing-xs, .25rem) * -1) 0}.multi-select-options .no-options{display:flex;padding:.5rem .75rem;padding:var(--pep-spacing-sm,.5rem) var(--pep-spacing-md,.75rem)}.multi-select-options .flip-scroll{padding:.5rem .25rem;padding:var(--pep-spacing-sm,.5rem) var(--pep-spacing-xs,.25rem);min-height:3.25rem;max-height:34.75rem;direction:rtl}.multi-select-options .flip-scroll.rtl,.multi-select-options .flip-scroll virtual-scroller{direction:ltr}.multi-select-options .flip-scroll.rtl virtual-scroller{direction:rtl}.multi-select-options .pep-checkbox-container{height:2.25rem;-webkit-padding-end:0;padding-inline-end:0}.multi-select-options .pep-checkbox-container ::ng-deep.mat-checkbox-layout{width:100%;height:100%;grid-template-columns:auto 1fr}.multi-select-options .pep-checkbox-container ::ng-deep.mat-checkbox-layout .mat-checkbox-label{align-self:center}.multi-select-options .pep-checkbox-container .title{display:flex;justify-content:space-between;align-items:center;margin:0 .25rem;margin:0 var(--pep-spacing-xs,.25rem)}"]
1075
835
  },] }
1076
836
  ];
@@ -1084,8 +844,6 @@ class PepNumberFilterComponent extends BaseFilterComponent {
1084
844
  super(...arguments);
1085
845
  this.PepSmartFilterOperators = PepSmartFilterOperators;
1086
846
  this.chooseTypeOptions = [];
1087
- this.operatorWidth = '38%';
1088
- this.firstControlWidth = '62%';
1089
847
  }
1090
848
  ngOnInit() {
1091
849
  this.firstControl.valueChanges
@@ -1098,7 +856,6 @@ class PepNumberFilterComponent extends BaseFilterComponent {
1098
856
  .subscribe(() => {
1099
857
  this.setFieldsStateAndValidators();
1100
858
  });
1101
- this.setControlsWidth();
1102
859
  }
1103
860
  // Override
1104
861
  getDefaultOperator() {
@@ -1142,39 +899,70 @@ class PepNumberFilterComponent extends BaseFilterComponent {
1142
899
  super.setFieldsStateAndValidators();
1143
900
  }
1144
901
  }
1145
- setControlsWidth() {
1146
- if (this.operator === PepSmartFilterOperators.NumberRange) {
1147
- this.operatorWidth = '30%';
1148
- }
1149
- else {
1150
- this.operatorWidth = '38%';
1151
- }
1152
- }
1153
902
  onOperatorChanged(value) {
1154
903
  const operator = Object.values(PepSmartFilterOperators).find((operator) => operator.id === value);
1155
904
  this.operator = operator;
1156
- if (this._parentForm) {
1157
- this.updateParentForm();
1158
- }
1159
- if (this.emitOnChange) {
1160
- this.applyFilter();
1161
- }
1162
- this.setControlsWidth();
1163
- }
1164
- onValueChanged() {
1165
- if (this.emitOnChange) {
1166
- this.applyFilter();
1167
- }
1168
905
  }
1169
906
  }
1170
907
  PepNumberFilterComponent.decorators = [
1171
908
  { type: Component, args: [{
1172
909
  selector: 'pep-number-filter',
1173
- template: "<div [formGroup]=\"form\" [fxLayout]=\"inline ? 'row' : 'column'\" [fxLayoutGap]=\"inline ? '.5rem' : '0rem'\">\n <ng-container>\n <pep-select [fxFlex]=\"inline ? operatorWidth : null\" [key]=\"'typeOperator'\" [value]=\"operator.id\"\n [label]=\"'SMART_FILTERS.TYPE' | translate\" [renderTitle]=\"renderTitle\" [emptyOption]=\"false\"\n [options]=\"chooseTypeOptions\" (valueChange)=\"onOperatorChanged($event)\">\n </pep-select>\n </ng-container>\n <div *ngIf=\"operator !== PepSmartFilterOperators.NumberRange\" [fxFlex]=\"inline ? firstControlWidth : null\">\n <!-- Amount -->\n <pep-textbox [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.AMOUNT' | translate\"\n [renderError]=\"false\" [renderTitle]=\"renderTitle\" [type]=\"field.type\"\n [formattedValue]=\"firstControl?.value || ''\" [value]=\"firstControl?.value || ''\"\n (valueChange)=\"onValueChanged()\">\n </pep-textbox>\n </div>\n <div *ngIf=\"operator === PepSmartFilterOperators.NumberRange\" fxLayout=\"row\" fxLayout.xs=\"column\"\n [fxLayoutGap]=\"inline ? '.5rem' : '1rem'\">\n <!-- Min number -->\n <pep-textbox [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.MIN' | translate\"\n [renderError]=\"false\" [renderTitle]=\"renderTitle\" [type]=\"field.type\" fxFlex=\"50%\"\n [formattedValue]=\"firstControl?.value || ''\" [value]=\"firstControl?.value || ''\"\n [maxValue]=\"secondControl?.value || ''\" (valueChange)=\"onValueChanged()\">\n </pep-textbox>\n <!-- Max number -->\n <pep-textbox [form]=\"form\" [key]=\"secondControlKey\" [label]=\"'SMART_FILTERS.MAX' | translate\"\n [renderError]=\"false\" [renderTitle]=\"renderTitle\" [type]=\"field.type\" fxFlex=\"50%\"\n [formattedValue]=\"secondControl?.value || ''\" [value]=\"secondControl?.value || ''\"\n [minValue]=\"firstControl?.value || ''\" (valueChange)=\"onValueChanged()\">\n </pep-textbox>\n </div>\n</div>",
910
+ template: "<div [formGroup]=\"form\">\n <ng-container>\n <pep-select [key]=\"'typeOperator'\" [value]=\"operator.id\" [label]=\"'SMART_FILTERS.TYPE' | translate\"\n [emptyOption]=\"false\" [options]=\"chooseTypeOptions\" (valueChange)=\"onOperatorChanged($event)\">\n </pep-select>\n </ng-container>\n <div *ngIf=\"operator !== PepSmartFilterOperators.NumberRange\">\n <!-- Amount -->\n <pep-textbox [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.AMOUNT' | translate\"\n [renderError]=\"false\" [type]=\"field.type\" [formattedValue]=\"firstControl.value\"\n [value]=\"firstControl.value\">\n </pep-textbox>\n </div>\n <div *ngIf=\"operator === PepSmartFilterOperators.NumberRange\" fxLayout=\"row\" fxLayout.xs=\"column\"\n fxLayoutGap=\"1rem\">\n <!-- Min number -->\n <pep-textbox [form]=\"form\" [key]=\"firstControlKey\" [label]=\"'SMART_FILTERS.MIN' | translate\"\n [renderError]=\"false\" fxFlex=\"50%\" [type]=\"field.type\" [formattedValue]=\"firstControl.value\"\n [value]=\"firstControl.value\" [maxValue]=\"secondControl.value\">\n </pep-textbox>\n <!-- Max number -->\n <pep-textbox [form]=\"form\" [key]=\"secondControlKey\" [label]=\"'SMART_FILTERS.MAX' | translate\"\n [renderError]=\"false\" fxFlex=\"50%\" [type]=\"field.type\" [formattedValue]=\"secondControl.value\"\n [value]=\"secondControl.value\" [minValue]=\"firstControl.value\">\n </pep-textbox>\n </div>\n</div>",
1174
911
  styles: [""]
1175
912
  },] }
1176
913
  ];
1177
914
 
915
+ class PepSmartFiltersModule {
916
+ constructor(pepIconRegistry) {
917
+ this.pepIconRegistry = pepIconRegistry;
918
+ this.pepIconRegistry.registerIcons([
919
+ pepIconNumberMinus,
920
+ pepIconNumberPlus,
921
+ ]);
922
+ }
923
+ }
924
+ PepSmartFiltersModule.decorators = [
925
+ { type: NgModule, args: [{
926
+ imports: [
927
+ CommonModule,
928
+ ReactiveFormsModule,
929
+ FlexLayoutModule,
930
+ // Material modules
931
+ MatCommonModule,
932
+ MatCheckboxModule,
933
+ MatChipsModule,
934
+ MatExpansionModule,
935
+ MatIconModule,
936
+ MatFormFieldModule,
937
+ MatInputModule,
938
+ MatRadioModule,
939
+ // External modules
940
+ VirtualScrollerModule,
941
+ // ngx-lib modules
942
+ PepNgxLibModule,
943
+ PepCheckboxModule,
944
+ PepDateModule,
945
+ PepSelectModule,
946
+ PepTextboxModule,
947
+ PepSearchModule,
948
+ PepIconModule,
949
+ ],
950
+ exports: [PepSmartFiltersComponent],
951
+ declarations: [
952
+ // BaseFilterComponent,
953
+ PepSmartFiltersComponent,
954
+ PepFilterActionsComponent,
955
+ PepBooleanFilterComponent,
956
+ PepDateFilterComponent,
957
+ PepMultiSelectFilterComponent,
958
+ PepNumberFilterComponent,
959
+ ],
960
+ },] }
961
+ ];
962
+ PepSmartFiltersModule.ctorParameters = () => [
963
+ { type: PepIconRegistry }
964
+ ];
965
+
1178
966
  // Base field
1179
967
  // ------------------------------
1180
968
  class PepSmartFilterBaseField {
@@ -1194,17 +982,6 @@ class PepSmartFilterBaseField {
1194
982
  return this._type;
1195
983
  }
1196
984
  }
1197
- // Text field
1198
- // ------------------------------
1199
- class PepSmartFilterTextField extends PepSmartFilterBaseField {
1200
- constructor(field) {
1201
- super(field);
1202
- this._componentType = 'text';
1203
- }
1204
- getType() {
1205
- return 'text';
1206
- }
1207
- }
1208
985
  // Boolean field
1209
986
  // ------------------------------
1210
987
  class PepSmartFilterBooleanField extends PepSmartFilterBaseField {
@@ -1292,9 +1069,6 @@ class PepSmartFilterPercentageField extends PepSmartFilterNumberBaseField {
1292
1069
  }
1293
1070
  }
1294
1071
 
1295
- function createTextSmartFilterField(data) {
1296
- return new PepSmartFilterTextField(data);
1297
- }
1298
1072
  function createBooleanSmartFilterField(data) {
1299
1073
  return new PepSmartFilterBooleanField(data);
1300
1074
  }
@@ -1322,9 +1096,6 @@ function createPercentageSmartFilterField(data) {
1322
1096
  function createSmartFilterField(data, type) {
1323
1097
  let field;
1324
1098
  switch (type) {
1325
- case 'text':
1326
- field = createTextSmartFilterField(data);
1327
- break;
1328
1099
  case 'boolean':
1329
1100
  field = createBooleanSmartFilterField(data);
1330
1101
  break;
@@ -1367,942 +1138,6 @@ function createSmartFilter(fieldId, operator, first, second, operatorUnit) {
1367
1138
  };
1368
1139
  }
1369
1140
 
1370
- const Equals = {
1371
- legacy: 'IsEqual',
1372
- smartFilter: PepSmartFilterOperators.Equals,
1373
- type: ['boolean', 'int', 'text']
1374
- };
1375
- const NotEqual = {
1376
- legacy: 'IsNotEqual',
1377
- smartFilter: PepSmartFilterOperators.NotEqual,
1378
- type: null
1379
- };
1380
- const LessThan = {
1381
- legacy: '<',
1382
- smartFilter: PepSmartFilterOperators.LessThan,
1383
- type: null
1384
- };
1385
- const GreaterThan = {
1386
- legacy: '>',
1387
- smartFilter: PepSmartFilterOperators.GreaterThan,
1388
- type: null
1389
- };
1390
- /*
1391
- const GreaterThanOrEquals: IPepFilterBuilderOperator = {
1392
- legacy: {
1393
- operator: '>=',
1394
- type: 'Integer'
1395
- },
1396
- smartFilter: {
1397
- item: PepSmartFilterOperators.GreaterThanOrEquals,
1398
- type: 'int'
1399
- }
1400
- };
1401
-
1402
- const LessThanOrEquals: IPepFilterBuilderOperator = {
1403
- legacy: {
1404
- operator: '<=',
1405
- type: 'Integer'
1406
- },
1407
- smartFilter: {
1408
- item: PepSmartFilterOperators.LessThanOrEquals,
1409
- type: 'int',
1410
- type: 'Integer'
1411
- }
1412
- }; */
1413
- const NumberRange = {
1414
- legacy: 'Between',
1415
- smartFilter: PepSmartFilterOperators.NumberRange,
1416
- type: ['int']
1417
- };
1418
- const Contains = {
1419
- legacy: 'Contains',
1420
- smartFilter: PepSmartFilterOperators.Contains,
1421
- type: null
1422
- };
1423
- /*
1424
- const BeginsWith: IPepFilterBuilderOperator = {
1425
- legacy: {
1426
- operator: 'BeginsWith',
1427
- type: 'String'
1428
- },
1429
- smartFilter: {
1430
- item: PepSmartFilterOperators.BeginsWith,
1431
- type: 'text'
1432
- }
1433
- };
1434
-
1435
- const EndsWith: IPepFilterBuilderOperator = {
1436
- legacy: {
1437
- operator: 'EndsWith',
1438
- type: 'String'
1439
- },
1440
- smartFilter: {
1441
- item: PepSmartFilterOperators.EndsWith,
1442
- type: 'text'
1443
- }
1444
- };
1445
-
1446
- const Before: IPepFilterBuilderOperator = {
1447
- legacy: {
1448
- operator: 'Before',
1449
- type: 'Date'
1450
- },
1451
- smartFilter: {
1452
- item: PepSmartFilterOperators.Before,
1453
- type: 'date'
1454
- }
1455
- };
1456
-
1457
- const After: IPepFilterBuilderOperator = {
1458
- legacy: {
1459
- operator: 'After',
1460
- type: 'Date'
1461
- },
1462
- smartFilter: {
1463
- item: PepSmartFilterOperators.After,
1464
- type: 'date'
1465
- }
1466
- }; */
1467
- const InTheLast = {
1468
- legacy: 'InTheLast',
1469
- smartFilter: PepSmartFilterOperators.InTheLast,
1470
- type: null
1471
- };
1472
- const NotInTheLast = {
1473
- legacy: 'NotInTheLast',
1474
- smartFilter: PepSmartFilterOperators.NotInTheLast,
1475
- type: null
1476
- };
1477
- const Today = {
1478
- legacy: 'Today',
1479
- smartFilter: PepSmartFilterOperators.Today,
1480
- type: null
1481
- };
1482
- const ThisWeek = {
1483
- legacy: 'ThisWeek',
1484
- smartFilter: PepSmartFilterOperators.ThisWeek,
1485
- type: null
1486
- };
1487
- const ThisMonth = {
1488
- legacy: 'ThisMonth',
1489
- smartFilter: PepSmartFilterOperators.ThisMonth,
1490
- type: null
1491
- };
1492
- const DateRange = {
1493
- legacy: 'Between',
1494
- smartFilter: PepSmartFilterOperators.DateRange,
1495
- type: ['date-time']
1496
- };
1497
- const DueIn = {
1498
- legacy: 'DueIn',
1499
- smartFilter: PepSmartFilterOperators.DueIn,
1500
- type: null
1501
- };
1502
- const NotDueIn = {
1503
- legacy: 'NotDueIn',
1504
- smartFilter: PepSmartFilterOperators.NotDueIn,
1505
- type: null
1506
- };
1507
- const On = {
1508
- legacy: 'On',
1509
- smartFilter: PepSmartFilterOperators.On,
1510
- type: null
1511
- };
1512
- const IsEmpty = {
1513
- legacy: 'IsEmpty',
1514
- smartFilter: PepSmartFilterOperators.IsEmpty,
1515
- type: null
1516
- };
1517
- const IsNotEmpty = {
1518
- legacy: 'IsNotEmpty',
1519
- smartFilter: PepSmartFilterOperators.IsNotEmpty,
1520
- type: null
1521
- };
1522
- const In = {
1523
- legacy: 'IsEqual',
1524
- smartFilter: PepSmartFilterOperators.In,
1525
- type: ['multi-select']
1526
- };
1527
- const PepFilterBuilderOperators = [
1528
- Equals,
1529
- NotEqual,
1530
- LessThan,
1531
- // LessThanOrEquals,
1532
- GreaterThan,
1533
- // GreaterThanOrEquals,
1534
- NumberRange,
1535
- Contains,
1536
- // BeginsWith,
1537
- // EndsWith,
1538
- // After,
1539
- // Before,
1540
- InTheLast,
1541
- NotInTheLast,
1542
- Today,
1543
- ThisWeek,
1544
- ThisMonth,
1545
- DateRange,
1546
- DueIn,
1547
- NotDueIn,
1548
- On,
1549
- IsEmpty,
1550
- IsNotEmpty,
1551
- In
1552
- ];
1553
- /**
1554
- * gets a smart filter operator item
1555
- * @param operator legacy operator
1556
- * @param type smart filter's type
1557
- * @returns smart filter operator item
1558
- */
1559
- function getSmartBuilderOperator(operator, type) {
1560
- const smartFilterOperator = PepFilterBuilderOperators.find(item => item.legacy === operator &&
1561
- (item.type === null || item.type.includes(type)));
1562
- return smartFilterOperator ? smartFilterOperator.smartFilter : null;
1563
- }
1564
- /**
1565
- * gets a legacy operator value
1566
- * @param operator smart filter operator item
1567
- * @param type smart filter's type
1568
- * @returns legacy operator value
1569
- */
1570
- function getLegacyOperator(operator, type) {
1571
- const legacyOperator = PepFilterBuilderOperators.find(item => item.smartFilter === operator &&
1572
- (item.type === null || item.type.includes(type)));
1573
- return legacyOperator ? legacyOperator.legacy : null;
1574
- }
1575
-
1576
- var PepOperatorTypes;
1577
- (function (PepOperatorTypes) {
1578
- PepOperatorTypes["And"] = "AND";
1579
- PepOperatorTypes["Or"] = "OR";
1580
- })(PepOperatorTypes || (PepOperatorTypes = {}));
1581
-
1582
- class FilterBuilderSectionComponent {
1583
- constructor(filterBuilderService, typeConvertorService) {
1584
- this.filterBuilderService = filterBuilderService;
1585
- this.typeConvertorService = typeConvertorService;
1586
- this.remove = new EventEmitter();
1587
- this.operatorChange = new EventEmitter();
1588
- }
1589
- ngOnInit() {
1590
- }
1591
- get f() {
1592
- return this.form.controls;
1593
- }
1594
- onOperatorChanged(value) {
1595
- this.f.operator.setValue(value);
1596
- this.operatorChange.emit();
1597
- }
1598
- onAddRuleClicked() {
1599
- this.filterBuilderService.createItem(null, this.sectionContainer, this.form);
1600
- }
1601
- onAddRuleSetClicked() {
1602
- const result = this.filterBuilderService.createSection(PepOperatorTypes.And, this.sectionContainer, this.form, this.depth + 1);
1603
- this.filterBuilderService.createItem(null, result.containerRef, result.parentForm);
1604
- }
1605
- onDeleteSectionClicked() {
1606
- this.remove.emit();
1607
- }
1608
- }
1609
- FilterBuilderSectionComponent.decorators = [
1610
- { type: Component, args: [{
1611
- selector: 'pep-filter-builder-section',
1612
- template: "<div fxLayout=\"row\" fxLayoutGap=\".5rem\">\n <div class=\"filter-section-container\" fxLayout=\"row\" fxLayoutAlign=\"flex-start start\" fxLayoutGap=\".5rem\">\n <pep-select fxFlex=\"11\" [value]=\"f.operator.value\" xAlignment=\"left\" [options]=\"typeConvertorService.operators\"\n [renderTitle]=\"false\" [emptyOption]=false (valueChange)=\"onOperatorChanged($event)\">\n </pep-select>\n <div fxFlex=\"89\" class=\"filter-section-wrapper\" fxLayout=\"column\" fxLayoutGap=\".5rem\">\n <ng-container #sectionContainer></ng-container>\n <div fxLayout=\"row\" fxLayoutGap=\".5rem\">\n <pep-button value=\"Add Filter\" styleType=\"weak\" styleStateType=\"system\" sizeType=\"sm\" classNames=\"\"\n [disabled]=\"false\" iconName=\"number_plus\" iconPosition=\"end\" [visible]=\"true\"\n (buttonClick)=\"onAddRuleClicked()\"></pep-button>\n <ng-container *ngIf=\"depth < filterBuilderService.maxDepth-1\">\n <pep-button value=\"Add Filter Group\" styleType=\"weak\" styleStateType=\"system\" sizeType=\"sm\"\n classNames=\"\" [disabled]=\"false\" iconName=\"number_plus\" iconPosition=\"end\" [visible]=\"true\"\n (buttonClick)=\"onAddRuleSetClicked()\"></pep-button>\n </ng-container>\n </div>\n </div>\n </div>\n <pep-button *ngIf=\"depth > 0\" styleType=\"weak\" styleStateType=\"system_bin\" sizeType=\"md\" classNames=\"\"\n [disabled]=\"false\" iconName=\"system_bin\" iconPosition=\"end\" [visible]=\"true\"\n (buttonClick)=\"onDeleteSectionClicked()\">\n </pep-button>\n</div>",
1613
- styles: [".filter-section-wrapper{width:100%}.filter-section-container{border-radius:.25rem;border-radius:var(--pep-border-radius-md,.25rem);padding:.5rem;width:100%}"]
1614
- },] }
1615
- ];
1616
- FilterBuilderSectionComponent.ctorParameters = () => [
1617
- { type: FilterBuilderService },
1618
- { type: PepTypeConvertorService }
1619
- ];
1620
- FilterBuilderSectionComponent.propDecorators = {
1621
- form: [{ type: Input }],
1622
- depth: [{ type: Input }],
1623
- remove: [{ type: Output }],
1624
- operatorChange: [{ type: Output }],
1625
- sectionContainer: [{ type: ViewChild, args: ['sectionContainer', { read: ViewContainerRef, static: true },] }]
1626
- };
1627
-
1628
- class FilterBuilderItemComponent {
1629
- constructor(_fb) {
1630
- this._fb = _fb;
1631
- this._fields = [];
1632
- this._options = [];
1633
- this._selectedField = null;
1634
- this.filterChange = new EventEmitter();
1635
- this.remove = new EventEmitter();
1636
- this.test = {};
1637
- this.fieldWidth = 26;
1638
- this.filterWidth = 67.5;
1639
- this.binWidth = 6.5;
1640
- this.setupForm();
1641
- }
1642
- set fields(list) {
1643
- if ((list === null || list === void 0 ? void 0 : list.length) > 0) {
1644
- this._fields = list;
1645
- this._options = list.map(field => {
1646
- return {
1647
- key: field.id,
1648
- value: field.name
1649
- };
1650
- });
1651
- }
1652
- }
1653
- ;
1654
- set selected(value) {
1655
- if (value) {
1656
- this._selectedField = value;
1657
- }
1658
- }
1659
- set filter(value) {
1660
- if (value) {
1661
- this._filter = value;
1662
- }
1663
- }
1664
- ;
1665
- set parentForm(value) {
1666
- if (value) {
1667
- this._parentForm = value;
1668
- this.addToParentForm();
1669
- }
1670
- }
1671
- ;
1672
- ngOnInit() {
1673
- }
1674
- setupForm() {
1675
- this._form = this._fb.group({
1676
- fieldId: this._fb.control(null),
1677
- fieldType: this._fb.control(null),
1678
- operator: this._fb.control(null),
1679
- operatorUnit: this._fb.control(null),
1680
- values: this._fb.group({
1681
- first: this._fb.control(null),
1682
- second: this._fb.control(null)
1683
- }),
1684
- });
1685
- }
1686
- addToParentForm() {
1687
- this._parentForm.setControl(this.formKey, this._form);
1688
- }
1689
- onFieldChanged(key) {
1690
- let item = this._fields.find(field => field.id === key);
1691
- this.setupForm();
1692
- this.addToParentForm();
1693
- /**
1694
- * hack due to angular's change detection bug -
1695
- * ERROR Error: There is no FormControl instance attached to form control element with name: [formControlName]
1696
- */
1697
- this._selectedField = null;
1698
- setTimeout(() => {
1699
- this._selectedField = item ? item : null;
1700
- }, 0);
1701
- this._filter = null;
1702
- }
1703
- onFilterChanged() {
1704
- if (this._form.valid) {
1705
- this.filterChange.emit();
1706
- }
1707
- }
1708
- onDeleteItemClicked() {
1709
- this.remove.emit();
1710
- }
1711
- }
1712
- FilterBuilderItemComponent.decorators = [
1713
- { type: Component, args: [{
1714
- selector: 'pep-filter-builder-item',
1715
- template: "<div class=\"filter-item-container\" fxLayout=\"column\" fxLayoutGap=\".5rem\">\n <div fxLayout=\"row\" fxLayoutGap=\".5rem\">\n <pep-select fxFlex=\"25%\" [value]=\"_selectedField?.id\" xAlignment=\"left\" [options]=\"_options\"\n [renderTitle]=\"false\" (valueChange)=\"onFieldChanged($event)\"></pep-select>\n <ng-container *ngIf=\"_selectedField?.componentType\">\n <ng-container [ngSwitch]=\"_selectedField.componentType\">\n <ng-container *ngSwitchCase=\"'text'\">\n <pep-text-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"_form\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-text-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'boolean'\">\n <pep-boolean-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"_form\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-boolean-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'date'\">\n <pep-date-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"_form\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-date-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'multi-select'\">\n <pep-multi-select-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"_form\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-multi-select-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'number'\">\n <pep-number-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"_form\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-number-filter>\n </ng-container>\n </ng-container>\n </ng-container>\n <!-- <ng-container *ngIf=\"(_parentForm | filterItemCounter) > 1\"> -->\n <pep-button styleType=\"weak\" styleStateType=\"system_bin\" sizeType=\"md\" classNames=\"\" [disabled]=\"false\"\n iconName=\"system_bin\" iconPosition=\"end\" [visible]=\"true\" (buttonClick)=\"onDeleteItemClicked()\">\n </pep-button>\n <!-- </ng-container> -->\n </div>\n</div>",
1716
- styles: [""]
1717
- },] }
1718
- ];
1719
- FilterBuilderItemComponent.ctorParameters = () => [
1720
- { type: FormBuilder }
1721
- ];
1722
- FilterBuilderItemComponent.propDecorators = {
1723
- formKey: [{ type: Input }],
1724
- fields: [{ type: Input }],
1725
- selected: [{ type: Input }],
1726
- filter: [{ type: Input }],
1727
- parentForm: [{ type: Input }],
1728
- filterChange: [{ type: Output }],
1729
- remove: [{ type: Output }]
1730
- };
1731
-
1732
- class PepFilterBuilderTypeMap {
1733
- constructor() {
1734
- this.loadTypes();
1735
- }
1736
- loadTypes() {
1737
- this.map = new Map();
1738
- this.map.set('Bool', 'boolean');
1739
- this.map.set('JsonBool', 'boolean');
1740
- this.map.set('Integer', 'int');
1741
- this.map.set('Double', 'int');
1742
- this.map.set('String', 'text');
1743
- this.map.set('Guid', 'text');
1744
- this.map.set('Date', 'date');
1745
- this.map.set('DateTime', 'date-time');
1746
- this.map.set('MultipleStringValues', 'multi-select');
1747
- }
1748
- /**
1749
- * Converts legacy field type to smart builder type
1750
- * @param type legacy type
1751
- * @returns smart builder field type
1752
- */
1753
- getSmartBuilderType(key) {
1754
- let item = this.map.get(key);
1755
- return item ? item : null;
1756
- }
1757
- }
1758
-
1759
- const Days = {
1760
- legacy: 'Days',
1761
- smartFilter: PepSmartFilterOperatorUnits.Days
1762
- };
1763
- const Weeks = {
1764
- legacy: 'Weeks',
1765
- smartFilter: PepSmartFilterOperatorUnits.Weeks
1766
- };
1767
- const Months = {
1768
- legacy: 'Months',
1769
- smartFilter: PepSmartFilterOperatorUnits.Months
1770
- };
1771
- const Years = {
1772
- legacy: 'Years',
1773
- smartFilter: PepSmartFilterOperatorUnits.Years
1774
- };
1775
- const PepFilterBuilderOperationUnit = [
1776
- Days,
1777
- Weeks,
1778
- Months,
1779
- Years,
1780
- ];
1781
- /**
1782
- * gets a smart filter operation unit item
1783
- * @param operationUnit legacy operation unit
1784
- * @returns smart filter operation unit item
1785
- */
1786
- function getSmartBuilderOperationUnit(operationUnit) {
1787
- const smartFilterOperationUnit = PepFilterBuilderOperationUnit.find(unit => unit.legacy === operationUnit);
1788
- return smartFilterOperationUnit ? smartFilterOperationUnit.smartFilter : null;
1789
- }
1790
- /**
1791
- * gets a legacy operation unit value
1792
- * @param operationUnit smart filter operation unit item
1793
- * @returns legacy operation unit value
1794
- */
1795
- function getLegacyOperationUnit(operationUnit) {
1796
- const legacyOperationUnit = PepFilterBuilderOperationUnit.find(unit => unit.smartFilter === operationUnit);
1797
- return legacyOperationUnit ? legacyOperationUnit.legacy : null;
1798
- }
1799
-
1800
- class PepOutputFilterService {
1801
- constructor() {
1802
- }
1803
- /**
1804
- * generates a legacy JSON
1805
- * @param json UI smart filters structure
1806
- * @param fields smart filter field
1807
- * @returns legacy JSON
1808
- */
1809
- generateJson(json, fields) {
1810
- this.initProperties();
1811
- this._fields = fields;
1812
- this.treeWalk(json);
1813
- return this._json ? this._json : this._firstItem ? this._firstItem : null;
1814
- }
1815
- /**
1816
- * reset properties
1817
- */
1818
- initProperties() {
1819
- this._json = undefined;
1820
- this._firstItem = undefined;
1821
- this._complexIdCounter = 1;
1822
- this._expressionIdCounter = 1;
1823
- }
1824
- /**
1825
- * a recursive function dynamically builds legacy JSON structure
1826
- * @param current UI object represents either a section or filter component
1827
- */
1828
- treeWalk(current) {
1829
- Object.keys(current).forEach(key => {
1830
- if (key.includes('item')) {
1831
- this.createItem({
1832
- ExpressionId: (this._expressionIdCounter++).toString(),
1833
- ApiName: current[key].fieldId,
1834
- Operation: getLegacyOperator(current[key].operator, current[key].fieldType),
1835
- Values: this.getItemValues(current[key])
1836
- }, current.operator);
1837
- }
1838
- else if (key.includes('section')) {
1839
- this.treeWalk(current[key]);
1840
- }
1841
- });
1842
- }
1843
- /**
1844
- * adds a filter to json and wrap it with complex operator
1845
- * @param item expression item
1846
- * @param operator complex operator
1847
- */
1848
- createItem(item, operator) {
1849
- if (this._json) {
1850
- this._json = this.createSection(this._json, item, operator);
1851
- }
1852
- else if (this._firstItem) {
1853
- this._json = this.createSection(this._firstItem, item, operator);
1854
- }
1855
- else {
1856
- this._firstItem = item;
1857
- }
1858
- }
1859
- /**
1860
- * creates a legacy complex object
1861
- * @param left LeftNode object
1862
- * @param right RightNode object
1863
- * @param operator AND/OR operator
1864
- * @returns complex object
1865
- */
1866
- createSection(left, right, operator) {
1867
- return {
1868
- ComplexId: (this._complexIdCounter++).toString(),
1869
- LeftNode: left,
1870
- RightNode: right,
1871
- Operation: operator
1872
- };
1873
- }
1874
- /**
1875
- * gets legacy filter values object
1876
- * @param current UI filter object's values
1877
- * @returns an array represents legacy values
1878
- */
1879
- getItemValues(current) {
1880
- var _a;
1881
- let values = [];
1882
- if ((_a = current === null || current === void 0 ? void 0 : current.values) === null || _a === void 0 ? void 0 : _a.first) {
1883
- if (current.operator === PepSmartFilterOperators.In) { //multi select
1884
- values = current.values.first;
1885
- }
1886
- else if (current.operator === PepSmartFilterOperators.InTheLast ||
1887
- current.operator === PepSmartFilterOperators.NotInTheLast ||
1888
- current.operator === PepSmartFilterOperators.DueIn ||
1889
- current.operator === PepSmartFilterOperators.NotDueIn) { //operation unit
1890
- values.push(current.values.first);
1891
- if (current.operatorUnit) {
1892
- values.push(getLegacyOperationUnit(current.operatorUnit));
1893
- }
1894
- }
1895
- else {
1896
- values.push(current.values.first);
1897
- if (current.values.second) {
1898
- values.push(current.values.second);
1899
- }
1900
- }
1901
- }
1902
- return values;
1903
- }
1904
- /**
1905
- * generates an array of keys of multi-select control
1906
- * @param values an array of the selected values
1907
- * @param id filter's selected field
1908
- * @returns an array of keys
1909
- */
1910
- getFieldKeys(values, id) {
1911
- let keys = [];
1912
- let field = this._fields.find(item => item.id === id);
1913
- if (field) {
1914
- keys = field === null || field === void 0 ? void 0 : field.options.filter(item => values.includes(item.value)).map((option) => option.key);
1915
- }
1916
- return keys;
1917
- }
1918
- }
1919
- PepOutputFilterService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PepOutputFilterService_Factory() { return new PepOutputFilterService(); }, token: PepOutputFilterService, providedIn: "root" });
1920
- PepOutputFilterService.decorators = [
1921
- { type: Injectable, args: [{
1922
- providedIn: 'root',
1923
- },] }
1924
- ];
1925
- PepOutputFilterService.ctorParameters = () => [];
1926
-
1927
- class FilterBuilderService {
1928
- constructor(_fb, _resolver, _outputJsonService) {
1929
- this._fb = _fb;
1930
- this._resolver = _resolver;
1931
- this._outputJsonService = _outputJsonService;
1932
- this.MAX_STRUCTURE_DEPTH = 3;
1933
- this._outputJsonSubject = new BehaviorSubject(null);
1934
- this.triggerOutputJson = this._outputJsonSubject.asObservable();
1935
- }
1936
- get maxDepth() {
1937
- return this.MAX_STRUCTURE_DEPTH;
1938
- }
1939
- /**
1940
- * creates a dynamic filter structure
1941
- * might has a different structure than the input's due to merge of parent-child elements
1942
- * @param json legacy JSON
1943
- * @param fields an array of legacy fields
1944
- * @param containerRef reference to root element
1945
- */
1946
- createFilterTree(json, fields, form, containerRef) {
1947
- this._form = form;
1948
- this._smartFilterFields = this.convertToSmartFilterFields(fields);
1949
- const result = this.createSection((json === null || json === void 0 ? void 0 : json.Operation) ? json.Operation : PepOperatorTypes.And, containerRef, this._form, 0);
1950
- if (json) {
1951
- this.flatten(json, json.LeftNode, result.containerRef, result.parentForm, 1);
1952
- this.flatten(json, json.RightNode, result.containerRef, result.parentForm, 1);
1953
- }
1954
- }
1955
- /**
1956
- * checks if the object contains property
1957
- * @param obj object
1958
- * @param prop property name
1959
- * @returns true if contains, false otherwise
1960
- */
1961
- hasProperty(obj, prop) {
1962
- return Object.prototype.hasOwnProperty.call(obj, prop);
1963
- }
1964
- /**
1965
- * a recursive function dynamically builds filters structure
1966
- * @param parent legacy complex object
1967
- * @param current child legacy object (either another complex or expression type)
1968
- * @param containerRef parent element
1969
- * @param parentForm parent form
1970
- */
1971
- flatten(parent, current, containerRef, parentForm, depth) {
1972
- if (this.hasProperty(current, 'ComplexId')) {
1973
- const section = current;
1974
- if (parent.Operation === current.Operation) {
1975
- this.flatten(parent, section.LeftNode, containerRef, parentForm, depth);
1976
- this.flatten(parent, section.RightNode, containerRef, parentForm, depth);
1977
- }
1978
- else {
1979
- const result = this.createSection(section.Operation, containerRef, parentForm, depth);
1980
- this.flatten(section, section.LeftNode, result.containerRef, result.parentForm, depth + 1);
1981
- this.flatten(section, section.RightNode, result.containerRef, result.parentForm, depth + 1);
1982
- }
1983
- }
1984
- else if (this.hasProperty(current, 'ExpressionId')) {
1985
- this.createItem(current, containerRef, parentForm);
1986
- }
1987
- }
1988
- /**
1989
- * creates a container object of two or more child filter items
1990
- * @param operator AND/OR operator
1991
- * @param containerRef parent element
1992
- * @param parentForm parent form
1993
- * @param depth
1994
- * @returns an object containing the current element and current form
1995
- */
1996
- createSection(operator, containerRef, parentForm, depth) {
1997
- const factory = this._resolver.resolveComponentFactory(FilterBuilderSectionComponent);
1998
- let componentRef = containerRef.createComponent(factory);
1999
- let sectionGroup = this._fb.group({
2000
- operator: this._fb.control(operator)
2001
- });
2002
- let counter = 1;
2003
- Object.keys(parentForm.controls).forEach(item => { if (item.includes('section')) {
2004
- counter++;
2005
- } });
2006
- let formKey = `section${counter}`;
2007
- parentForm.addControl(formKey, sectionGroup);
2008
- componentRef.instance.depth = depth;
2009
- componentRef.instance.form = sectionGroup;
2010
- componentRef.instance.remove.subscribe(() => {
2011
- parentForm.removeControl(formKey);
2012
- componentRef.destroy();
2013
- this.createOutputJson();
2014
- });
2015
- componentRef.instance.operatorChange.subscribe(() => {
2016
- this.createOutputJson();
2017
- });
2018
- return {
2019
- containerRef: componentRef.instance.sectionContainer,
2020
- parentForm: sectionGroup
2021
- };
2022
- }
2023
- /**
2024
- * creates a component represents filter item (leaf element - has no childs)
2025
- * @param current filter legacy element
2026
- * @param containerRef parent element
2027
- * @param parentForm parent form
2028
- */
2029
- createItem(current, containerRef, parentForm) {
2030
- const factory = this._resolver.resolveComponentFactory(FilterBuilderItemComponent);
2031
- let componentRef = containerRef.createComponent(factory);
2032
- let counter = 1;
2033
- Object.keys(parentForm.controls).forEach(item => { if (item.includes('item')) {
2034
- counter++;
2035
- } });
2036
- let formKey = `item${counter}`;
2037
- componentRef.instance.formKey = formKey;
2038
- componentRef.instance.fields = this._smartFilterFields;
2039
- const selectedField = this.getSelectedField(current);
2040
- if (selectedField) {
2041
- componentRef.instance.selected = selectedField;
2042
- if (current) {
2043
- componentRef.instance.filter = this.getFilter(current, selectedField);
2044
- }
2045
- }
2046
- componentRef.instance.parentForm = parentForm;
2047
- componentRef.instance.filterChange.subscribe(() => {
2048
- this.createOutputJson();
2049
- });
2050
- componentRef.instance.remove.subscribe(() => {
2051
- parentForm.removeControl(formKey);
2052
- componentRef.destroy();
2053
- this.createOutputJson();
2054
- });
2055
- }
2056
- /**
2057
- * creates a smart filter object
2058
- * @param current filter legacy element
2059
- * @param field filter's selected field
2060
- * @returns smart filter object
2061
- */
2062
- getFilter(current, field) {
2063
- let operator = getSmartBuilderOperator(current.Operation, field.type);
2064
- if (operator) {
2065
- let filterValues = this.getFilterValues(current, operator, field);
2066
- return createSmartFilter(current.ApiName, operator, filterValues.first, filterValues.second, filterValues.operationUnit);
2067
- }
2068
- else {
2069
- return null;
2070
- }
2071
- }
2072
- /**
2073
- * get smart filter field
2074
- * @param current filter legacy element
2075
- * @returns smart filter field, if not found returns the first fields
2076
- */
2077
- getSelectedField(current) {
2078
- var _a, _b;
2079
- if (current) {
2080
- let item = this._smartFilterFields.find(field => field.id === current.ApiName);
2081
- return item ? item : ((_a = this._smartFilterFields) === null || _a === void 0 ? void 0 : _a.length) > 0 ? this._smartFilterFields[0] : null;
2082
- }
2083
- else {
2084
- return ((_b = this._smartFilterFields) === null || _b === void 0 ? void 0 : _b.length) > 0 ? this._smartFilterFields[0] : null;
2085
- }
2086
- }
2087
- /**
2088
- * gets smart filter's values data
2089
- * @param current filter legacy element
2090
- * @param operator smart filter operator
2091
- * @param field filter's selected field
2092
- * @returns object contains the filter values data
2093
- */
2094
- getFilterValues(current, operator, field) {
2095
- var _a, _b, _c, _d, _e;
2096
- let data = {
2097
- first: null,
2098
- second: null,
2099
- operationUnit: null
2100
- };
2101
- if (operator === PepSmartFilterOperators.In) { //multi select
2102
- //filter keys don't exist on field options
2103
- data.first = ((_a = current === null || current === void 0 ? void 0 : current.Values) === null || _a === void 0 ? void 0 : _a.length) > 0 ? current.Values.filter(item => {
2104
- return field.options.find(option => option.key === item);
2105
- }) : null;
2106
- }
2107
- else if (operator === PepSmartFilterOperators.InTheLast ||
2108
- operator === PepSmartFilterOperators.NotInTheLast ||
2109
- operator === PepSmartFilterOperators.DueIn ||
2110
- operator === PepSmartFilterOperators.NotDueIn) { //operation unit
2111
- data.first = ((_b = current === null || current === void 0 ? void 0 : current.Values) === null || _b === void 0 ? void 0 : _b.length) > 0 ? current.Values[0] : null;
2112
- if (((_c = current === null || current === void 0 ? void 0 : current.Values) === null || _c === void 0 ? void 0 : _c.length) === 2) {
2113
- data.operationUnit = getSmartBuilderOperationUnit(current.Values[1]);
2114
- }
2115
- }
2116
- else {
2117
- data.first = ((_d = current === null || current === void 0 ? void 0 : current.Values) === null || _d === void 0 ? void 0 : _d.length) > 0 ? current.Values[0] : null;
2118
- data.second = ((_e = current === null || current === void 0 ? void 0 : current.Values) === null || _e === void 0 ? void 0 : _e.length) === 2 ? current.Values[1] : null;
2119
- }
2120
- return data;
2121
- }
2122
- /**
2123
- * converts legacy fields to smart filter fields
2124
- * @param fields legacy fields array
2125
- * @returns smart filter fields array
2126
- */
2127
- convertToSmartFilterFields(fields) {
2128
- if ((fields === null || fields === void 0 ? void 0 : fields.length) > 0) {
2129
- const typeMapper = new PepFilterBuilderTypeMap();
2130
- return fields.map((field) => {
2131
- var _a;
2132
- return createSmartFilterField({
2133
- id: field.FieldID,
2134
- name: field.Title,
2135
- options: (_a = field.OptionalValues) === null || _a === void 0 ? void 0 : _a.map(option => {
2136
- return {
2137
- key: option.Key,
2138
- value: option.Value
2139
- };
2140
- })
2141
- }, typeMapper.getSmartBuilderType(field.FieldType));
2142
- });
2143
- }
2144
- else {
2145
- return [];
2146
- }
2147
- }
2148
- /**
2149
- * creates a legacy output JSON
2150
- */
2151
- createOutputJson() {
2152
- if (this._form.valid) {
2153
- const json = this._outputJsonService.generateJson(this._form.value, this._smartFilterFields);
2154
- this._outputJsonSubject.next(json);
2155
- }
2156
- }
2157
- }
2158
- FilterBuilderService.ɵprov = i0.ɵɵdefineInjectable({ factory: function FilterBuilderService_Factory() { return new FilterBuilderService(i0.ɵɵinject(i1.FormBuilder), i0.ɵɵinject(i0.ComponentFactoryResolver), i0.ɵɵinject(PepOutputFilterService)); }, token: FilterBuilderService, providedIn: "root" });
2159
- FilterBuilderService.decorators = [
2160
- { type: Injectable, args: [{
2161
- providedIn: 'root'
2162
- },] }
2163
- ];
2164
- FilterBuilderService.ctorParameters = () => [
2165
- { type: FormBuilder },
2166
- { type: ComponentFactoryResolver },
2167
- { type: PepOutputFilterService }
2168
- ];
2169
-
2170
- class FilterBuilderComponent {
2171
- constructor(_fb, _filterBuilderService) {
2172
- this._fb = _fb;
2173
- this._filterBuilderService = _filterBuilderService;
2174
- this.json = null;
2175
- this.fields = new Array();
2176
- this.filters = new EventEmitter();
2177
- this.formValidationChange = new EventEmitter();
2178
- this._isFormValid = true;
2179
- this.setupForm();
2180
- this._formSubscription$ = this.form.valueChanges.subscribe((val) => {
2181
- if (this.form.valid !== this._isFormValid) {
2182
- this._isFormValid = this.form.valid;
2183
- this.formValidationChange.emit(this._isFormValid);
2184
- }
2185
- });
2186
- this._outputJsonSubscription$ = this._filterBuilderService.triggerOutputJson.subscribe((outputJson) => {
2187
- this.filters.emit(outputJson);
2188
- });
2189
- }
2190
- setupForm() {
2191
- this.form = this._fb.group({});
2192
- }
2193
- ngOnInit() {
2194
- this._filterBuilderService.createFilterTree(this.json, this.fields, this.form, this.filterRoot);
2195
- }
2196
- /*
2197
- ngAfterViewInit() {
2198
- //this._filterBuilderService.createFilterTree(this.json, this.fields, this.form, this.filterRoot);
2199
- }
2200
-
2201
- ngAfterViewChecked() {
2202
- //this._changeDetectionRef.detectChanges();
2203
- } */
2204
- ngOnDestroy() {
2205
- if (this._formSubscription$) {
2206
- this._formSubscription$.unsubscribe();
2207
- }
2208
- if (this._outputJsonSubscription$) {
2209
- this._outputJsonSubscription$.unsubscribe();
2210
- }
2211
- }
2212
- }
2213
- FilterBuilderComponent.decorators = [
2214
- { type: Component, args: [{
2215
- selector: 'pep-filter-builder',
2216
- template: "<!-- <div class=\"filter-builder-container\"> -->\n<ng-container #filterRoot></ng-container>\n<!-- </div> -->",
2217
- styles: [""]
2218
- },] }
2219
- ];
2220
- FilterBuilderComponent.ctorParameters = () => [
2221
- { type: FormBuilder },
2222
- { type: FilterBuilderService }
2223
- ];
2224
- FilterBuilderComponent.propDecorators = {
2225
- json: [{ type: Input }],
2226
- fields: [{ type: Input }],
2227
- filters: [{ type: Output }],
2228
- formValidationChange: [{ type: Output }],
2229
- filterRoot: [{ type: ViewChild, args: ['filterRoot', { read: ViewContainerRef, static: true },] }]
2230
- };
2231
-
2232
- class FilterItemCounterPipe {
2233
- transform(container) {
2234
- console.log('init filter', container);
2235
- let counter = 0;
2236
- Object.keys(container.controls).forEach(item => { if (item.includes('item') || item.includes('section')) {
2237
- counter++;
2238
- } });
2239
- console.log('filter counter', counter);
2240
- return counter;
2241
- }
2242
- }
2243
- FilterItemCounterPipe.decorators = [
2244
- { type: Pipe, args: [{
2245
- name: 'filterItemCounter'
2246
- },] }
2247
- ];
2248
-
2249
- class PepSmartFiltersModule {
2250
- constructor(pepIconRegistry) {
2251
- this.pepIconRegistry = pepIconRegistry;
2252
- this.pepIconRegistry.registerIcons([
2253
- pepIconNumberMinus,
2254
- pepIconNumberPlus,
2255
- ]);
2256
- }
2257
- }
2258
- PepSmartFiltersModule.decorators = [
2259
- { type: NgModule, args: [{
2260
- imports: [
2261
- CommonModule,
2262
- ReactiveFormsModule,
2263
- FlexLayoutModule,
2264
- // Material modules
2265
- MatCommonModule,
2266
- MatCheckboxModule,
2267
- MatChipsModule,
2268
- MatExpansionModule,
2269
- MatIconModule,
2270
- MatFormFieldModule,
2271
- MatInputModule,
2272
- MatRadioModule,
2273
- // External modules
2274
- VirtualScrollerModule,
2275
- // ngx-lib modules
2276
- PepNgxLibModule,
2277
- PepCheckboxModule,
2278
- PepDateModule,
2279
- PepSelectModule,
2280
- PepTextboxModule,
2281
- PepSearchModule,
2282
- PepIconModule,
2283
- PepButtonModule,
2284
- ],
2285
- exports: [PepSmartFiltersComponent, FilterBuilderComponent],
2286
- declarations: [
2287
- // BaseFilterComponent,
2288
- PepSmartFiltersComponent,
2289
- PepFilterActionsComponent,
2290
- PepTextFilterComponent,
2291
- PepBooleanFilterComponent,
2292
- PepDateFilterComponent,
2293
- PepMultiSelectFilterComponent,
2294
- PepNumberFilterComponent,
2295
- FilterBuilderComponent,
2296
- FilterBuilderSectionComponent,
2297
- FilterBuilderItemComponent,
2298
- FilterItemCounterPipe
2299
- ],
2300
- },] }
2301
- ];
2302
- PepSmartFiltersModule.ctorParameters = () => [
2303
- { type: PepIconRegistry }
2304
- ];
2305
-
2306
1141
  /*
2307
1142
  * Public API Surface of ngx-lib/smart-filters
2308
1143
  */
@@ -2311,5 +1146,5 @@ PepSmartFiltersModule.ctorParameters = () => [
2311
1146
  * Generated bundle index. Do not edit.
2312
1147
  */
2313
1148
 
2314
- export { BaseFilterComponent, FilterBuilderComponent, IPepSmartFilterOperator, IPepSmartFilterOperatorUnit, PepBooleanFilterComponent, PepDateFilterComponent, PepFilterActionsComponent, PepMultiSelectFilterComponent, PepNumberFilterComponent, PepSmartFilterBaseField, PepSmartFilterBooleanField, PepSmartFilterCurrencyField, PepSmartFilterDateBaseField, PepSmartFilterDateField, PepSmartFilterDateTimeField, PepSmartFilterIntField, PepSmartFilterMultiSelectField, PepSmartFilterNumberBaseField, PepSmartFilterOperatorUnits, PepSmartFilterOperators, PepSmartFilterPercentageField, PepSmartFilterRealField, PepSmartFilterTextField, PepSmartFiltersComponent, PepSmartFiltersModule, createSmartFilter, createSmartFilterField, FilterBuilderService as ɵa, PepOutputFilterService as ɵb, PepTextFilterComponent as ɵc, PepTypeConvertorService as ɵd, FilterBuilderSectionComponent as ɵe, FilterBuilderItemComponent as ɵf, FilterItemCounterPipe as ɵg };
1149
+ export { BaseFilterComponent, IPepSmartFilterOperator, IPepSmartFilterOperatorUnit, PepBooleanFilterComponent, PepDateFilterComponent, PepFilterActionsComponent, PepMultiSelectFilterComponent, PepNumberFilterComponent, PepSmartFilterBaseField, PepSmartFilterBooleanField, PepSmartFilterCurrencyField, PepSmartFilterDateBaseField, PepSmartFilterDateField, PepSmartFilterDateTimeField, PepSmartFilterIntField, PepSmartFilterMultiSelectField, PepSmartFilterNumberBaseField, PepSmartFilterOperatorUnits, PepSmartFilterOperators, PepSmartFilterPercentageField, PepSmartFilterRealField, PepSmartFiltersComponent, PepSmartFiltersModule, createSmartFilter, createSmartFilterField };
2315
1150
  //# sourceMappingURL=pepperi-addons-ngx-lib-smart-filters.js.map