1
1
import { _ } from 'meteor/underscore' ;
2
2
3
3
function getPubSelector (
4
- selector ,
5
- searchString ,
6
- searchFields ,
7
- searchCaseInsensitive ,
8
- splitSearchByWhitespace ,
9
- columns ,
10
- tableColumns ,
11
- ) {
12
-
4
+ selector ,
5
+ searchString ,
6
+ searchFields ,
7
+ searchCaseInsensitive ,
8
+ splitSearchByWhitespace ,
9
+ columns ,
10
+ tableColumns
11
+ ) {
13
12
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14
13
// if search was invoked via .columns().search(), build a query off that
15
14
// https://datatables.net/reference/api/columns().search()
16
15
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17
- let searchColumns = _ . filter ( columns , column => {
16
+ let searchColumns = _ . filter ( columns , ( column ) => {
18
17
return column . search && column . search . value !== '' ;
19
18
} ) ;
20
19
@@ -26,12 +25,12 @@ function getPubSelector(
26
25
if ( searchColumns . length === 0 ) {
27
26
// normalize search fields array to mirror the structure
28
27
// as passed by the datatables ajax.data function
29
- searchColumns = _ . map ( searchFields , field => {
28
+ searchColumns = _ . map ( searchFields , ( field ) => {
30
29
return {
31
30
data : field ,
32
31
search : {
33
- value : searchString
34
- }
32
+ value : searchString ,
33
+ } ,
35
34
} ;
36
35
} ) ;
37
36
}
@@ -43,7 +42,7 @@ function getPubSelector(
43
42
searchCaseInsensitive ,
44
43
splitSearchByWhitespace ,
45
44
columns ,
46
- tableColumns ,
45
+ tableColumns
47
46
) ;
48
47
}
49
48
@@ -54,14 +53,14 @@ function createMongoSearchQuery(
54
53
searchCaseInsensitive ,
55
54
splitSearchByWhitespace ,
56
55
columns ,
57
- tableColumns ,
56
+ tableColumns
58
57
) {
59
58
// See if we can resolve the search string to a number,
60
59
// in which case we use an extra query because $regex
61
60
// matches string fields only.
62
61
const searches = [ ] ;
63
62
64
- _ . each ( searchColumns , field => {
63
+ _ . each ( searchColumns , ( field ) => {
65
64
// Get the column options from the Tabular.Table so we can check search options
66
65
const column = _ . findWhere ( tableColumns , { data : field . data } ) ;
67
66
const exactSearch = column && column . search && column . search . exact ;
@@ -76,9 +75,7 @@ function createMongoSearchQuery(
76
75
searchValue = [ searchValue ] ;
77
76
}
78
77
79
- _ . each ( searchValue , searchTerm => {
80
- const m1 = { } ;
81
-
78
+ _ . each ( searchValue , ( searchTerm ) => {
82
79
// String search
83
80
if ( exactSearch ) {
84
81
if ( numberSearch ) {
@@ -111,9 +108,9 @@ function createMongoSearchQuery(
111
108
112
109
let result ;
113
110
if ( typeof selector === 'object' && selector !== null ) {
114
- result = { $and : [ selector , { $or : searches } ] } ;
111
+ result = { $and : [ selector , { $or : searches } ] } ;
115
112
} else if ( searches . length > 1 ) {
116
- result = { $or : searches } ;
113
+ result = { $or : searches } ;
117
114
} else {
118
115
result = searches [ 0 ] || { } ;
119
116
}
0 commit comments