@startinblox/core 0.18.1 → 0.18.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.
|
@@ -52,15 +52,20 @@ export const SolidFormSearch = {
|
|
|
52
52
|
get defaultSetWidget() {
|
|
53
53
|
return 'solid-set-default';
|
|
54
54
|
},
|
|
55
|
+
// Returns the current value of the search from
|
|
56
|
+
// As a search query object
|
|
55
57
|
get value() {
|
|
56
58
|
const values = {};
|
|
57
59
|
this.widgets.forEach(widget => {
|
|
58
60
|
const name = (widget.component || widget).name;
|
|
59
61
|
if (name == null) return;
|
|
60
62
|
let value = widget.component ? widget.component.getValue() : widget.value;
|
|
63
|
+
let keep = value;
|
|
61
64
|
try {
|
|
62
65
|
value = JSON.parse(value);
|
|
66
|
+
if (!value && keep === '""') value = keep;
|
|
63
67
|
} catch {}
|
|
68
|
+
// Add another filter value in the values array
|
|
64
69
|
value = {
|
|
65
70
|
type: widget.component.type,
|
|
66
71
|
list: !!widget.component.multiple,
|
package/dist/libs/filter.js
CHANGED
|
@@ -67,8 +67,8 @@ const orThrow = (throwOn, ret) => {
|
|
|
67
67
|
*/
|
|
68
68
|
const matchValue = async (val, query, throwOn) => {
|
|
69
69
|
const subject = await val;
|
|
70
|
-
if (subject == null && query.value === '') return orThrow(throwOn, true);
|
|
71
|
-
if (subject == null) return orThrow(throwOn, false); // return false;
|
|
70
|
+
if (subject == null && query.value === "" && query.type !== 'string') return orThrow(throwOn, true);
|
|
71
|
+
if (subject == null && query.value !== "" && query.type !== 'string') return orThrow(throwOn, false); // return false;
|
|
72
72
|
if (query.list) {
|
|
73
73
|
// Filter on a container
|
|
74
74
|
if (query.value.length === 0) return orThrow(throwOn, true);
|
|
@@ -84,7 +84,7 @@ const matchValue = async (val, query, throwOn) => {
|
|
|
84
84
|
}
|
|
85
85
|
return orThrow(throwOn, false);
|
|
86
86
|
}
|
|
87
|
-
if (subject.isContainer?.()) {
|
|
87
|
+
if (subject && subject.isContainer?.()) {
|
|
88
88
|
let ret = Promise.resolve(query.value === ''); // if no query, return a match
|
|
89
89
|
for (const value of subject['ldp:contains']) {
|
|
90
90
|
ret = (await ret) || (await matchValue(value, query)); // do not throw here, we need the result
|
|
@@ -140,6 +140,7 @@ const matchFilter = async (resource, filter, query, fieldsAttr, searchForm, filt
|
|
|
140
140
|
await Promise.all((fields || []).map(field => matchFilter(resource, field, query, fieldsAttr, searchForm, filterId, true // stop searching when 1 filter is true (= OR)
|
|
141
141
|
)));
|
|
142
142
|
} catch (e) {
|
|
143
|
+
// console.log("Exception raised when subject is null", query, e);
|
|
143
144
|
return true;
|
|
144
145
|
}
|
|
145
146
|
throw false;
|
|
@@ -161,6 +162,7 @@ const matchFilters = async (resource, filters, filterNames, fields, searchForm,
|
|
|
161
162
|
await Promise.all(filterNames.map(filter => matchFilter(resource, filter, filters[filter], fields, searchForm, filterId, false // stop searching when 1 filter is false (= AND)
|
|
162
163
|
)));
|
|
163
164
|
} catch (e) {
|
|
165
|
+
// console.log("Exception raised when subject is null", e, filters);
|
|
164
166
|
return false;
|
|
165
167
|
}
|
|
166
168
|
return true;
|
package/dist/libs/helpers.js
CHANGED
|
@@ -136,8 +136,11 @@ function fuzzyCompare(subject, search) {
|
|
|
136
136
|
}
|
|
137
137
|
const compare = {
|
|
138
138
|
string(subject, query) {
|
|
139
|
-
|
|
140
|
-
if (
|
|
139
|
+
// Exact match on empty string between query and subject
|
|
140
|
+
if (query === '""' && (subject === null || !subject)) return true;
|
|
141
|
+
// Else if query is empty and subject is something else, return true
|
|
142
|
+
else if (query === '') return true;
|
|
143
|
+
if (subject && subject.toString().toLowerCase().includes(String(query).toLowerCase())) return true;
|
|
141
144
|
return fuzzyCompare(subject, query);
|
|
142
145
|
},
|
|
143
146
|
boolean(subject, query) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|