@budibase/frontend-core 1.2.39-alpha.4 → 1.2.39-alpha.7
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/package.json +3 -3
- package/src/constants.js +5 -1
- package/src/utils/lucene.js +26 -3
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "1.2.39-alpha.
|
|
3
|
+
"version": "1.2.39-alpha.7",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
7
|
"svelte": "src/index.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@budibase/bbui": "1.2.39-alpha.
|
|
9
|
+
"@budibase/bbui": "1.2.39-alpha.7",
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"svelte": "^3.46.2"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "90cb5b3d42b21cf5d87770c5458d9cf7f8b8047b"
|
|
14
14
|
}
|
package/src/constants.js
CHANGED
|
@@ -39,13 +39,17 @@ export const OperatorOptions = {
|
|
|
39
39
|
label: "Contains",
|
|
40
40
|
},
|
|
41
41
|
NotContains: {
|
|
42
|
-
value: "
|
|
42
|
+
value: "notContains",
|
|
43
43
|
label: "Does Not Contain",
|
|
44
44
|
},
|
|
45
45
|
In: {
|
|
46
46
|
value: "oneOf",
|
|
47
47
|
label: "Is in",
|
|
48
48
|
},
|
|
49
|
+
ContainsAny: {
|
|
50
|
+
value: "containsAny",
|
|
51
|
+
label: "Has any",
|
|
52
|
+
},
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
// Cookie names
|
package/src/utils/lucene.js
CHANGED
|
@@ -32,9 +32,9 @@ export const getValidOperatorsForType = type => {
|
|
|
32
32
|
} else if (type === "number") {
|
|
33
33
|
return numOps
|
|
34
34
|
} else if (type === "options") {
|
|
35
|
-
return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
|
|
35
|
+
return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
|
|
36
36
|
} else if (type === "array") {
|
|
37
|
-
return [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty]
|
|
37
|
+
return [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty, Op.ContainsAny]
|
|
38
38
|
} else if (type === "boolean") {
|
|
39
39
|
return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
|
|
40
40
|
} else if (type === "longform") {
|
|
@@ -96,6 +96,7 @@ export const buildLuceneQuery = filter => {
|
|
|
96
96
|
contains: {},
|
|
97
97
|
notContains: {},
|
|
98
98
|
oneOf: {},
|
|
99
|
+
containsAny: {},
|
|
99
100
|
}
|
|
100
101
|
if (Array.isArray(filter)) {
|
|
101
102
|
filter.forEach(expression => {
|
|
@@ -128,6 +129,13 @@ export const buildLuceneQuery = filter => {
|
|
|
128
129
|
if (type === "boolean") {
|
|
129
130
|
value = `${value}`?.toLowerCase() === "true"
|
|
130
131
|
}
|
|
132
|
+
if (
|
|
133
|
+
["contains", "notContains", "containsAny"].includes(operator) &&
|
|
134
|
+
type === "array" &&
|
|
135
|
+
typeof value === "string"
|
|
136
|
+
) {
|
|
137
|
+
value = value.split(",")
|
|
138
|
+
}
|
|
131
139
|
if (operator.startsWith("range")) {
|
|
132
140
|
const minint =
|
|
133
141
|
SqlNumberTypeRangeMap[externalType]?.min || Number.MIN_SAFE_INTEGER
|
|
@@ -244,6 +252,18 @@ export const runLuceneQuery = (docs, query) => {
|
|
|
244
252
|
return !testValue?.includes(docValue)
|
|
245
253
|
})
|
|
246
254
|
|
|
255
|
+
const containsAny = match("containsAny", (docValue, testValue) => {
|
|
256
|
+
return !docValue?.includes(...testValue)
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
const contains = match("contains", (docValue, testValue) => {
|
|
260
|
+
return !testValue?.every(item => docValue?.includes(item))
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
const notContains = match("notContains", (docValue, testValue) => {
|
|
264
|
+
return testValue?.every(item => docValue?.includes(item))
|
|
265
|
+
})
|
|
266
|
+
|
|
247
267
|
// Match a document against all criteria
|
|
248
268
|
const docMatch = doc => {
|
|
249
269
|
return (
|
|
@@ -254,7 +274,10 @@ export const runLuceneQuery = (docs, query) => {
|
|
|
254
274
|
notEqualMatch(doc) &&
|
|
255
275
|
emptyMatch(doc) &&
|
|
256
276
|
notEmptyMatch(doc) &&
|
|
257
|
-
oneOf(doc)
|
|
277
|
+
oneOf(doc) &&
|
|
278
|
+
contains(doc) &&
|
|
279
|
+
containsAny(doc) &&
|
|
280
|
+
notContains(doc)
|
|
258
281
|
)
|
|
259
282
|
}
|
|
260
283
|
|