mirror of https://github.com/hashicorp/consul
parent
559fbc2ef4
commit
aebb988daf
@ -0,0 +1 @@
|
|||||||
|
{{yield (hash data=this.data)}}
|
@ -0,0 +1,28 @@
|
|||||||
|
import Component from '@glimmer/component';
|
||||||
|
|
||||||
|
export default class SearchProvider extends Component {
|
||||||
|
get items() {
|
||||||
|
const { items, search, searchProperties } = this.args;
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get data() {
|
||||||
|
const { items } = this;
|
||||||
|
return {
|
||||||
|
items,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue