Return all items without search term exported
This commit is contained in:
parent
b356cffbc5
commit
0194eebd95
|
@ -4,19 +4,23 @@ export default class SearchProvider extends Component {
|
|||
get items() {
|
||||
const { items, search, searchProperties } = this.args;
|
||||
|
||||
const regex = new RegExp(`${search}`, 'ig');
|
||||
if (search.length > 0) {
|
||||
const regex = new RegExp(`${search}`, 'ig');
|
||||
|
||||
return items.filter((item) => {
|
||||
const matchesInSearchProperties = searchProperties.reduce((acc, searchProperty) => {
|
||||
const match = item[searchProperty].match(regex);
|
||||
if (match) {
|
||||
return [...acc, match];
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
}, []);
|
||||
return matchesInSearchProperties.length > 0;
|
||||
});
|
||||
return items.filter((item) => {
|
||||
const matchesInSearchProperties = searchProperties.reduce((acc, searchProperty) => {
|
||||
const match = item[searchProperty].match(regex);
|
||||
if (match) {
|
||||
return [...acc, match];
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
}, []);
|
||||
return matchesInSearchProperties.length > 0;
|
||||
});
|
||||
} else {
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
get data() {
|
||||
|
|
Loading…
Reference in New Issue