datatables.net-searchbuilder 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/dataTables.searchBuilder.js +240 -193
- package/js/dataTables.searchBuilder.min.js +132 -131
- package/package.json +1 -1
- package/types/criteria.d.ts +19 -6
- package/types/group.d.ts +5 -2
- package/types/index.d.ts +1 -1
- package/types/searchBuilder.d.ts +7 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! SearchBuilder 1.3.
|
|
1
|
+
/*! SearchBuilder 1.3.2
|
|
2
2
|
* ©SpryMedia Ltd - datatables.net/license/mit
|
|
3
3
|
*/
|
|
4
4
|
(function () {
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
var $$2;
|
|
8
8
|
var dataTable$2;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
function moment() {
|
|
10
|
+
return window.moment;
|
|
11
|
+
}
|
|
12
|
+
function luxon() {
|
|
13
|
+
return window.luxon;
|
|
14
|
+
}
|
|
13
15
|
/**
|
|
14
16
|
* Sets the value of jQuery for use in the file
|
|
15
17
|
*
|
|
@@ -23,10 +25,11 @@
|
|
|
23
25
|
* The Criteria class is used within SearchBuilder to represent a search criteria
|
|
24
26
|
*/
|
|
25
27
|
var Criteria = /** @class */ (function () {
|
|
26
|
-
function Criteria(table, opts, topGroup, index, depth) {
|
|
28
|
+
function Criteria(table, opts, topGroup, index, depth, serverData) {
|
|
27
29
|
var _this = this;
|
|
28
30
|
if (index === void 0) { index = 0; }
|
|
29
31
|
if (depth === void 0) { depth = 1; }
|
|
32
|
+
if (serverData === void 0) { serverData = undefined; }
|
|
30
33
|
// Check that the required version of DataTables is included
|
|
31
34
|
if (!dataTable$2 || !dataTable$2.versionCheck || !dataTable$2.versionCheck('1.10.0')) {
|
|
32
35
|
throw new Error('SearchPane requires DataTables 1.10 or newer');
|
|
@@ -48,6 +51,7 @@
|
|
|
48
51
|
index: index,
|
|
49
52
|
origData: undefined,
|
|
50
53
|
preventRedraw: false,
|
|
54
|
+
serverData: serverData,
|
|
51
55
|
topGroup: topGroup,
|
|
52
56
|
type: '',
|
|
53
57
|
value: []
|
|
@@ -81,6 +85,8 @@
|
|
|
81
85
|
.addClass(this.classes.button)
|
|
82
86
|
.attr('title', this.s.dt.i18n('searchBuilder.deleteTitle', i18n.deleteTitle))
|
|
83
87
|
.attr('type', 'button'),
|
|
88
|
+
inputCont: $$2('<div/>')
|
|
89
|
+
.addClass(this.classes.inputCont),
|
|
84
90
|
// eslint-disable-next-line no-useless-escape
|
|
85
91
|
left: $$2('<button/>')
|
|
86
92
|
.html(this.s.dt.i18n('searchBuilder.left', i18n.left))
|
|
@@ -115,15 +121,8 @@
|
|
|
115
121
|
val.addClass(this.classes.greyscale);
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
|
-
// For responsive design, adjust the criterias properties on the following events
|
|
119
|
-
this.s.dt.on('draw.dtsb', function () {
|
|
120
|
-
_this._adjustCriteria();
|
|
121
|
-
});
|
|
122
|
-
this.s.dt.on('buttons-action.dtsb', function () {
|
|
123
|
-
_this._adjustCriteria();
|
|
124
|
-
});
|
|
125
124
|
$$2(window).on('resize.dtsb', dataTable$2.util.throttle(function () {
|
|
126
|
-
_this.
|
|
125
|
+
_this.s.topGroup.trigger('dtsb-redrawLogic');
|
|
127
126
|
}));
|
|
128
127
|
this._buildCriteria();
|
|
129
128
|
return this;
|
|
@@ -142,17 +141,28 @@
|
|
|
142
141
|
.replace(/>/g, '>')
|
|
143
142
|
.replace(/"/g, '"');
|
|
144
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Parses formatted numbers down to a form where they can be compared
|
|
146
|
+
*
|
|
147
|
+
* @param val the value to convert
|
|
148
|
+
* @returns the converted value
|
|
149
|
+
*/
|
|
150
|
+
Criteria.parseNumFmt = function (val) {
|
|
151
|
+
return +val.replace(/(?!^-)[^0-9.]/g, '');
|
|
152
|
+
};
|
|
145
153
|
/**
|
|
146
154
|
* Adds the left button to the criteria
|
|
147
155
|
*/
|
|
148
|
-
Criteria.prototype.updateArrows = function (hasSiblings
|
|
156
|
+
Criteria.prototype.updateArrows = function (hasSiblings) {
|
|
149
157
|
if (hasSiblings === void 0) { hasSiblings = false; }
|
|
150
|
-
if (redraw === void 0) { redraw = true; }
|
|
151
158
|
// Empty the container and append all of the elements in the correct order
|
|
152
159
|
this.dom.container.children().detach();
|
|
153
160
|
this.dom.container
|
|
154
161
|
.append(this.dom.data)
|
|
155
162
|
.append(this.dom.condition)
|
|
163
|
+
.append(this.dom.inputCont);
|
|
164
|
+
this.dom.inputCont
|
|
165
|
+
.empty()
|
|
156
166
|
.append(this.dom.value[0]);
|
|
157
167
|
this.setListeners();
|
|
158
168
|
// Trigger the inserted events for the value elements as they are inserted
|
|
@@ -160,7 +170,7 @@
|
|
|
160
170
|
this.dom.value[0].trigger('dtsb-inserted');
|
|
161
171
|
}
|
|
162
172
|
for (var i = 1; i < this.dom.value.length; i++) {
|
|
163
|
-
this.dom.
|
|
173
|
+
this.dom.inputCont.append(this.dom.value[i]);
|
|
164
174
|
this.dom.value[i].trigger('dtsb-inserted');
|
|
165
175
|
}
|
|
166
176
|
// If this is a top level criteria then don't let it move left
|
|
@@ -176,10 +186,6 @@
|
|
|
176
186
|
}
|
|
177
187
|
this.dom.buttons.append(this.dom["delete"]);
|
|
178
188
|
this.dom.container.append(this.dom.buttons);
|
|
179
|
-
if (redraw) {
|
|
180
|
-
// A different combination of arrows and selectors may lead to a need for responsive to be triggered
|
|
181
|
-
this._adjustCriteria();
|
|
182
|
-
}
|
|
183
189
|
};
|
|
184
190
|
/**
|
|
185
191
|
* Destroys the criteria, removing listeners and container from the dom
|
|
@@ -290,8 +296,8 @@
|
|
|
290
296
|
for (var i = 0; i < this.s.value.length; i++) {
|
|
291
297
|
if (this.s.value[i] &&
|
|
292
298
|
this.s.value[i].length > 0 &&
|
|
293
|
-
moment(this.s.value[i], this.s.dateFormat, true).isValid()) {
|
|
294
|
-
this.s.value[i] = moment(this.s.value[i], this.s.dateFormat).
|
|
299
|
+
moment()(this.s.value[i], this.s.dateFormat, true).isValid()) {
|
|
300
|
+
this.s.value[i] = moment()(this.s.value[i], this.s.dateFormat).format('YYYY-MM-DD HH:mm:ss');
|
|
295
301
|
}
|
|
296
302
|
}
|
|
297
303
|
}
|
|
@@ -299,8 +305,8 @@
|
|
|
299
305
|
for (var i = 0; i < this.s.value.length; i++) {
|
|
300
306
|
if (this.s.value[i] &&
|
|
301
307
|
this.s.value[i].length > 0 &&
|
|
302
|
-
luxon.DateTime.fromFormat(this.s.value[i], this.s.dateFormat).invalid === null) {
|
|
303
|
-
this.s.value[i] = luxon.DateTime.fromFormat(this.s.value[i], this.s.dateFormat).
|
|
308
|
+
luxon().DateTime.fromFormat(this.s.value[i], this.s.dateFormat).invalid === null) {
|
|
309
|
+
this.s.value[i] = luxon().DateTime.fromFormat(this.s.value[i], this.s.dateFormat).toFormat('yyyy-MM-dd HH:mm:ss');
|
|
304
310
|
}
|
|
305
311
|
}
|
|
306
312
|
}
|
|
@@ -482,7 +488,7 @@
|
|
|
482
488
|
var val = _c[_b];
|
|
483
489
|
// If this criteria was previously active in the search then remove
|
|
484
490
|
// it from the search and trigger a new search
|
|
485
|
-
if (_this.s.filled && val !== undefined && _this.dom.
|
|
491
|
+
if (_this.s.filled && val !== undefined && _this.dom.inputCont.has(val[0]).length !== 0) {
|
|
486
492
|
_this.s.filled = false;
|
|
487
493
|
_this.s.dt.draw();
|
|
488
494
|
_this.setListeners();
|
|
@@ -499,52 +505,16 @@
|
|
|
499
505
|
}
|
|
500
506
|
});
|
|
501
507
|
};
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if ($$2(document).has(this.dom.container).length === 0) {
|
|
508
|
+
Criteria.prototype.setupButtons = function () {
|
|
509
|
+
if (window.innerWidth > 550) {
|
|
510
|
+
this.dom.container.removeClass(this.classes.vertical);
|
|
511
|
+
this.dom.buttons.css('left', null);
|
|
512
|
+
this.dom.buttons.css('top', null);
|
|
508
513
|
return;
|
|
509
514
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
// Calculate the width and right value of the outmost value element
|
|
514
|
-
if (outmostval !== undefined && this.dom.container.has(outmostval[0]).length !== 0) {
|
|
515
|
-
valWidth = outmostval.outerWidth(true);
|
|
516
|
-
valRight = outmostval.offset().left + valWidth;
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
var leftOffset = this.dom.left.offset();
|
|
522
|
-
var rightOffset = this.dom.right.offset();
|
|
523
|
-
var clearOffset = this.dom["delete"].offset();
|
|
524
|
-
var hasLeft = this.dom.container.has(this.dom.left[0]).length !== 0;
|
|
525
|
-
var hasRight = this.dom.container.has(this.dom.right[0]).length !== 0;
|
|
526
|
-
var buttonsLeft = hasLeft ?
|
|
527
|
-
leftOffset.left :
|
|
528
|
-
hasRight ?
|
|
529
|
-
rightOffset.left :
|
|
530
|
-
clearOffset.left;
|
|
531
|
-
// Perform the responsive calculations and redraw where necessary
|
|
532
|
-
if ((buttonsLeft - valRight < 15 ||
|
|
533
|
-
hasLeft && leftOffset.top !== clearOffset.top ||
|
|
534
|
-
hasRight && rightOffset.top !== clearOffset.top) &&
|
|
535
|
-
!this.dom.container.parent().hasClass(this.classes.vertical)) {
|
|
536
|
-
this.dom.container.parent().addClass(this.classes.vertical);
|
|
537
|
-
this.s.topGroup.trigger('dtsb-redrawContents-noDraw');
|
|
538
|
-
}
|
|
539
|
-
else if (buttonsLeft -
|
|
540
|
-
(this.dom.data.offset().left +
|
|
541
|
-
this.dom.data.outerWidth(true) +
|
|
542
|
-
this.dom.condition.outerWidth(true) +
|
|
543
|
-
valWidth) > 15
|
|
544
|
-
&& this.dom.container.parent().hasClass(this.classes.vertical)) {
|
|
545
|
-
this.dom.container.parent().removeClass(this.classes.vertical);
|
|
546
|
-
this.s.topGroup.trigger('dtsb-redrawContents-noDraw');
|
|
547
|
-
}
|
|
515
|
+
this.dom.container.addClass(this.classes.vertical);
|
|
516
|
+
this.dom.buttons.css('left', this.dom.data.innerWidth());
|
|
517
|
+
this.dom.buttons.css('top', this.dom.data.position().top);
|
|
548
518
|
};
|
|
549
519
|
/**
|
|
550
520
|
* Builds the elements of the dom together
|
|
@@ -557,15 +527,17 @@
|
|
|
557
527
|
this.dom.container
|
|
558
528
|
.append(this.dom.data)
|
|
559
529
|
.append(this.dom.condition);
|
|
530
|
+
this.dom.inputCont.empty();
|
|
560
531
|
for (var _i = 0, _a = this.dom.value; _i < _a.length; _i++) {
|
|
561
532
|
var val = _a[_i];
|
|
562
533
|
val.append(this.dom.valueTitle);
|
|
563
|
-
this.dom.
|
|
534
|
+
this.dom.inputCont.append(val);
|
|
564
535
|
}
|
|
565
536
|
// Add buttons to container
|
|
566
|
-
this.dom.
|
|
537
|
+
this.dom.buttons
|
|
567
538
|
.append(this.dom["delete"])
|
|
568
539
|
.append(this.dom.right);
|
|
540
|
+
this.dom.container.append(this.dom.inputCont).append(this.dom.buttons);
|
|
569
541
|
this.setListeners();
|
|
570
542
|
};
|
|
571
543
|
/**
|
|
@@ -601,10 +573,15 @@
|
|
|
601
573
|
// Call the init function to get the value elements for this condition
|
|
602
574
|
this.dom.value = [].concat(this.s.conditions[this.s.condition].init(this, Criteria.updateListener));
|
|
603
575
|
if (this.dom.value.length > 0 && this.dom.value[0] !== undefined) {
|
|
604
|
-
this.dom.
|
|
576
|
+
this.dom.inputCont
|
|
577
|
+
.empty()
|
|
578
|
+
.append(this.dom.value[0])
|
|
579
|
+
.insertAfter(this.dom.condition);
|
|
580
|
+
this.dom.value[0].trigger('dtsb-inserted');
|
|
605
581
|
// Insert all of the value elements
|
|
606
582
|
for (var i = 1; i < this.dom.value.length; i++) {
|
|
607
|
-
this.dom.
|
|
583
|
+
this.dom.inputCont.append(this.dom.value[i]);
|
|
584
|
+
this.dom.value[i].trigger('dtsb-inserted');
|
|
608
585
|
}
|
|
609
586
|
}
|
|
610
587
|
}
|
|
@@ -654,11 +631,11 @@
|
|
|
654
631
|
Criteria.prototype._populateCondition = function () {
|
|
655
632
|
var conditionOpts = [];
|
|
656
633
|
var conditionsLength = Object.keys(this.s.conditions).length;
|
|
634
|
+
var colInits = this.s.dt.settings()[0].aoColumns;
|
|
635
|
+
var column = +this.dom.data.children('option:selected').val();
|
|
657
636
|
// If there are no conditions stored then we need to get them from the appropriate type
|
|
658
637
|
if (conditionsLength === 0) {
|
|
659
|
-
var column = +this.dom.data.children('option:selected').val();
|
|
660
638
|
this.s.type = this.s.dt.columns().type().toArray()[column];
|
|
661
|
-
var colInits = this.s.dt.settings()[0].aoColumns;
|
|
662
639
|
if (colInits !== undefined) {
|
|
663
640
|
var colInit = colInits[column];
|
|
664
641
|
if (colInit.searchBuilderType !== undefined && colInit.searchBuilderType !== null) {
|
|
@@ -713,9 +690,15 @@
|
|
|
713
690
|
// Serverside processing does not supply the options for the select elements
|
|
714
691
|
// Instead input elements need to be used for these instead
|
|
715
692
|
if (this.s.dt.page.info().serverSide && conditionObj[condition].init === Criteria.initSelect) {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
693
|
+
var col = colInits[column];
|
|
694
|
+
if (this.s.serverData[col.data]) {
|
|
695
|
+
conditionObj[condition].init = Criteria.initSelectSSP;
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
conditionObj[condition].init = Criteria.initInput;
|
|
699
|
+
}
|
|
700
|
+
conditionObj[condition].inputValue = Criteria.inputValueSelect;
|
|
701
|
+
conditionObj[condition].isInputValid = Criteria.isInputValidSelect;
|
|
719
702
|
}
|
|
720
703
|
this.s.conditions[condition] = conditionObj[condition];
|
|
721
704
|
var condName = conditionObj[condition].conditionName;
|
|
@@ -763,7 +746,44 @@
|
|
|
763
746
|
var opt = conditionOpts_1[_d];
|
|
764
747
|
this.dom.condition.append(opt);
|
|
765
748
|
}
|
|
766
|
-
|
|
749
|
+
// Selecting a default condition if one is set
|
|
750
|
+
if (colInits[column].searchBuilder && colInits[column].searchBuilder.defaultCondition) {
|
|
751
|
+
var defaultCondition = colInits[column].searchBuilder.defaultCondition;
|
|
752
|
+
// If it is a number just use it as an index
|
|
753
|
+
if (typeof defaultCondition === 'number') {
|
|
754
|
+
this.dom.condition.prop('selectedIndex', defaultCondition);
|
|
755
|
+
this.dom.condition.trigger('change');
|
|
756
|
+
}
|
|
757
|
+
// If it is a string then things get slightly more tricly
|
|
758
|
+
else if (typeof defaultCondition === 'string') {
|
|
759
|
+
// We need to check each condition option to see if any will match
|
|
760
|
+
for (var i = 0; i < conditionOpts.length; i++) {
|
|
761
|
+
// Need to check against the stored conditions so we can match the token "cond" to the option
|
|
762
|
+
for (var _e = 0, _f = Object.keys(this.s.conditions); _e < _f.length; _e++) {
|
|
763
|
+
var cond = _f[_e];
|
|
764
|
+
var condName = this.s.conditions[cond].conditionName;
|
|
765
|
+
if (
|
|
766
|
+
// If the conditionName matches the text of the option
|
|
767
|
+
(typeof condName === 'string' ? condName : condName(this.s.dt, this.c.i18n)) ===
|
|
768
|
+
conditionOpts[i].text() &&
|
|
769
|
+
// and the tokens match
|
|
770
|
+
cond === defaultCondition) {
|
|
771
|
+
// Select that option
|
|
772
|
+
this.dom.condition
|
|
773
|
+
.prop('selectedIndex', this.dom.condition.children().toArray().indexOf(conditionOpts[i][0]))
|
|
774
|
+
.removeClass(this.classes.italic);
|
|
775
|
+
this.dom.condition.trigger('change');
|
|
776
|
+
i = conditionOpts.length;
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
// If not default set then default to 0, the title
|
|
784
|
+
else {
|
|
785
|
+
this.dom.condition.prop('selectedIndex', 0);
|
|
786
|
+
}
|
|
767
787
|
};
|
|
768
788
|
/**
|
|
769
789
|
* Populates the data select element
|
|
@@ -870,9 +890,10 @@
|
|
|
870
890
|
var val = _a[_i];
|
|
871
891
|
_loop_4(val);
|
|
872
892
|
}
|
|
873
|
-
var children = this.dom.
|
|
874
|
-
if (children.length >
|
|
875
|
-
|
|
893
|
+
var children = this.dom.inputCont.children();
|
|
894
|
+
if (children.length > 1) {
|
|
895
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
896
|
+
for (var i = 0; i < children.length; i++) {
|
|
876
897
|
$$2(children[i]).remove();
|
|
877
898
|
}
|
|
878
899
|
}
|
|
@@ -889,10 +910,11 @@
|
|
|
889
910
|
if (loadedCriteria !== undefined && loadedCriteria.value !== undefined) {
|
|
890
911
|
this.s.value = loadedCriteria.value;
|
|
891
912
|
}
|
|
913
|
+
this.dom.inputCont.empty();
|
|
892
914
|
// Insert value elements and trigger the inserted event
|
|
893
915
|
if (this.dom.value[0] !== undefined) {
|
|
894
916
|
this.dom.value[0]
|
|
895
|
-
.
|
|
917
|
+
.appendTo(this.dom.inputCont)
|
|
896
918
|
.trigger('dtsb-inserted');
|
|
897
919
|
}
|
|
898
920
|
for (var i = 1; i < this.dom.value.length; i++) {
|
|
@@ -957,6 +979,7 @@
|
|
|
957
979
|
dropDown: 'dtsb-dropDown',
|
|
958
980
|
greyscale: 'dtsb-greyscale',
|
|
959
981
|
input: 'dtsb-input',
|
|
982
|
+
inputCont: 'dtsb-inputCont',
|
|
960
983
|
italic: 'dtsb-italic',
|
|
961
984
|
joiner: 'dtsp-joiner',
|
|
962
985
|
left: 'dtsb-left',
|
|
@@ -1102,6 +1125,64 @@
|
|
|
1102
1125
|
}
|
|
1103
1126
|
return el;
|
|
1104
1127
|
};
|
|
1128
|
+
/**
|
|
1129
|
+
* Default initialisation function for select conditions
|
|
1130
|
+
*/
|
|
1131
|
+
Criteria.initSelectSSP = function (that, fn, preDefined) {
|
|
1132
|
+
if (preDefined === void 0) { preDefined = null; }
|
|
1133
|
+
that.dom.valueTitle.prop('selected', true);
|
|
1134
|
+
// Declare select element to be used with all of the default classes and listeners.
|
|
1135
|
+
var el = $$2('<select/>')
|
|
1136
|
+
.addClass(Criteria.classes.value)
|
|
1137
|
+
.addClass(Criteria.classes.dropDown)
|
|
1138
|
+
.addClass(Criteria.classes.italic)
|
|
1139
|
+
.addClass(Criteria.classes.select)
|
|
1140
|
+
.append(that.dom.valueTitle)
|
|
1141
|
+
.on('change.dtsb', function () {
|
|
1142
|
+
$$2(this).removeClass(Criteria.classes.italic);
|
|
1143
|
+
fn(that, this);
|
|
1144
|
+
});
|
|
1145
|
+
if (that.c.greyscale) {
|
|
1146
|
+
el.addClass(Criteria.classes.greyscale);
|
|
1147
|
+
}
|
|
1148
|
+
var options = [];
|
|
1149
|
+
for (var _i = 0, _a = that.s.serverData[that.s.origData]; _i < _a.length; _i++) {
|
|
1150
|
+
var option = _a[_i];
|
|
1151
|
+
var value = option.value;
|
|
1152
|
+
var label = option.label;
|
|
1153
|
+
// Function to add an option to the select element
|
|
1154
|
+
var addOption = function (filt, text) {
|
|
1155
|
+
if (that.s.type.includes('html') && filt !== null && typeof filt === 'string') {
|
|
1156
|
+
filt.replace(/(<([^>]+)>)/ig, '');
|
|
1157
|
+
}
|
|
1158
|
+
// Add text and value, stripping out any html if that is the column type
|
|
1159
|
+
var opt = $$2('<option>', {
|
|
1160
|
+
type: Array.isArray(filt) ? 'Array' : 'String',
|
|
1161
|
+
value: filt
|
|
1162
|
+
})
|
|
1163
|
+
.data('sbv', filt)
|
|
1164
|
+
.addClass(that.classes.option)
|
|
1165
|
+
.addClass(that.classes.notItalic)
|
|
1166
|
+
// Have to add the text this way so that special html characters are not escaped - & etc.
|
|
1167
|
+
.html(typeof text === 'string' ?
|
|
1168
|
+
text.replace(/(<([^>]+)>)/ig, '') :
|
|
1169
|
+
text);
|
|
1170
|
+
options.push(opt);
|
|
1171
|
+
// If this value was previously selected as indicated by preDefined, then select it again
|
|
1172
|
+
if (preDefined !== null && opt.val() === preDefined[0]) {
|
|
1173
|
+
opt.prop('selected', true);
|
|
1174
|
+
el.removeClass(Criteria.classes.italic);
|
|
1175
|
+
that.dom.valueTitle.removeProp('selected');
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
addOption(value, label);
|
|
1179
|
+
}
|
|
1180
|
+
for (var _b = 0, options_2 = options; _b < options_2.length; _b++) {
|
|
1181
|
+
var opt = options_2[_b];
|
|
1182
|
+
el.append(opt);
|
|
1183
|
+
}
|
|
1184
|
+
return el;
|
|
1185
|
+
};
|
|
1105
1186
|
/**
|
|
1106
1187
|
* Default initialisation function for select array conditions
|
|
1107
1188
|
*
|
|
@@ -1554,8 +1635,8 @@
|
|
|
1554
1635
|
inputValue: Criteria.inputValueInput,
|
|
1555
1636
|
isInputValid: Criteria.isInputValidInput,
|
|
1556
1637
|
search: function (value, comparison, that) {
|
|
1557
|
-
return moment(value, that.s.dateFormat).valueOf() ===
|
|
1558
|
-
moment(comparison[0], that.s.dateFormat).valueOf();
|
|
1638
|
+
return moment()(value, that.s.dateFormat).valueOf() ===
|
|
1639
|
+
moment()(comparison[0], that.s.dateFormat).valueOf();
|
|
1559
1640
|
}
|
|
1560
1641
|
},
|
|
1561
1642
|
// eslint-disable-next-line sort-keys
|
|
@@ -1567,8 +1648,8 @@
|
|
|
1567
1648
|
inputValue: Criteria.inputValueInput,
|
|
1568
1649
|
isInputValid: Criteria.isInputValidInput,
|
|
1569
1650
|
search: function (value, comparison, that) {
|
|
1570
|
-
return moment(value, that.s.dateFormat).valueOf() !==
|
|
1571
|
-
moment(comparison[0], that.s.dateFormat).valueOf();
|
|
1651
|
+
return moment()(value, that.s.dateFormat).valueOf() !==
|
|
1652
|
+
moment()(comparison[0], that.s.dateFormat).valueOf();
|
|
1572
1653
|
}
|
|
1573
1654
|
},
|
|
1574
1655
|
'<': {
|
|
@@ -1579,7 +1660,7 @@
|
|
|
1579
1660
|
inputValue: Criteria.inputValueInput,
|
|
1580
1661
|
isInputValid: Criteria.isInputValidInput,
|
|
1581
1662
|
search: function (value, comparison, that) {
|
|
1582
|
-
return moment(value, that.s.dateFormat).valueOf() < moment(comparison[0], that.s.dateFormat).valueOf();
|
|
1663
|
+
return moment()(value, that.s.dateFormat).valueOf() < moment()(comparison[0], that.s.dateFormat).valueOf();
|
|
1583
1664
|
}
|
|
1584
1665
|
},
|
|
1585
1666
|
'>': {
|
|
@@ -1590,7 +1671,7 @@
|
|
|
1590
1671
|
inputValue: Criteria.inputValueInput,
|
|
1591
1672
|
isInputValid: Criteria.isInputValidInput,
|
|
1592
1673
|
search: function (value, comparison, that) {
|
|
1593
|
-
return moment(value, that.s.dateFormat).valueOf() > moment(comparison[0], that.s.dateFormat).valueOf();
|
|
1674
|
+
return moment()(value, that.s.dateFormat).valueOf() > moment()(comparison[0], that.s.dateFormat).valueOf();
|
|
1594
1675
|
}
|
|
1595
1676
|
},
|
|
1596
1677
|
'between': {
|
|
@@ -1601,9 +1682,9 @@
|
|
|
1601
1682
|
inputValue: Criteria.inputValueInput,
|
|
1602
1683
|
isInputValid: Criteria.isInputValidInput,
|
|
1603
1684
|
search: function (value, comparison, that) {
|
|
1604
|
-
var val = moment(value, that.s.dateFormat).valueOf();
|
|
1605
|
-
var comp0 = moment(comparison[0], that.s.dateFormat).valueOf();
|
|
1606
|
-
var comp1 = moment(comparison[1], that.s.dateFormat).valueOf();
|
|
1685
|
+
var val = moment()(value, that.s.dateFormat).valueOf();
|
|
1686
|
+
var comp0 = moment()(comparison[0], that.s.dateFormat).valueOf();
|
|
1687
|
+
var comp1 = moment()(comparison[1], that.s.dateFormat).valueOf();
|
|
1607
1688
|
if (comp0 < comp1) {
|
|
1608
1689
|
return comp0 <= val && val <= comp1;
|
|
1609
1690
|
}
|
|
@@ -1621,9 +1702,9 @@
|
|
|
1621
1702
|
inputValue: Criteria.inputValueInput,
|
|
1622
1703
|
isInputValid: Criteria.isInputValidInput,
|
|
1623
1704
|
search: function (value, comparison, that) {
|
|
1624
|
-
var val = moment(value, that.s.dateFormat).valueOf();
|
|
1625
|
-
var comp0 = moment(comparison[0], that.s.dateFormat).valueOf();
|
|
1626
|
-
var comp1 = moment(comparison[1], that.s.dateFormat).valueOf();
|
|
1705
|
+
var val = moment()(value, that.s.dateFormat).valueOf();
|
|
1706
|
+
var comp0 = moment()(comparison[0], that.s.dateFormat).valueOf();
|
|
1707
|
+
var comp1 = moment()(comparison[1], that.s.dateFormat).valueOf();
|
|
1627
1708
|
if (comp0 < comp1) {
|
|
1628
1709
|
return !(+comp0 <= +val && +val <= +comp1);
|
|
1629
1710
|
}
|
|
@@ -1677,8 +1758,8 @@
|
|
|
1677
1758
|
inputValue: Criteria.inputValueInput,
|
|
1678
1759
|
isInputValid: Criteria.isInputValidInput,
|
|
1679
1760
|
search: function (value, comparison, that) {
|
|
1680
|
-
return luxon.DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1681
|
-
=== luxon.DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1761
|
+
return luxon().DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1762
|
+
=== luxon().DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1682
1763
|
}
|
|
1683
1764
|
},
|
|
1684
1765
|
// eslint-disable-next-line sort-keys
|
|
@@ -1690,8 +1771,8 @@
|
|
|
1690
1771
|
inputValue: Criteria.inputValueInput,
|
|
1691
1772
|
isInputValid: Criteria.isInputValidInput,
|
|
1692
1773
|
search: function (value, comparison, that) {
|
|
1693
|
-
return luxon.DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1694
|
-
!== luxon.DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1774
|
+
return luxon().DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1775
|
+
!== luxon().DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1695
1776
|
}
|
|
1696
1777
|
},
|
|
1697
1778
|
'<': {
|
|
@@ -1702,8 +1783,8 @@
|
|
|
1702
1783
|
inputValue: Criteria.inputValueInput,
|
|
1703
1784
|
isInputValid: Criteria.isInputValidInput,
|
|
1704
1785
|
search: function (value, comparison, that) {
|
|
1705
|
-
return luxon.DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1706
|
-
< luxon.DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1786
|
+
return luxon().DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1787
|
+
< luxon().DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1707
1788
|
}
|
|
1708
1789
|
},
|
|
1709
1790
|
'>': {
|
|
@@ -1714,8 +1795,8 @@
|
|
|
1714
1795
|
inputValue: Criteria.inputValueInput,
|
|
1715
1796
|
isInputValid: Criteria.isInputValidInput,
|
|
1716
1797
|
search: function (value, comparison, that) {
|
|
1717
|
-
return luxon.DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1718
|
-
> luxon.DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1798
|
+
return luxon().DateTime.fromFormat(value, that.s.dateFormat).ts
|
|
1799
|
+
> luxon().DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1719
1800
|
}
|
|
1720
1801
|
},
|
|
1721
1802
|
'between': {
|
|
@@ -1726,9 +1807,9 @@
|
|
|
1726
1807
|
inputValue: Criteria.inputValueInput,
|
|
1727
1808
|
isInputValid: Criteria.isInputValidInput,
|
|
1728
1809
|
search: function (value, comparison, that) {
|
|
1729
|
-
var val = luxon.DateTime.fromFormat(value, that.s.dateFormat).ts;
|
|
1730
|
-
var comp0 = luxon.DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1731
|
-
var comp1 = luxon.DateTime.fromFormat(comparison[1], that.s.dateFormat).ts;
|
|
1810
|
+
var val = luxon().DateTime.fromFormat(value, that.s.dateFormat).ts;
|
|
1811
|
+
var comp0 = luxon().DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1812
|
+
var comp1 = luxon().DateTime.fromFormat(comparison[1], that.s.dateFormat).ts;
|
|
1732
1813
|
if (comp0 < comp1) {
|
|
1733
1814
|
return comp0 <= val && val <= comp1;
|
|
1734
1815
|
}
|
|
@@ -1746,9 +1827,9 @@
|
|
|
1746
1827
|
inputValue: Criteria.inputValueInput,
|
|
1747
1828
|
isInputValid: Criteria.isInputValidInput,
|
|
1748
1829
|
search: function (value, comparison, that) {
|
|
1749
|
-
var val = luxon.DateTime.fromFormat(value, that.s.dateFormat).ts;
|
|
1750
|
-
var comp0 = luxon.DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1751
|
-
var comp1 = luxon.DateTime.fromFormat(comparison[1], that.s.dateFormat).ts;
|
|
1830
|
+
var val = luxon().DateTime.fromFormat(value, that.s.dateFormat).ts;
|
|
1831
|
+
var comp0 = luxon().DateTime.fromFormat(comparison[0], that.s.dateFormat).ts;
|
|
1832
|
+
var comp1 = luxon().DateTime.fromFormat(comparison[1], that.s.dateFormat).ts;
|
|
1752
1833
|
if (comp0 < comp1) {
|
|
1753
1834
|
return !(+comp0 <= +val && +val <= +comp1);
|
|
1754
1835
|
}
|
|
@@ -1940,13 +2021,7 @@
|
|
|
1940
2021
|
inputValue: Criteria.inputValueSelect,
|
|
1941
2022
|
isInputValid: Criteria.isInputValidSelect,
|
|
1942
2023
|
search: function (value, comparison) {
|
|
1943
|
-
|
|
1944
|
-
'-' + value.replace(/[^0-9.]/g, '') :
|
|
1945
|
-
value.replace(/[^0-9.]/g, '');
|
|
1946
|
-
var comp = comparison[0].indexOf('-') === 0 ?
|
|
1947
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
1948
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
1949
|
-
return +val === +comp;
|
|
2024
|
+
return Criteria.parseNumFmt(value) === Criteria.parseNumFmt(comparison[0]);
|
|
1950
2025
|
}
|
|
1951
2026
|
},
|
|
1952
2027
|
// eslint-disable-next-line sort-keys
|
|
@@ -1958,13 +2033,7 @@
|
|
|
1958
2033
|
inputValue: Criteria.inputValueSelect,
|
|
1959
2034
|
isInputValid: Criteria.isInputValidSelect,
|
|
1960
2035
|
search: function (value, comparison) {
|
|
1961
|
-
|
|
1962
|
-
'-' + value.replace(/[^0-9.]/g, '') :
|
|
1963
|
-
value.replace(/[^0-9.]/g, '');
|
|
1964
|
-
var comp = comparison[0].indexOf('-') === 0 ?
|
|
1965
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
1966
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
1967
|
-
return +val !== +comp;
|
|
2036
|
+
return Criteria.parseNumFmt(value) !== Criteria.parseNumFmt(comparison[0]);
|
|
1968
2037
|
}
|
|
1969
2038
|
},
|
|
1970
2039
|
'<': {
|
|
@@ -1975,13 +2044,7 @@
|
|
|
1975
2044
|
inputValue: Criteria.inputValueInput,
|
|
1976
2045
|
isInputValid: Criteria.isInputValidInput,
|
|
1977
2046
|
search: function (value, comparison) {
|
|
1978
|
-
|
|
1979
|
-
'-' + value.replace(/[^0-9.]/g, '') :
|
|
1980
|
-
value.replace(/[^0-9.]/g, '');
|
|
1981
|
-
var comp = comparison[0].indexOf('-') === 0 ?
|
|
1982
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
1983
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
1984
|
-
return +val < +comp;
|
|
2047
|
+
return Criteria.parseNumFmt(value) < Criteria.parseNumFmt(comparison[0]);
|
|
1985
2048
|
}
|
|
1986
2049
|
},
|
|
1987
2050
|
'<=': {
|
|
@@ -1992,13 +2055,7 @@
|
|
|
1992
2055
|
inputValue: Criteria.inputValueInput,
|
|
1993
2056
|
isInputValid: Criteria.isInputValidInput,
|
|
1994
2057
|
search: function (value, comparison) {
|
|
1995
|
-
|
|
1996
|
-
'-' + value.replace(/[^0-9.]/g, '') :
|
|
1997
|
-
value.replace(/[^0-9.]/g, '');
|
|
1998
|
-
var comp = comparison[0].indexOf('-') === 0 ?
|
|
1999
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
2000
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
2001
|
-
return +val <= +comp;
|
|
2058
|
+
return Criteria.parseNumFmt(value) <= Criteria.parseNumFmt(comparison[0]);
|
|
2002
2059
|
}
|
|
2003
2060
|
},
|
|
2004
2061
|
'>=': {
|
|
@@ -2009,13 +2066,7 @@
|
|
|
2009
2066
|
inputValue: Criteria.inputValueInput,
|
|
2010
2067
|
isInputValid: Criteria.isInputValidInput,
|
|
2011
2068
|
search: function (value, comparison) {
|
|
2012
|
-
|
|
2013
|
-
'-' + value.replace(/[^0-9.]/g, '') :
|
|
2014
|
-
value.replace(/[^0-9.]/g, '');
|
|
2015
|
-
var comp = comparison[0].indexOf('-') === 0 ?
|
|
2016
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
2017
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
2018
|
-
return +val >= +comp;
|
|
2069
|
+
return Criteria.parseNumFmt(value) >= Criteria.parseNumFmt(comparison[0]);
|
|
2019
2070
|
}
|
|
2020
2071
|
},
|
|
2021
2072
|
// eslint-disable-next-line sort-keys
|
|
@@ -2027,13 +2078,7 @@
|
|
|
2027
2078
|
inputValue: Criteria.inputValueInput,
|
|
2028
2079
|
isInputValid: Criteria.isInputValidInput,
|
|
2029
2080
|
search: function (value, comparison) {
|
|
2030
|
-
|
|
2031
|
-
'-' + value.replace(/[^0-9.]/g, '') :
|
|
2032
|
-
value.replace(/[^0-9.]/g, '');
|
|
2033
|
-
var comp = comparison[0].indexOf('-') === 0 ?
|
|
2034
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
2035
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
2036
|
-
return +val > +comp;
|
|
2081
|
+
return Criteria.parseNumFmt(value) > Criteria.parseNumFmt(comparison[0]);
|
|
2037
2082
|
}
|
|
2038
2083
|
},
|
|
2039
2084
|
'between': {
|
|
@@ -2044,15 +2089,9 @@
|
|
|
2044
2089
|
inputValue: Criteria.inputValueInput,
|
|
2045
2090
|
isInputValid: Criteria.isInputValidInput,
|
|
2046
2091
|
search: function (value, comparison) {
|
|
2047
|
-
var val =
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
var comp0 = comparison[0].indexOf('-') === 0 ?
|
|
2051
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
2052
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
2053
|
-
var comp1 = comparison[1].indexOf('-') === 0 ?
|
|
2054
|
-
'-' + comparison[1].replace(/[^0-9.]/g, '') :
|
|
2055
|
-
comparison[1].replace(/[^0-9.]/g, '');
|
|
2092
|
+
var val = Criteria.parseNumFmt(value);
|
|
2093
|
+
var comp0 = Criteria.parseNumFmt(comparison[0]);
|
|
2094
|
+
var comp1 = Criteria.parseNumFmt(comparison[1]);
|
|
2056
2095
|
if (+comp0 < +comp1) {
|
|
2057
2096
|
return +comp0 <= +val && +val <= +comp1;
|
|
2058
2097
|
}
|
|
@@ -2070,15 +2109,9 @@
|
|
|
2070
2109
|
inputValue: Criteria.inputValueInput,
|
|
2071
2110
|
isInputValid: Criteria.isInputValidInput,
|
|
2072
2111
|
search: function (value, comparison) {
|
|
2073
|
-
var val =
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
var comp0 = comparison[0].indexOf('-') === 0 ?
|
|
2077
|
-
'-' + comparison[0].replace(/[^0-9.]/g, '') :
|
|
2078
|
-
comparison[0].replace(/[^0-9.]/g, '');
|
|
2079
|
-
var comp1 = comparison[1].indexOf('-') === 0 ?
|
|
2080
|
-
'-' + comparison[1].replace(/[^0-9.]/g, '') :
|
|
2081
|
-
comparison[1].replace(/[^0-9.]/g, '');
|
|
2112
|
+
var val = Criteria.parseNumFmt(value);
|
|
2113
|
+
var comp0 = Criteria.parseNumFmt(comparison[0]);
|
|
2114
|
+
var comp1 = Criteria.parseNumFmt(comparison[1]);
|
|
2082
2115
|
if (+comp0 < +comp1) {
|
|
2083
2116
|
return !(+comp0 <= +val && +val <= +comp1);
|
|
2084
2117
|
}
|
|
@@ -2417,10 +2450,11 @@
|
|
|
2417
2450
|
* The Group class is used within SearchBuilder to represent a group of criteria
|
|
2418
2451
|
*/
|
|
2419
2452
|
var Group = /** @class */ (function () {
|
|
2420
|
-
function Group(table, opts, topGroup, index, isChild, depth) {
|
|
2453
|
+
function Group(table, opts, topGroup, index, isChild, depth, serverData) {
|
|
2421
2454
|
if (index === void 0) { index = 0; }
|
|
2422
2455
|
if (isChild === void 0) { isChild = false; }
|
|
2423
2456
|
if (depth === void 0) { depth = 1; }
|
|
2457
|
+
if (serverData === void 0) { serverData = undefined; }
|
|
2424
2458
|
// Check that the required version of DataTables is included
|
|
2425
2459
|
if (!dataTable$1 || !dataTable$1.versionCheck || !dataTable$1.versionCheck('1.10.0')) {
|
|
2426
2460
|
throw new Error('SearchBuilder requires DataTables 1.10 or newer');
|
|
@@ -2437,6 +2471,7 @@
|
|
|
2437
2471
|
logic: undefined,
|
|
2438
2472
|
opts: opts,
|
|
2439
2473
|
preventRedraw: false,
|
|
2474
|
+
serverData: serverData,
|
|
2440
2475
|
toDrop: undefined,
|
|
2441
2476
|
topGroup: topGroup
|
|
2442
2477
|
};
|
|
@@ -2539,7 +2574,7 @@
|
|
|
2539
2574
|
for (var _b = 0, _c = this.s.criteria; _b < _c.length; _b++) {
|
|
2540
2575
|
var crit = _c[_b];
|
|
2541
2576
|
if (crit.criteria instanceof Criteria) {
|
|
2542
|
-
crit.criteria.updateArrows(this.s.criteria.length > 1
|
|
2577
|
+
crit.criteria.updateArrows(this.s.criteria.length > 1);
|
|
2543
2578
|
this._setCriteriaListeners(crit.criteria);
|
|
2544
2579
|
}
|
|
2545
2580
|
}
|
|
@@ -2607,8 +2642,8 @@
|
|
|
2607
2642
|
Group.prototype.redrawLogic = function () {
|
|
2608
2643
|
for (var _i = 0, _a = this.s.criteria; _i < _a.length; _i++) {
|
|
2609
2644
|
var crit = _a[_i];
|
|
2610
|
-
if (crit instanceof Group) {
|
|
2611
|
-
crit.redrawLogic();
|
|
2645
|
+
if (crit.criteria instanceof Group) {
|
|
2646
|
+
crit.criteria.redrawLogic();
|
|
2612
2647
|
}
|
|
2613
2648
|
}
|
|
2614
2649
|
this.setupLogic();
|
|
@@ -2644,12 +2679,19 @@
|
|
|
2644
2679
|
}
|
|
2645
2680
|
return;
|
|
2646
2681
|
}
|
|
2647
|
-
// Set width, take 2 for the border
|
|
2648
|
-
var height = this.dom.container.height() - 1;
|
|
2649
2682
|
this.dom.clear.height('0px');
|
|
2650
|
-
this.dom.logicContainer.append(this.dom.clear)
|
|
2683
|
+
this.dom.logicContainer.append(this.dom.clear);
|
|
2651
2684
|
// Prepend logic button
|
|
2652
2685
|
this.dom.container.prepend(this.dom.logicContainer);
|
|
2686
|
+
for (var _i = 0, _a = this.s.criteria; _i < _a.length; _i++) {
|
|
2687
|
+
var crit = _a[_i];
|
|
2688
|
+
if (crit.criteria instanceof Criteria) {
|
|
2689
|
+
crit.criteria.setupButtons();
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
// Set width, take 2 for the border
|
|
2693
|
+
var height = this.dom.container.outerHeight() - 1;
|
|
2694
|
+
this.dom.logicContainer.width(height);
|
|
2653
2695
|
this._setLogicListener();
|
|
2654
2696
|
// Set criteria left margin
|
|
2655
2697
|
this.dom.container.css('margin-left', this.dom.logicContainer.outerHeight(true));
|
|
@@ -2698,11 +2740,10 @@
|
|
|
2698
2740
|
*
|
|
2699
2741
|
* @param crit Instance of Criteria to be added to the group
|
|
2700
2742
|
*/
|
|
2701
|
-
Group.prototype.addCriteria = function (crit
|
|
2743
|
+
Group.prototype.addCriteria = function (crit) {
|
|
2702
2744
|
if (crit === void 0) { crit = null; }
|
|
2703
|
-
if (redraw === void 0) { redraw = true; }
|
|
2704
2745
|
var index = crit === null ? this.s.criteria.length : crit.s.index;
|
|
2705
|
-
var criteria = new Criteria(this.s.dt, this.s.opts, this.s.topGroup, index, this.s.depth);
|
|
2746
|
+
var criteria = new Criteria(this.s.dt, this.s.opts, this.s.topGroup, index, this.s.depth, this.s.serverData);
|
|
2706
2747
|
// If a Criteria has been passed in then set the values to continue that
|
|
2707
2748
|
if (crit !== null) {
|
|
2708
2749
|
criteria.c = crit.c;
|
|
@@ -2738,7 +2779,7 @@
|
|
|
2738
2779
|
for (var _i = 0, _a = this.s.criteria; _i < _a.length; _i++) {
|
|
2739
2780
|
var opt = _a[_i];
|
|
2740
2781
|
if (opt.criteria instanceof Criteria) {
|
|
2741
|
-
opt.criteria.updateArrows(this.s.criteria.length > 1
|
|
2782
|
+
opt.criteria.updateArrows(this.s.criteria.length > 1);
|
|
2742
2783
|
}
|
|
2743
2784
|
}
|
|
2744
2785
|
this._setCriteriaListeners(criteria);
|
|
@@ -2781,7 +2822,7 @@
|
|
|
2781
2822
|
*/
|
|
2782
2823
|
Group.prototype._addPrevGroup = function (loadedGroup) {
|
|
2783
2824
|
var idx = this.s.criteria.length;
|
|
2784
|
-
var group = new Group(this.s.dt, this.c, this.s.topGroup, idx, true, this.s.depth + 1);
|
|
2825
|
+
var group = new Group(this.s.dt, this.c, this.s.topGroup, idx, true, this.s.depth + 1, this.s.serverData);
|
|
2785
2826
|
// Add the new group to the criteria array
|
|
2786
2827
|
this.s.criteria.push({
|
|
2787
2828
|
criteria: group,
|
|
@@ -2801,7 +2842,7 @@
|
|
|
2801
2842
|
*/
|
|
2802
2843
|
Group.prototype._addPrevCriteria = function (loadedCriteria) {
|
|
2803
2844
|
var idx = this.s.criteria.length;
|
|
2804
|
-
var criteria = new Criteria(this.s.dt, this.s.opts, this.s.topGroup, idx, this.s.depth);
|
|
2845
|
+
var criteria = new Criteria(this.s.dt, this.s.opts, this.s.topGroup, idx, this.s.depth, this.s.serverData);
|
|
2805
2846
|
criteria.populate();
|
|
2806
2847
|
// Add the new criteria to the criteria array
|
|
2807
2848
|
this.s.criteria.push({
|
|
@@ -2933,7 +2974,7 @@
|
|
|
2933
2974
|
.unbind('click')
|
|
2934
2975
|
.on('click.dtsb', function () {
|
|
2935
2976
|
var idx = criteria.s.index;
|
|
2936
|
-
var group = new Group(_this.s.dt, _this.s.opts, _this.s.topGroup, criteria.s.index, true, _this.s.depth + 1);
|
|
2977
|
+
var group = new Group(_this.s.dt, _this.s.opts, _this.s.topGroup, criteria.s.index, true, _this.s.depth + 1, _this.s.serverData);
|
|
2937
2978
|
// Add the criteria that is to be moved to the new group
|
|
2938
2979
|
group.addCriteria(criteria);
|
|
2939
2980
|
// Update the details in the current groups criteria array
|
|
@@ -2946,7 +2987,7 @@
|
|
|
2946
2987
|
criteria.dom.left
|
|
2947
2988
|
.unbind('click')
|
|
2948
2989
|
.on('click.dtsb', function () {
|
|
2949
|
-
_this.s.toDrop = new Criteria(_this.s.dt, _this.s.opts, _this.s.topGroup, criteria.s.index);
|
|
2990
|
+
_this.s.toDrop = new Criteria(_this.s.dt, _this.s.opts, _this.s.topGroup, criteria.s.index, undefined, _this.s.serverData);
|
|
2950
2991
|
_this.s.toDrop.s = criteria.s;
|
|
2951
2992
|
_this.s.toDrop.c = criteria.c;
|
|
2952
2993
|
_this.s.toDrop.classes = criteria.classes;
|
|
@@ -3015,8 +3056,8 @@
|
|
|
3015
3056
|
.on('dtsb-dropCriteria.dtsb', function () {
|
|
3016
3057
|
var toDrop = group.s.toDrop;
|
|
3017
3058
|
toDrop.s.index = group.s.index;
|
|
3018
|
-
toDrop.updateArrows(_this.s.criteria.length > 1
|
|
3019
|
-
_this.addCriteria(toDrop
|
|
3059
|
+
toDrop.updateArrows(_this.s.criteria.length > 1);
|
|
3060
|
+
_this.addCriteria(toDrop);
|
|
3020
3061
|
return false;
|
|
3021
3062
|
});
|
|
3022
3063
|
group.setListeners();
|
|
@@ -3176,6 +3217,7 @@
|
|
|
3176
3217
|
dt: table,
|
|
3177
3218
|
opts: opts,
|
|
3178
3219
|
search: undefined,
|
|
3220
|
+
serverData: undefined,
|
|
3179
3221
|
topGroup: undefined
|
|
3180
3222
|
};
|
|
3181
3223
|
// If searchbuilder is already defined for this table then return
|
|
@@ -3191,6 +3233,11 @@
|
|
|
3191
3233
|
data.searchBuilder = _this._collapseArray(loadedState.searchBuilder);
|
|
3192
3234
|
}
|
|
3193
3235
|
});
|
|
3236
|
+
this.s.dt.on('xhr.dtsb', function (e, settings, json) {
|
|
3237
|
+
if (json && json.searchBuilder && json.searchBuilder.options) {
|
|
3238
|
+
_this.s.serverData = json.searchBuilder.options;
|
|
3239
|
+
}
|
|
3240
|
+
});
|
|
3194
3241
|
}
|
|
3195
3242
|
// Run the remaining setup when the table is initialised
|
|
3196
3243
|
if (this.s.dt.settings()[0]._bInitComplete) {
|
|
@@ -3317,7 +3364,7 @@
|
|
|
3317
3364
|
}
|
|
3318
3365
|
}
|
|
3319
3366
|
}
|
|
3320
|
-
this.s.topGroup = new Group(this.s.dt, this.c, undefined);
|
|
3367
|
+
this.s.topGroup = new Group(this.s.dt, this.c, undefined, undefined, undefined, undefined, this.s.serverData);
|
|
3321
3368
|
this._setClearListener();
|
|
3322
3369
|
this.s.dt.on('stateSaveParams.dtsb', function (e, settings, data) {
|
|
3323
3370
|
data.searchBuilder = _this.getDetails();
|
|
@@ -3352,7 +3399,7 @@
|
|
|
3352
3399
|
if (loadedState.page) {
|
|
3353
3400
|
this.s.dt.page(loadedState.page).draw('page');
|
|
3354
3401
|
}
|
|
3355
|
-
else if (this.s.dt.scroller) {
|
|
3402
|
+
else if (this.s.dt.scroller && loadedState.scroller) {
|
|
3356
3403
|
this.s.dt.scroller().scrollToRow(loadedState.scroller.topRow);
|
|
3357
3404
|
}
|
|
3358
3405
|
}
|
|
@@ -3473,7 +3520,7 @@
|
|
|
3473
3520
|
var _this = this;
|
|
3474
3521
|
this.dom.clearAll.unbind('click');
|
|
3475
3522
|
this.dom.clearAll.on('click.dtsb', function () {
|
|
3476
|
-
_this.s.topGroup = new Group(_this.s.dt, _this.c, undefined);
|
|
3523
|
+
_this.s.topGroup = new Group(_this.s.dt, _this.c, undefined, undefined, undefined, undefined, _this.s.serverData);
|
|
3477
3524
|
_this._build();
|
|
3478
3525
|
_this.s.dt.draw();
|
|
3479
3526
|
_this.s.topGroup.setListeners();
|
|
@@ -3551,7 +3598,7 @@
|
|
|
3551
3598
|
_this.dom.clearAll.remove();
|
|
3552
3599
|
});
|
|
3553
3600
|
};
|
|
3554
|
-
SearchBuilder.version = '1.3.
|
|
3601
|
+
SearchBuilder.version = '1.3.2';
|
|
3555
3602
|
SearchBuilder.classes = {
|
|
3556
3603
|
button: 'dtsb-button',
|
|
3557
3604
|
clearAll: 'dtsb-clearAll',
|
|
@@ -3657,7 +3704,7 @@
|
|
|
3657
3704
|
return SearchBuilder;
|
|
3658
3705
|
}());
|
|
3659
3706
|
|
|
3660
|
-
/*! SearchBuilder 1.3.
|
|
3707
|
+
/*! SearchBuilder 1.3.2
|
|
3661
3708
|
* ©SpryMedia Ltd - datatables.net/license/mit
|
|
3662
3709
|
*/
|
|
3663
3710
|
// DataTables extensions common UMD. Note that this allows for AMD, CommonJS
|
|
@@ -3720,7 +3767,7 @@
|
|
|
3720
3767
|
var topGroup = config._searchBuilder.s.topGroup;
|
|
3721
3768
|
// Need to redraw the contents to calculate the correct positions for the elements
|
|
3722
3769
|
if (topGroup !== undefined) {
|
|
3723
|
-
topGroup.dom.container.trigger('dtsb-redrawContents');
|
|
3770
|
+
topGroup.dom.container.trigger('dtsb-redrawContents-noDraw');
|
|
3724
3771
|
}
|
|
3725
3772
|
if (topGroup.s.criteria.length === 0) {
|
|
3726
3773
|
$('.' + $.fn.dataTable.Group.classes.add.replace(/ /g, '.')).click();
|