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

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 (177) hide show
  1. package/attachment/attachment.component.d.ts +1 -0
  2. package/attachment/pepperi-addons-ngx-lib-attachment.metadata.json +1 -1
  3. package/bundles/pepperi-addons-ngx-lib-attachment.umd.js +6 -1
  4. package/bundles/pepperi-addons-ngx-lib-attachment.umd.js.map +1 -1
  5. package/bundles/pepperi-addons-ngx-lib-checkbox.umd.js +3 -0
  6. package/bundles/pepperi-addons-ngx-lib-checkbox.umd.js.map +1 -1
  7. package/bundles/pepperi-addons-ngx-lib-color.umd.js +6 -1
  8. package/bundles/pepperi-addons-ngx-lib-color.umd.js.map +1 -1
  9. package/bundles/pepperi-addons-ngx-lib-date.umd.js +4 -1
  10. package/bundles/pepperi-addons-ngx-lib-date.umd.js.map +1 -1
  11. package/bundles/pepperi-addons-ngx-lib-form.umd.js +20 -15
  12. package/bundles/pepperi-addons-ngx-lib-form.umd.js.map +1 -1
  13. package/bundles/pepperi-addons-ngx-lib-image.umd.js +6 -1
  14. package/bundles/pepperi-addons-ngx-lib-image.umd.js.map +1 -1
  15. package/bundles/pepperi-addons-ngx-lib-images-filmstrip.umd.js +6 -1
  16. package/bundles/pepperi-addons-ngx-lib-images-filmstrip.umd.js.map +1 -1
  17. package/bundles/pepperi-addons-ngx-lib-list.umd.js +4 -2
  18. package/bundles/pepperi-addons-ngx-lib-list.umd.js.map +1 -1
  19. package/bundles/pepperi-addons-ngx-lib-quantity-selector.umd.js +6 -1
  20. package/bundles/pepperi-addons-ngx-lib-quantity-selector.umd.js.map +1 -1
  21. package/bundles/pepperi-addons-ngx-lib-rich-html-textarea.umd.js +6 -1
  22. package/bundles/pepperi-addons-ngx-lib-rich-html-textarea.umd.js.map +1 -1
  23. package/bundles/pepperi-addons-ngx-lib-select.umd.js +6 -1
  24. package/bundles/pepperi-addons-ngx-lib-select.umd.js.map +1 -1
  25. package/bundles/pepperi-addons-ngx-lib-separator.umd.js +8 -0
  26. package/bundles/pepperi-addons-ngx-lib-separator.umd.js.map +1 -1
  27. package/bundles/pepperi-addons-ngx-lib-signature.umd.js +6 -1
  28. package/bundles/pepperi-addons-ngx-lib-signature.umd.js.map +1 -1
  29. package/bundles/pepperi-addons-ngx-lib-slider.umd.js.map +1 -1
  30. package/bundles/pepperi-addons-ngx-lib-smart-filters.umd.js +1432 -173
  31. package/bundles/pepperi-addons-ngx-lib-smart-filters.umd.js.map +1 -1
  32. package/bundles/pepperi-addons-ngx-lib-textarea.umd.js +6 -1
  33. package/bundles/pepperi-addons-ngx-lib-textarea.umd.js.map +1 -1
  34. package/bundles/pepperi-addons-ngx-lib-textbox.umd.js +4 -2
  35. package/bundles/pepperi-addons-ngx-lib-textbox.umd.js.map +1 -1
  36. package/bundles/pepperi-addons-ngx-lib-top-bar.umd.js +1 -1
  37. package/bundles/pepperi-addons-ngx-lib.umd.js +4 -2
  38. package/bundles/pepperi-addons-ngx-lib.umd.js.map +1 -1
  39. package/color/color.component.d.ts +1 -0
  40. package/color/pepperi-addons-ngx-lib-color.metadata.json +1 -1
  41. package/core/customization/customization.service.d.ts +1 -0
  42. package/esm2015/attachment/attachment.component.js +7 -2
  43. package/esm2015/checkbox/checkbox.component.js +4 -1
  44. package/esm2015/color/color.component.js +7 -2
  45. package/esm2015/core/common/services/translate.service.js +1 -1
  46. package/esm2015/core/customization/customization.service.js +4 -2
  47. package/esm2015/date/date.component.js +4 -1
  48. package/esm2015/form/form.component.js +2 -1
  49. package/esm2015/form/internal-button.component.js +20 -17
  50. package/esm2015/form/internal-carusel.component.js +2 -1
  51. package/esm2015/image/image.component.js +7 -2
  52. package/esm2015/image/image.service.js +1 -1
  53. package/esm2015/images-filmstrip/images-filmstrip.component.js +7 -2
  54. package/esm2015/list/list-total.component.js +5 -3
  55. package/esm2015/quantity-selector/quantity-selector.component.js +7 -2
  56. package/esm2015/rich-html-textarea/rich-html-textarea.component.js +7 -2
  57. package/esm2015/select/select.component.js +7 -2
  58. package/esm2015/separator/separator.component.js +9 -1
  59. package/esm2015/signature/signature.component.js +7 -2
  60. package/esm2015/slider/slider.component.js +1 -1
  61. package/esm2015/smart-filters/boolean-filter/boolean-filter.component.js +12 -2
  62. package/esm2015/smart-filters/common/model/base-filter-component.js +40 -10
  63. package/esm2015/smart-filters/common/model/creator.js +8 -2
  64. package/esm2015/smart-filters/common/model/field.js +12 -1
  65. package/esm2015/smart-filters/common/model/operator.js +8 -8
  66. package/esm2015/smart-filters/common/model/type.js +1 -1
  67. package/esm2015/smart-filters/date-filter/date-filter.component.js +45 -2
  68. package/esm2015/smart-filters/filter-builder/common/model/filter.js +2 -0
  69. package/esm2015/smart-filters/filter-builder/common/model/legacy.js +2 -0
  70. package/esm2015/smart-filters/filter-builder/common/model/operator-unit.js +42 -0
  71. package/esm2015/smart-filters/filter-builder/common/model/operator.js +207 -0
  72. package/esm2015/smart-filters/filter-builder/common/model/type-map.js +27 -0
  73. package/esm2015/smart-filters/filter-builder/common/model/type.js +6 -0
  74. package/esm2015/smart-filters/filter-builder/common/pipes/filter-item-counter.pipe.js +18 -0
  75. package/esm2015/smart-filters/filter-builder/common/services/output-filter.service.js +132 -0
  76. package/esm2015/smart-filters/filter-builder/common/services/type-convertor.service.js +44 -0
  77. package/esm2015/smart-filters/filter-builder/filter-builder-item/filter-builder-item.component.js +106 -0
  78. package/esm2015/smart-filters/filter-builder/filter-builder-section/filter-builder-section.component.js +50 -0
  79. package/esm2015/smart-filters/filter-builder/filter-builder.component.js +65 -0
  80. package/esm2015/smart-filters/filter-builder/filter-builder.service.js +261 -0
  81. package/esm2015/smart-filters/index.js +5 -0
  82. package/esm2015/smart-filters/multi-select-filter/multi-select-filter.component.js +53 -14
  83. package/esm2015/smart-filters/number-filter/number-filter.component.js +25 -2
  84. package/esm2015/smart-filters/pepperi-addons-ngx-lib-smart-filters.js +8 -1
  85. package/esm2015/smart-filters/public-api.js +2 -1
  86. package/esm2015/smart-filters/smart-filters.module.js +14 -2
  87. package/esm2015/smart-filters/text-filter/text-filter.component.js +79 -0
  88. package/esm2015/textarea/textarea.component.js +7 -2
  89. package/esm2015/textbox/textbox.component.js +5 -3
  90. package/esm2015/top-bar/top-bar.component.js +1 -1
  91. package/fesm2015/pepperi-addons-ngx-lib-attachment.js +6 -1
  92. package/fesm2015/pepperi-addons-ngx-lib-attachment.js.map +1 -1
  93. package/fesm2015/pepperi-addons-ngx-lib-checkbox.js +3 -0
  94. package/fesm2015/pepperi-addons-ngx-lib-checkbox.js.map +1 -1
  95. package/fesm2015/pepperi-addons-ngx-lib-color.js +6 -1
  96. package/fesm2015/pepperi-addons-ngx-lib-color.js.map +1 -1
  97. package/fesm2015/pepperi-addons-ngx-lib-date.js +3 -0
  98. package/fesm2015/pepperi-addons-ngx-lib-date.js.map +1 -1
  99. package/fesm2015/pepperi-addons-ngx-lib-form.js +20 -15
  100. package/fesm2015/pepperi-addons-ngx-lib-form.js.map +1 -1
  101. package/fesm2015/pepperi-addons-ngx-lib-image.js +6 -1
  102. package/fesm2015/pepperi-addons-ngx-lib-image.js.map +1 -1
  103. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.js +6 -1
  104. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.js.map +1 -1
  105. package/fesm2015/pepperi-addons-ngx-lib-list.js +4 -2
  106. package/fesm2015/pepperi-addons-ngx-lib-list.js.map +1 -1
  107. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.js +6 -1
  108. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.js.map +1 -1
  109. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.js +6 -1
  110. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.js.map +1 -1
  111. package/fesm2015/pepperi-addons-ngx-lib-select.js +6 -1
  112. package/fesm2015/pepperi-addons-ngx-lib-select.js.map +1 -1
  113. package/fesm2015/pepperi-addons-ngx-lib-separator.js +8 -0
  114. package/fesm2015/pepperi-addons-ngx-lib-separator.js.map +1 -1
  115. package/fesm2015/pepperi-addons-ngx-lib-signature.js +6 -1
  116. package/fesm2015/pepperi-addons-ngx-lib-signature.js.map +1 -1
  117. package/fesm2015/pepperi-addons-ngx-lib-slider.js.map +1 -1
  118. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.js +1293 -128
  119. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.js.map +1 -1
  120. package/fesm2015/pepperi-addons-ngx-lib-textarea.js +6 -1
  121. package/fesm2015/pepperi-addons-ngx-lib-textarea.js.map +1 -1
  122. package/fesm2015/pepperi-addons-ngx-lib-textbox.js +4 -2
  123. package/fesm2015/pepperi-addons-ngx-lib-textbox.js.map +1 -1
  124. package/fesm2015/pepperi-addons-ngx-lib-top-bar.js +1 -1
  125. package/fesm2015/pepperi-addons-ngx-lib.js +3 -1
  126. package/fesm2015/pepperi-addons-ngx-lib.js.map +1 -1
  127. package/form/internal-button.component.d.ts +0 -1
  128. package/image/image.component.d.ts +1 -0
  129. package/image/pepperi-addons-ngx-lib-image.metadata.json +1 -1
  130. package/images-filmstrip/images-filmstrip.component.d.ts +1 -0
  131. package/images-filmstrip/pepperi-addons-ngx-lib-images-filmstrip.metadata.json +1 -1
  132. package/list/list-total.component.d.ts +2 -0
  133. package/list/pepperi-addons-ngx-lib-list.metadata.json +1 -1
  134. package/package.json +4 -4
  135. package/pepperi-addons-ngx-lib.metadata.json +1 -1
  136. package/quantity-selector/pepperi-addons-ngx-lib-quantity-selector.metadata.json +1 -1
  137. package/quantity-selector/quantity-selector.component.d.ts +1 -0
  138. package/rich-html-textarea/pepperi-addons-ngx-lib-rich-html-textarea.metadata.json +1 -1
  139. package/rich-html-textarea/rich-html-textarea.component.d.ts +1 -0
  140. package/select/pepperi-addons-ngx-lib-select.metadata.json +1 -1
  141. package/select/select.component.d.ts +1 -0
  142. package/separator/pepperi-addons-ngx-lib-separator.metadata.json +1 -1
  143. package/signature/pepperi-addons-ngx-lib-signature.metadata.json +1 -1
  144. package/signature/signature.component.d.ts +1 -0
  145. package/smart-filters/boolean-filter/boolean-filter.component.d.ts +5 -1
  146. package/smart-filters/common/model/base-filter-component.d.ts +10 -1
  147. package/smart-filters/common/model/field.d.ts +4 -0
  148. package/smart-filters/common/model/operator.d.ts +1 -0
  149. package/smart-filters/common/model/type.d.ts +2 -2
  150. package/smart-filters/date-filter/date-filter.component.d.ts +8 -1
  151. package/smart-filters/filter-builder/common/model/filter.d.ts +6 -0
  152. package/smart-filters/filter-builder/common/model/legacy.d.ts +23 -0
  153. package/smart-filters/filter-builder/common/model/operator-unit.d.ts +13 -0
  154. package/smart-filters/filter-builder/common/model/operator.d.ts +21 -0
  155. package/smart-filters/filter-builder/common/model/type-map.d.ts +12 -0
  156. package/smart-filters/filter-builder/common/model/type.d.ts +4 -0
  157. package/smart-filters/filter-builder/common/pipes/filter-item-counter.pipe.d.ts +5 -0
  158. package/smart-filters/filter-builder/common/services/output-filter.service.d.ts +52 -0
  159. package/smart-filters/filter-builder/common/services/type-convertor.service.d.ts +10 -0
  160. package/smart-filters/filter-builder/filter-builder-item/filter-builder-item.component.d.ts +32 -0
  161. package/smart-filters/filter-builder/filter-builder-section/filter-builder-section.component.d.ts +22 -0
  162. package/smart-filters/filter-builder/filter-builder-section/filter-builder-section.component.theme.scss +6 -0
  163. package/smart-filters/filter-builder/filter-builder.component.d.ts +22 -0
  164. package/smart-filters/filter-builder/filter-builder.service.d.ts +90 -0
  165. package/smart-filters/index.d.ts +1 -0
  166. package/smart-filters/multi-select-filter/multi-select-filter.component.d.ts +6 -0
  167. package/smart-filters/number-filter/number-filter.component.d.ts +5 -0
  168. package/smart-filters/pepperi-addons-ngx-lib-smart-filters.d.ts +7 -0
  169. package/smart-filters/pepperi-addons-ngx-lib-smart-filters.metadata.json +1 -1
  170. package/smart-filters/public-api.d.ts +1 -0
  171. package/smart-filters/text-filter/text-filter.component.d.ts +17 -0
  172. package/src/assets/i18n/en.ngx-lib.json +2 -1
  173. package/src/core/style/components/general.scss +4 -2
  174. package/textarea/pepperi-addons-ngx-lib-textarea.metadata.json +1 -1
  175. package/textarea/textarea.component.d.ts +1 -0
  176. package/theming.scss +4 -0
  177. package/top-bar/pepperi-addons-ngx-lib-top-bar.metadata.json +1 -1
@@ -1,5 +1,7 @@
1
- import { EventEmitter, Component, ChangeDetectionStrategy, ElementRef, Input, Output, Directive, ViewContainerRef, Injector, ComponentFactoryResolver, Renderer2, ViewChild, NgModule } from '@angular/core';
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';
2
3
  import { CommonModule } from '@angular/common';
4
+ import * as i1 from '@angular/forms';
3
5
  import { Validators, FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms';
4
6
  import { FlexLayoutModule } from '@angular/flex-layout';
5
7
  import { MatCommonModule } from '@angular/material/core';
@@ -17,9 +19,10 @@ import { PepDateModule } from '@pepperi-addons/ngx-lib/date';
17
19
  import { PepSelectModule } from '@pepperi-addons/ngx-lib/select';
18
20
  import { PepTextboxModule } from '@pepperi-addons/ngx-lib/textbox';
19
21
  import { PepSearchModule } from '@pepperi-addons/ngx-lib/search';
22
+ import { PepButtonModule } from '@pepperi-addons/ngx-lib/button';
20
23
  import { pepIconNumberMinus, pepIconNumberPlus, PepIconModule, PepIconRegistry } from '@pepperi-addons/ngx-lib/icon';
21
- import { Subject } from 'rxjs';
22
24
  import { takeUntil, distinctUntilChanged, startWith, map } from 'rxjs/operators';
25
+ import { Subject, BehaviorSubject } from 'rxjs';
23
26
  import { TranslateService } from '@ngx-translate/core';
24
27
 
25
28
  class PepSmartFiltersComponent {
@@ -177,7 +180,7 @@ PepFilterActionsComponent.propDecorators = {
177
180
 
178
181
  class IPepSmartFilterOperator {
179
182
  }
180
- const Equals = {
183
+ const Equals$1 = {
181
184
  id: 'eq',
182
185
  name: 'EQUAL',
183
186
  short: '=',
@@ -191,7 +194,7 @@ const Equals = {
191
194
  // 'select',
192
195
  ],
193
196
  };
194
- const NotEqual = {
197
+ const NotEqual$1 = {
195
198
  id: 'neq',
196
199
  name: 'NOT_EQUAL',
197
200
  short: '<>',
@@ -204,7 +207,7 @@ const NotEqual = {
204
207
  // 'select',
205
208
  ],
206
209
  };
207
- const LessThan = {
210
+ const LessThan$1 = {
208
211
  id: 'lt',
209
212
  name: 'LESS_THEN',
210
213
  short: '<',
@@ -216,7 +219,7 @@ const LessThan = {
216
219
  // short: '<=',
217
220
  // type: ['number'],
218
221
  // };
219
- const GreaterThan = {
222
+ const GreaterThan$1 = {
220
223
  id: 'gt',
221
224
  name: 'GREATER_THEN',
222
225
  short: '>',
@@ -228,18 +231,18 @@ const GreaterThan = {
228
231
  // short: '>=',
229
232
  // type: ['number'],
230
233
  // };
231
- const NumberRange = {
234
+ const NumberRange$1 = {
232
235
  id: 'numberRange',
233
236
  name: 'NUMBER_RANGE',
234
237
  short: 'Range',
235
238
  componentType: ['number'],
236
239
  };
237
- // const Contains: Operator = {
238
- // id: 'contains',
239
- // name: 'Contains',
240
- // short: 'Contains',
241
- // type: ['text'],
242
- // };
240
+ const Contains$1 = {
241
+ id: 'contains',
242
+ name: 'CONTAINS',
243
+ short: 'Contains',
244
+ componentType: ['text'],
245
+ };
243
246
  // const BeginsWith: Operator = {
244
247
  // id: 'beginsWith',
245
248
  // name: 'Begins With',
@@ -264,135 +267,177 @@ const NumberRange = {
264
267
  // short: 'Before',
265
268
  // type: ['date'],
266
269
  // };
267
- const InTheLast = {
270
+ const InTheLast$1 = {
268
271
  id: 'inTheLast',
269
272
  name: 'IN_THE_LAST',
270
273
  short: 'In the last',
271
274
  componentType: ['date'],
272
275
  };
273
- const Today = {
276
+ const Today$1 = {
274
277
  id: 'today',
275
278
  name: 'TODAY',
276
279
  short: 'Today',
277
280
  componentType: ['date'],
278
281
  };
279
- const ThisWeek = {
282
+ const ThisWeek$1 = {
280
283
  id: 'thisWeek',
281
284
  name: 'THIS_WEEK',
282
285
  short: 'This week',
283
286
  componentType: ['date'],
284
287
  };
285
- const ThisMonth = {
288
+ const ThisMonth$1 = {
286
289
  id: 'thisMonth',
287
290
  name: 'THIS_MONTH',
288
291
  short: 'This month',
289
292
  componentType: ['date'],
290
293
  };
291
- const DateRange = {
294
+ const DateRange$1 = {
292
295
  id: 'dateRange',
293
296
  name: 'DATE_RANGE',
294
297
  short: 'Range',
295
298
  componentType: ['date'],
296
299
  };
297
- const DueIn = {
300
+ const DueIn$1 = {
298
301
  id: 'dueIn',
299
302
  name: 'DUE_IN',
300
303
  short: 'Due in',
301
304
  componentType: ['date'],
302
305
  };
303
- const On = {
306
+ const On$1 = {
304
307
  id: 'on',
305
308
  name: 'ON',
306
309
  short: 'On',
307
310
  componentType: ['date'],
308
311
  };
309
- const NotInTheLast = {
312
+ const NotInTheLast$1 = {
310
313
  id: 'notInTheLast',
311
314
  name: 'NOT_IN_THE_LAST',
312
315
  short: 'Not in the last',
313
316
  componentType: ['date'],
314
317
  };
315
- const NotDueIn = {
318
+ const NotDueIn$1 = {
316
319
  id: 'notDueIn',
317
320
  name: 'NOT_DUE_IN',
318
321
  short: 'Not due in',
319
322
  componentType: ['date'],
320
323
  };
321
- const IsEmpty = {
324
+ const IsEmpty$1 = {
322
325
  id: 'isEmpty',
323
326
  name: 'IS_EMPTY',
324
327
  short: 'Is empty',
325
328
  componentType: ['date'],
326
329
  };
327
- const IsNotEmpty = {
330
+ const IsNotEmpty$1 = {
328
331
  id: 'isNotEmpty',
329
332
  name: 'IS_NOT_EMPTY',
330
333
  short: 'Is not empty',
331
334
  componentType: ['date'],
332
335
  };
333
- const In = {
336
+ const In$1 = {
334
337
  id: 'in',
335
338
  name: 'IN',
336
339
  short: 'In',
337
340
  componentType: ['multi-select'],
338
341
  };
339
342
  const PepSmartFilterOperators = {
340
- Equals: Equals,
341
- NotEqual: NotEqual,
342
- LessThan: LessThan,
343
+ Equals: Equals$1,
344
+ NotEqual: NotEqual$1,
345
+ LessThan: LessThan$1,
343
346
  // LessThanOrEquals: LessThanOrEquals,
344
- GreaterThan: GreaterThan,
347
+ GreaterThan: GreaterThan$1,
345
348
  // GreaterThanOrEquals: GreaterThanOrEquals,
346
- NumberRange: NumberRange,
347
- // Contains: Contains,
349
+ NumberRange: NumberRange$1,
350
+ Contains: Contains$1,
348
351
  // BeginsWith: BeginsWith,
349
352
  // EndsWith: EndsWith,
350
353
  // After: After,
351
354
  // Before: Before,
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,
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,
364
367
  };
365
368
  class IPepSmartFilterOperatorUnit {
366
369
  }
367
- const Days = {
370
+ const Days$1 = {
368
371
  id: 'days',
369
372
  name: 'DAYS',
370
373
  componentType: ['date'],
371
374
  };
372
- const Weeks = {
375
+ const Weeks$1 = {
373
376
  id: 'weeks',
374
377
  name: 'WEEKS',
375
378
  componentType: ['date'],
376
379
  };
377
- const Months = {
380
+ const Months$1 = {
378
381
  id: 'months',
379
382
  name: 'MONTHS',
380
383
  componentType: ['date'],
381
384
  };
382
- const Years = {
385
+ const Years$1 = {
383
386
  id: 'years',
384
387
  name: 'YEARS',
385
388
  componentType: ['date'],
386
389
  };
387
390
  const PepSmartFilterOperatorUnits = {
388
- Days: Days,
389
- Weeks: Weeks,
390
- Months: Months,
391
- Years: Years,
391
+ Days: Days$1,
392
+ Weeks: Weeks$1,
393
+ Months: Months$1,
394
+ Years: Years$1,
392
395
  };
393
396
 
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
+
394
439
  class BaseFilterComponent {
395
- constructor(viewContainerRef, injector, resolver, builder, translate, validator, renderer) {
440
+ constructor(viewContainerRef, injector, resolver, builder, translate, validator, renderer, typeConvertorService) {
396
441
  this.viewContainerRef = viewContainerRef;
397
442
  this.injector = injector;
398
443
  this.resolver = resolver;
@@ -400,7 +445,12 @@ class BaseFilterComponent {
400
445
  this.translate = translate;
401
446
  this.validator = validator;
402
447
  this.renderer = renderer;
448
+ this.typeConvertorService = typeConvertorService;
403
449
  this._fieldIdWithNoDots = '';
450
+ this.emitOnChange = false;
451
+ this.inline = false;
452
+ this.showActionButtons = true;
453
+ this.renderTitle = true;
404
454
  this.filterClear = new EventEmitter();
405
455
  this.filterChange = new EventEmitter();
406
456
  this.OPERATORS_TRANSLATION_PREFIX = 'SMART_FILTERS.OPERATORS';
@@ -422,6 +472,10 @@ class BaseFilterComponent {
422
472
  get filter() {
423
473
  return this._filter;
424
474
  }
475
+ set parentForm(form) {
476
+ this._parentForm = form;
477
+ this.updateParentForm();
478
+ }
425
479
  set operator(operator) {
426
480
  var _a;
427
481
  if ((operator === null || operator === void 0 ? void 0 : operator.id) != ((_a = this._operator) === null || _a === void 0 ? void 0 : _a.id)) {
@@ -442,10 +496,7 @@ class BaseFilterComponent {
442
496
  }
443
497
  set operatorUnit(operatorUnit) {
444
498
  // Validate operator unit
445
- if (operatorUnit === undefined) {
446
- this._operatorUnit = undefined;
447
- }
448
- else {
499
+ if (operatorUnit) {
449
500
  const index = this.operatorUnits.findIndex((ou) => ou.id === operatorUnit.id);
450
501
  if (index >= 0) {
451
502
  this._operatorUnit = this.operatorUnits[index];
@@ -454,6 +505,9 @@ class BaseFilterComponent {
454
505
  this._operatorUnit = this.operatorUnits[0];
455
506
  }
456
507
  }
508
+ else {
509
+ this._operatorUnit = undefined;
510
+ }
457
511
  }
458
512
  get operatorUnit() {
459
513
  return this._operatorUnit;
@@ -482,12 +536,14 @@ class BaseFilterComponent {
482
536
  const formValue = {};
483
537
  formValue[this.firstControlKey] = [];
484
538
  formValue[this.secondControlKey] = [];
485
- // this.form.patchValue(formValue);
539
+ // this.form.patchValue(formValue);
486
540
  this.form = this.builder.group(formValue);
487
541
  // this.form[this.firstControlKey] = [];
488
542
  // this.form[this.secondControlKey] = [];
489
543
  this.setupOperators();
490
- this.createActionsComponent();
544
+ if (this.showActionButtons) {
545
+ this.createActionsComponent();
546
+ }
491
547
  }
492
548
  setupOperators() {
493
549
  var _a, _b;
@@ -531,6 +587,16 @@ class BaseFilterComponent {
531
587
  this.clearFilter(false);
532
588
  }
533
589
  }
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
+ }
534
600
  getDestroyer() {
535
601
  return takeUntil(this._destroyed);
536
602
  }
@@ -594,7 +660,9 @@ class BaseFilterComponent {
594
660
  ngOnDestroy() {
595
661
  this._destroyed.next();
596
662
  this._destroyed.complete();
597
- this.actionsContainerRef.destroy();
663
+ if (this.showActionButtons) {
664
+ this.actionsContainerRef.destroy();
665
+ }
598
666
  }
599
667
  }
600
668
  BaseFilterComponent.decorators = [
@@ -607,16 +675,98 @@ BaseFilterComponent.ctorParameters = () => [
607
675
  { type: FormBuilder },
608
676
  { type: TranslateService },
609
677
  { type: PepValidatorService },
610
- { type: Renderer2 }
678
+ { type: Renderer2 },
679
+ { type: PepTypeConvertorService }
611
680
  ];
612
681
  BaseFilterComponent.propDecorators = {
613
682
  field: [{ type: Input }],
614
683
  filter: [{ type: Input }],
684
+ parentForm: [{ type: Input }],
685
+ emitOnChange: [{ type: Input }],
686
+ inline: [{ type: Input }],
687
+ showActionButtons: [{ type: Input }],
688
+ renderTitle: [{ type: Input }],
615
689
  filterClear: [{ type: Output }],
616
690
  filterChange: [{ type: Output }]
617
691
  };
618
692
 
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
+
619
767
  class PepBooleanFilterComponent extends BaseFilterComponent {
768
+ ngOnInit() {
769
+ }
620
770
  // Override
621
771
  getDefaultOperator() {
622
772
  return PepSmartFilterOperators.Equals;
@@ -626,11 +776,19 @@ class PepBooleanFilterComponent extends BaseFilterComponent {
626
776
  const filterValue = { first: this.firstControl.value || false };
627
777
  return filterValue;
628
778
  }
779
+ onRadioChanged() {
780
+ }
781
+ onValueChanged(value) {
782
+ this.firstControl.setValue(value);
783
+ if (this.emitOnChange) {
784
+ this.applyFilter();
785
+ }
786
+ }
629
787
  }
630
788
  PepBooleanFilterComponent.decorators = [
631
789
  { type: Component, args: [{
632
790
  selector: 'pep-boolean-filter',
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>",
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>",
634
792
  styles: [".radio-group{display:flex;flex-direction:column}.radio-group .pep-radio-button.pep-input{height:2.25rem;display:flex}"]
635
793
  },] }
636
794
  ];
@@ -642,6 +800,11 @@ class PepDateFilterComponent extends BaseFilterComponent {
642
800
  this.chooseTimeOptions = [];
643
801
  this.chooseTimeUnitOptions = [];
644
802
  }
803
+ ngOnInit() {
804
+ if (this.inline) {
805
+ this.setControlsWidth();
806
+ }
807
+ }
645
808
  // Override
646
809
  getDefaultOperator() {
647
810
  return PepSmartFilterOperators.InTheLast;
@@ -714,20 +877,58 @@ class PepDateFilterComponent extends BaseFilterComponent {
714
877
  super.setFieldsStateAndValidators();
715
878
  }
716
879
  }
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
+ }
717
898
  onOperatorChanged(value) {
718
899
  const operator = Object.values(PepSmartFilterOperators).find((operator) => operator.id === value);
719
900
  this.operator = operator;
720
901
  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
+ }
721
911
  }
722
912
  onTimeUnitChanged(value) {
723
913
  const operatorUnit = Object.values(PepSmartFilterOperatorUnits).find((operatorUnit) => operatorUnit.id === value);
724
914
  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
+ }
725
926
  }
726
927
  }
727
928
  PepDateFilterComponent.decorators = [
728
929
  { type: Component, args: [{
729
930
  selector: 'pep-date-filter',
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>",
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>",
731
932
  styles: [""]
732
933
  },] }
733
934
  ];
@@ -742,12 +943,36 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
742
943
  super(...arguments);
743
944
  this.options = [];
744
945
  this.searchControl = new FormControl();
946
+ //inline props
947
+ this.selected = '';
948
+ this.inlineOptions = [];
745
949
  this.MAX_OPTIONS_TO_SHOW = 6.35;
746
950
  this.numberOptionsToShowSearch = 10;
747
951
  }
748
952
  ngOnInit() {
749
- var _a;
750
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
+ var _a;
751
976
  if (((_a = this.field.options) === null || _a === void 0 ? void 0 : _a.length) > 0) {
752
977
  this.options = this.field.options.map((opt) => {
753
978
  return { value: opt.value, count: opt.count, selected: false };
@@ -778,10 +1003,6 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
778
1003
  }, 125);
779
1004
  });
780
1005
  }
781
- ngAfterViewInit() {
782
- // Calc for the first time.
783
- this.calcOptionsHeight(this.options.length);
784
- }
785
1006
  initOptionsSelectedValues(selectedValues) {
786
1007
  this.options.forEach((opt) => {
787
1008
  const isValueSelected = selectedValues && selectedValues.includes(opt.value);
@@ -809,13 +1030,20 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
809
1030
  }
810
1031
  // Override
811
1032
  getFilterValue() {
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;
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
+ }
819
1047
  }
820
1048
  // Override
821
1049
  initFilter() {
@@ -826,11 +1054,23 @@ class PepMultiSelectFilterComponent extends BaseFilterComponent {
826
1054
  option.selected = event.checked;
827
1055
  this.firstControl.setValue(this.options.filter((opt) => opt.selected).map((opt) => opt.value), { emitEvent: false });
828
1056
  }
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
+ }
829
1069
  }
830
1070
  PepMultiSelectFilterComponent.decorators = [
831
1071
  { type: Component, args: [{
832
1072
  selector: 'pep-multi-select-filter',
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>",
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>",
834
1074
  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)}"]
835
1075
  },] }
836
1076
  ];
@@ -844,6 +1084,8 @@ class PepNumberFilterComponent extends BaseFilterComponent {
844
1084
  super(...arguments);
845
1085
  this.PepSmartFilterOperators = PepSmartFilterOperators;
846
1086
  this.chooseTypeOptions = [];
1087
+ this.operatorWidth = '38%';
1088
+ this.firstControlWidth = '62%';
847
1089
  }
848
1090
  ngOnInit() {
849
1091
  this.firstControl.valueChanges
@@ -856,6 +1098,7 @@ class PepNumberFilterComponent extends BaseFilterComponent {
856
1098
  .subscribe(() => {
857
1099
  this.setFieldsStateAndValidators();
858
1100
  });
1101
+ this.setControlsWidth();
859
1102
  }
860
1103
  // Override
861
1104
  getDefaultOperator() {
@@ -899,70 +1142,39 @@ class PepNumberFilterComponent extends BaseFilterComponent {
899
1142
  super.setFieldsStateAndValidators();
900
1143
  }
901
1144
  }
1145
+ setControlsWidth() {
1146
+ if (this.operator === PepSmartFilterOperators.NumberRange) {
1147
+ this.operatorWidth = '30%';
1148
+ }
1149
+ else {
1150
+ this.operatorWidth = '38%';
1151
+ }
1152
+ }
902
1153
  onOperatorChanged(value) {
903
1154
  const operator = Object.values(PepSmartFilterOperators).find((operator) => operator.id === value);
904
1155
  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
+ }
905
1168
  }
906
1169
  }
907
1170
  PepNumberFilterComponent.decorators = [
908
1171
  { type: Component, args: [{
909
1172
  selector: 'pep-number-filter',
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>",
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>",
911
1174
  styles: [""]
912
1175
  },] }
913
1176
  ];
914
1177
 
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
-
966
1178
  // Base field
967
1179
  // ------------------------------
968
1180
  class PepSmartFilterBaseField {
@@ -982,6 +1194,17 @@ class PepSmartFilterBaseField {
982
1194
  return this._type;
983
1195
  }
984
1196
  }
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
+ }
985
1208
  // Boolean field
986
1209
  // ------------------------------
987
1210
  class PepSmartFilterBooleanField extends PepSmartFilterBaseField {
@@ -1069,6 +1292,9 @@ class PepSmartFilterPercentageField extends PepSmartFilterNumberBaseField {
1069
1292
  }
1070
1293
  }
1071
1294
 
1295
+ function createTextSmartFilterField(data) {
1296
+ return new PepSmartFilterTextField(data);
1297
+ }
1072
1298
  function createBooleanSmartFilterField(data) {
1073
1299
  return new PepSmartFilterBooleanField(data);
1074
1300
  }
@@ -1096,6 +1322,9 @@ function createPercentageSmartFilterField(data) {
1096
1322
  function createSmartFilterField(data, type) {
1097
1323
  let field;
1098
1324
  switch (type) {
1325
+ case 'text':
1326
+ field = createTextSmartFilterField(data);
1327
+ break;
1099
1328
  case 'boolean':
1100
1329
  field = createBooleanSmartFilterField(data);
1101
1330
  break;
@@ -1138,6 +1367,942 @@ function createSmartFilter(fieldId, operator, first, second, operatorUnit) {
1138
1367
  };
1139
1368
  }
1140
1369
 
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
+
1141
2306
  /*
1142
2307
  * Public API Surface of ngx-lib/smart-filters
1143
2308
  */
@@ -1146,5 +2311,5 @@ function createSmartFilter(fieldId, operator, first, second, operatorUnit) {
1146
2311
  * Generated bundle index. Do not edit.
1147
2312
  */
1148
2313
 
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 };
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 };
1150
2315
  //# sourceMappingURL=pepperi-addons-ngx-lib-smart-filters.js.map