-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGxFilters.bbj
669 lines (637 loc) · 21.4 KB
/
GxFilters.bbj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
rem /**
rem * The package contains the classes for all the supported Filter components
rem */
rem package GxFilters
rem /**
rem * This file is part of the BBjGridExWidget plugin.
rem * (c) Basis Europe <[email protected]>
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
use ::BBjGridExWidget/GxOptions.bbj::GxOptionsBoolean
use ::BBjGridExWidget/GxOptions.bbj::GxOptionsDateTime
use ::BBjGridExWidget/GxRenderers.bbj::GxRendererInterface
use ::BBjGridExWidget/GxLogger.bbj::GxLogger
use com.google.gson.JsonObject
use com.google.gson.JsonArray
rem /**
rem * Column Filter Public Interface
rem *
rem * @author Hyyan Abo Fakher
rem */
interface public GxFilterInterface
rem /**
rem * A constant which holds the client filter real name
rem */
method public static BBjString getFilterName()
rem /**
rem * Convert the filter definition to Json Object
rem *
rem * @return JsonObject The filter as JsonObject
rem */
method public JsonObject getAsJsonObject()
rem /**
rem * Compare two filters
rem *
rem * @param filter! - Another filter instance to compare with
rem *
rem * @return bool - true when they are equal , false otherwise
rem */
method public boolean equals(GxFilterInterface filter!)
interfaceend
rem /**
rem * Compare two filter components
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterComparator
rem /**
rem * Compare two filters
rem *
rem * @param one! - First filter instance
rem * @param two! - Second filter instance
rem *
rem * @return boolean true when they are equal , false otherwise
rem */
method public static boolean compare(GxFilterInterface one! , GxFilterInterface two!)
if(one!.getFilterName() <> two!.getFilterName())
methodret BBjAPI.FALSE
FI
methodret one!.getAsJsonObject().equals(two!.getAsJsonObject())
methodend
classend
rem /**
rem * Filter options constants for texts filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxColumnFilterTextFilterOptions
rem /**
rem * @return BBjString <b>Equals</b>
rem */
method public static BBjString EQUALS()
methodret "equals"
methodend
rem /**
rem * @return BBjString <b>notEquals</b>
rem */
method public static BBjString NOT_EQUALS()
methodret "notEquals"
methodend
rem /**
rem * @return BBjString <b>contains</b>
rem */
method public static BBjString CONTAINS()
methodret "contains"
methodend
rem /**
rem * @return BBjString <b>notContains</b>
rem */
method public static BBjString NOT_CONTAINS()
methodret "notContains"
methodend
rem /**
rem * @return BBjString <b>startsWith</b>
rem */
method public static BBjString STARTS_WITH()
methodret "startsWith"
methodend
rem /**
rem * @return BBjString <b>endsWith</b>
rem */
method public static BBjString ENDS_WITH()
methodret "endsWith"
methodend
classend
rem /**
rem * Filter options constants for date/time filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxColumnFilterDateTimeFilterOptions
rem /**
rem * @return BBjString <b>Equals</b>
rem */
method public static BBjString EQUALS()
methodret "equals"
methodend
rem /**
rem * @return BBjString <b>notEquals</b>
rem */
method public static BBjString NOT_EQUALS()
methodret "notEquals"
methodend
rem /**
rem * @return BBjString <b>greaterThan</b>
rem */
method public static BBjString GREATER_THAN()
methodret "greaterThan"
methodend
rem /**
rem * @return BBjString <b>lessThan</b>
rem */
method public static BBjString LESS_THAN()
methodret "lessThan"
methodend
rem /**
rem * @return BBjString <b>IN_RANGE</b>
rem */
method public static BBjString IN_RANGE()
methodret "inRange"
methodend
classend
rem /**
rem * Filter options constants for numbers filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxColumnFilterNumberFilterOptions extends GxColumnFilterDateTimeFilterOptions
rem /**
rem * @return BBjString <b>greaterThanOrEqual</b>
rem */
method public static BBjString GREATER_THAN_OR_EQUALS()
methodret "greaterThanOrEqual"
methodend
rem /**
rem * @return BBjString <b>lessThanOrEqual</b>
rem */
method public static BBjString LESS_THAN_OR_EQUALS()
methodret "lessThanOrEqual"
methodend
classend
rem /**
rem * The class holds the shared ag filter options between all filter types. This is the base class for all ag filter types
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxColumnFilterAG implements GxFilterInterface
rem /**
rem *Set to true to have the filter use an Apply button. If the Apply button is present, then the filter is only applied after the user hits the Apply button.
rem */
field public BBjNumber ApplyButton! = 0
rem /**
rem * Set to true to have the filter use a Clear button. The Clear button will clear the details of the filter thus resetting it.
rem */
field public BBjNumber ClearButton! = 0
rem /**
rem * Set to true to have the filter use a Reset button. The Reset button will clear the details of the filter and any active filters on that column.
rem */
field public BBjNumber RestButton! = 0
rem /**
rem * The number of milliseconds to debounce by before applying the filter
rem */
field public BBjNumber DebounceMs! = 500
rem /**
rem * If set to 'clear', then setting data into the grid will clear (reset) the filter If set to 'keep' then the grid will keep it's currently set filter. The default is 'clear'
rem *
rem * @deprecated since version 1.7.0. This option has not replacement. The `keep` setting is now the default.
rem */
field public BBjString NewRowsAction! = GxColumnFilterAG.NEW_ROWS_ACTION_CLEAR()
rem /**
rem * If true, the filter will only offer Condition 1.
rem */
field public BBjNumber SuppressAndOrCondition! = 0
rem /**
rem * What Filter Options to present to the user.
rem * By default all supported options are presented
rem *
rem * @see GxColumnFilterTextFilterOptions
rem * @see GxColumnFilterNumberFilterOptions
rem */
field public JsonArray FilterOptions! = new JsonArray()
rem /**
rem * The default Filter Options to be selected.
rem * By default it is Equals
rem */
field public BBjString DefaultOption! = null()
rem /**
rem * A constant which describes the NewRowsAction behavior
rem *
rem * @return BBjString <b>clear</b>
rem *
rem * @deprecated since version 1.7.0
rem */
method public static BBjString NEW_ROWS_ACTION_CLEAR()
methodret "clear"
methodend
rem /**
rem * A constant which describes the NewRowsAction behavior
rem *
rem * @return BBjString <b>keep</b>
rem *
rem * @deprecated since version 1.7.0
rem */
method public static BBjString NEW_ROWS_ACTION_KEEP()
methodret "keep"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonArray buttons!
declare JsonObject json!
buttons! = new JsonArray()
if(#getApplyButton().booleanValue()) then
buttons!.add("apply")
fi
if(#getClearButton().booleanValue()) then
buttons!.add("clear")
fi
if(#getRestButton().booleanValue()) then
buttons!.add("reset")
fi
json! = new JsonObject()
json!.addProperty("debounceMs" , iff(!#getApplyButton().booleanValue() , #getDebounceMs().longValue() , empty!),err=*next)
json!.addProperty("suppressAndOrCondition" , #getSuppressAndOrCondition().booleanValue(),err=*next)
json!.addProperty("defaultOption" , #getDefaultOption(),err=*next)
json!. add("filterOptions" , iff(#getFilterOptions().size() > 0 , #getFilterOptions() , empty!),err=*next)
json!. add("buttons" , buttons!,err=*next)
methodret json!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public boolean equals(GxFilterInterface filter!)
methodret GxFilterComparator.compare(#this!, filter!)
methodend
classend
rem /**
rem * The class represents the default ag-grid text filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterText extends GxColumnFilterAG
rem /**
rem * Set to true to make text filtering case sensitive, otherwise the filtering will be case insensitive
rem */
field public BBjNumber CaseSensitive! = 0
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getFilterName()
methodret "agTextColumnFilter"
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("caseSensitive" , #getCaseSensitive().booleanValue(),err=*next)
methodret json!
methodend
classend
rem /**
rem * The class represents the default ag-grid number filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterNumber extends GxColumnFilterAG
rem /**
rem * If true then doing 'inRange' filter option will include values equal to the start and end of the range.
rem */
field public BBjNumber InRangeInclusive! = 1
rem /**
rem * If true then blank (null or undefined) values will pass the 'equals' filter option.
rem */
field public BBjNumber IncludeBlanksInEquals! = 0
rem /**
rem * If true then blank (null or undefined) values will pass the 'lessThan' and 'lessThanOrEqual' filter options.
rem */
field public BBjNumber IncludeBlanksInLessThan! = 0
rem /**
rem * If true then blank (null or undefined) values will pass the 'greaterThan' and 'greaterThanOrEqual' filter options.
rem */
field public BBjNumber IncludeBlanksInGreaterThan! = 0
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getFilterName()
methodret "agNumberColumnFilter"
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("inRangeInclusive" , #getInRangeInclusive().booleanValue(),err=*next)
json!.addProperty("includeBlanksInEquals" , #getIncludeBlanksInEquals().booleanValue(),err=*next)
json!.addProperty("includeBlanksInLessThan" , #getIncludeBlanksInLessThan().booleanValue(),err=*next)
json!.addProperty("includeBlanksInGreaterThan" , #getIncludeBlanksInGreaterThan().booleanValue(),err=*next)
methodret json!
methodend
classend
rem /**
rem * The class represents the default ag-grid date filter
rem *
rem * @author Hyyan Abo Fakher
rem *
rem * @deprecated since version 0.101.0, GxFilterDate is deprecated. Use GxFilterBasicDate instead.
rem */
class public GxFilterDate extends GxFilterNumber
method public GxFilterDate()
#super!()
GxLogger.warn("GxFilters","since version 0.101.0, GxFilterDate is deprecated. Use GxFilterBasicDate instead.")
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public static BBjString getFilterName()
methodret "agDateColumnFilter"
methodend
classend
rem /**
rem * GxFilterSetFilter allow you to filter on set data, influenced by how filters work in Microsoft Excel
rem *
rem * <br><b><small>#Enterprise</small></b>
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterSetFilter extends GxColumnFilterAG
rem /**
rem * Provide a cell renderer for each value
rem */
field public GxRendererInterface CellRenderer! = null()
rem /**
rem * The values to display in the filter. If this is not set, then the filter will takes its values
rem * from what is loaded in the table.
rem * Setting it allows you to set values where the value may not be present in the list
rem * (for example, if you want to show all states in America so that the user is not confused by missing states, even though states are missing from the data set in the grid)
rem */
field public JsonArray Values! = new JsonArray()
rem /**
rem * Set to true to have the values inside the set filter NOT refresh after values are changed inside the grid.
rem *
rem * @deprecated since version 1.7.0. This option has no replacement
rem */
field public BBjNumber SuppressSyncValuesAfterDataChange! = 0
rem /**
rem * Set to true to stop the filter from removing values that are no longer available (like what Excel does).
rem *
rem * since version 1.7.0. This option has been deprecated with no replacement.
rem */
field public BBjNumber SuppressRemoveEntries! = 0
rem /**
rem * If true, sorting will not be done on the set filter values. Use this if providing your own values and don't want them sorted as you are providing in the order you want.
rem */
field public BBjNumber SuppressSorting! = 0
rem /**
rem * Set to true to hide the mini filter.
rem */
field public BBjNumber SuppressMiniFilter! = 0
rem /**
rem * Set to true to remove the "select all" checkbox.
rem */
field public BBjNumber SuppressSelectAll! = 0
rem /**
rem * Set this to true to instead show all values as de-selected by default.
rem * Default: false
rem */
field public BBjNumber DefaultToNothingSelected! = 0
rem /**
rem * Set to true to apply the Set Filter immediately when the user is typing in the Mini Filter.
rem * Default: false
rem */
field public BBjNumber ApplyMiniFilterWhileTyping! = 0
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getFilterName()
methodret "agSetColumnFilter"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("suppressSorting" , #getSuppressSorting().booleanValue() , err=*next)
json!.addProperty("suppressMiniFilter" , #getSuppressMiniFilter().booleanValue() , err=*next)
json!.addProperty("suppressSelectAll" , #getSuppressSelectAll().booleanValue() , err=*next)
json!.addProperty("defaultToNothingSelected" , #getDefaultToNothingSelected().booleanValue() , err=*next)
json!.addProperty("applyMiniFilterWhileTyping" , #getApplyMiniFilterWhileTyping().booleanValue() , err=*next)
json!.add("values", iff(#getValues().size() > 0 , #getValues() , empty!), err=*next)
renderer! = #getCellRenderer()
if(renderer! <> null()) then
json!.addProperty("cellRenderer" , renderer!.getCellRendererName(),err=*next)
json!. add("cellRendererParams" , renderer!.getAsJsonObject(),err=*next)
FI
methodret json!
methodend
classend
rem /**
rem * The class represents the boolean filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterBasicBoolean extends GxOptionsBoolean implements GxFilterInterface
rem /**
rem * The value to use when when the component needs to render true values.
rem * in case it is null() then we use the first item in PossibleTrueValues!
rem */
field public BBjString UsedTrueValue! = null()
rem /**
rem * The value to use when when the component needs to render false values.
rem * in case it is null() then we use the first item in PossibleFalseValues!
rem */
field public BBjString UsedFalseValue! = null()
rem /**
rem * True value translation
rem */
field public BBjString TrueValue! = "✔ True"
rem /**
rem * False value translation
rem */
field public BBjString FalseValue! = "✘ False"
rem /**
rem * None value Translation
rem */
field public BBjString NoneValue! = "∅ None"
rem /**
rem *Set to true to have the filter use an Apply button. If the Apply button is present, then the filter is only applied after the user hits the Apply button.
rem */
field public BBjNumber ApplyButton! = 0
rem /**
rem * Set to true to have the filter use a Clear button. The Clear button will clear the details of the filter thus resetting it.
rem */
field public BBjNumber ClearButton! = 0
rem /**
rem * Set to true to have the filter use a Reset button. The Reset button will clear the details of the filter and any active filters on that column.
rem */
field public BBjNumber RestButton! = 0
rem /**
rem * @override
rem */
method public static BBjString getFilterName()
methodret "BooleanFilter"
methodend
rem /**
rem * @override
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("booleanUsedTrueValue",#getUsedTrueValue(), err=*next)
json!.addProperty("booleanUsedFalseValue",#getUsedFalseValue(), err=*next)
json!.addProperty("applyButton" , #getApplyButton().booleanValue(),err=*next)
json!.addProperty("clearButton" , #getClearButton().booleanValue(),err=*next)
json!.addProperty("resetButton" , #getRestButton().booleanValue(),err=*next)
translation! = new JsonObject()
translation!.addProperty("true" , #getTrueValue(),err=*next)
translation!.addProperty("false" , #getFalseValue(),err=*next)
translation!.addProperty("reset" , #getNoneValue(),err=*next)
json!. add("booleanFilterTranslation" , translation!)
methodret json!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public boolean equals(GxFilterInterface filter!)
methodret GxFilterComparator.compare(#this!, filter!)
methodend
classend
rem /**
rem * The class represents the date time filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterBasicDateTime extends GxOptionsDateTime implements GxFilterInterface
rem /**
rem *Set to true to have the filter use an Apply button. If the Apply button is present, then the filter is only applied after the user hits the Apply button.
rem */
field public BBjNumber ApplyButton! = 0
rem /**
rem * Set to true to have the filter use a Clear button. The Clear button will clear the details of the filter thus resetting it.
rem */
field public BBjNumber ClearButton! = 0
rem /**
rem * Set to true to have the filter use a Reset button. The Reset button will clear the details of the filter and any active filters on that column.
rem */
field public BBjNumber RestButton! = 0
rem /**
rem * What Filter Options to present to the user.
rem * By default all supported options are presented
rem *
rem * @see GxColumnFilterDateTimeFilterOptions
rem */
field public JsonArray FilterOptions! = new JsonArray()
rem /**
rem * The default Filter Options to be selected.
rem * By default it is Equals
rem */
field public BBjString DefaultOption! = null()
rem /**
rem * If true, the filter will only offer Condition 1.
rem */
field public BBjNumber SuppressAndOrCondition! = 0
rem /**
rem * If true then doing 'inRange' filter option will include values equal to the start and end of the range.
rem */
field public BBjNumber InRangeInclusive! = 1
rem /**
rem * Construct new GxFilterBasicDateTime
rem *
rem * @param mask! BBj date mask
rem */
method public GxFilterBasicDateTime(BBjString mask!)
#setMask(mask!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getFilterName()
methodret "DateTimeFilter"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("applyButton" , #getApplyButton().booleanValue(),err=*next)
json!.addProperty("clearButton" , #getClearButton().booleanValue(),err=*next)
json!.addProperty("resetButton" , #getRestButton().booleanValue(),err=*next)
json!.addProperty("suppressAndOrCondition" , #getSuppressAndOrCondition().booleanValue(),err=*next)
json!.addProperty("inRangeInclusive" , #getInRangeInclusive().booleanValue(),err=*next)
json!.addProperty("defaultOption" , #getDefaultOption(),err=*next)
json!. add("filterOptions" , iff(#getFilterOptions().size() > 0 , #getFilterOptions() , empty!),err=*next)
methodret json!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public boolean equals(GxFilterInterface filter!)
methodret GxFilterComparator.compare(#this!, filter!)
methodend
classend
rem /**
rem * Alias for GxFilterBasicDateTime
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterBasicTimestamp extends GxFilterBasicDateTime
rem /**
rem * Construct new GxFilterBasicTimestamp
rem *
rem * @param mask! BBj date mask
rem */
method public GxFilterBasicTimestamp(BBjString mask!)
#super!(mask!)
methodend
classend
rem /**
rem * The class represents the date filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterBasicDate extends GxFilterBasicDateTime
rem /**
rem * Construct a new GxFilterBasicDateTime
rem */
method public GxFilterBasicDate()
#setEnableTime(0)
#setMask("%Y/%Mz/%Dz")
methodend
rem /**
rem * Construct new GxFilterBasicDate
rem *
rem * @param mask! BBj date mask
rem */
method public GxFilterBasicDate(BBjString mask!)
#super!(mask!)
#setEnableTime(0)
methodend
classend
rem /**
rem * The class represents the time filter
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFilterBasicTime extends GxFilterBasicDateTime
rem /**
rem * Construct a new GxFilterBasicTime
rem */
method public GxFilterBasicTime()
#setEnableTime(1)
#setEnableCalendar(0)
#setMask("%Hz:%mz:%sz")
methodend
rem /**
rem * Construct new GxFilterBasicTime
rem *
rem * @param mask! BBj date mask
rem */
method public GxFilterBasicTime(BBjString mask!)
#super!(mask!)
#setEnableTime(1)
#setEnableCalendar(0)
methodend
classend