Remove fuse as a dependency
This commit is contained in:
parent
635263b8aa
commit
19b2ac4858
|
@ -1,5 +1,4 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import Fuse from 'npm:fuse.js';
|
|
||||||
|
|
||||||
const { Mixin, computed, get } = Ember;
|
const { Mixin, computed, get } = Ember;
|
||||||
|
|
||||||
|
@ -21,31 +20,16 @@ export default Mixin.create({
|
||||||
listToSearch: computed(() => []),
|
listToSearch: computed(() => []),
|
||||||
searchProps: null,
|
searchProps: null,
|
||||||
|
|
||||||
fuse: computed('listToSearch.[]', 'searchProps.[]', function() {
|
listSearched: computed('searchTerm', 'listToSearch.[]', 'searchProps.[]', function() {
|
||||||
return new Fuse(this.get('listToSearch'), {
|
const searchTerm = this.get('searchTerm');
|
||||||
shouldSort: true,
|
|
||||||
threshold: 0.6,
|
|
||||||
location: 0,
|
|
||||||
distance: 100,
|
|
||||||
maxPatternLength: 32,
|
|
||||||
minMatchCharLength: 1,
|
|
||||||
keys: this.get('searchProps') || [],
|
|
||||||
getFn(item, key) {
|
|
||||||
return get(item, key);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
|
|
||||||
listSearched: computed('fuse', 'searchTerm', function() {
|
|
||||||
const { fuse, searchTerm } = this.getProperties('fuse', 'searchTerm');
|
|
||||||
if (searchTerm && searchTerm.length) {
|
if (searchTerm && searchTerm.length) {
|
||||||
return regexSearch(searchTerm, fuse);
|
return regexSearch(searchTerm, this.get('listToSearch'), this.get('searchProps'));
|
||||||
}
|
}
|
||||||
return this.get('listToSearch');
|
return this.get('listToSearch');
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
function regexSearch(term, { list, options: { keys } }) {
|
function regexSearch(term, list, keys) {
|
||||||
if (term.length) {
|
if (term.length) {
|
||||||
try {
|
try {
|
||||||
const regex = new RegExp(term, 'i');
|
const regex = new RegExp(term, 'i');
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
"prettier --single-quote --trailing-comma es5 --print-width 100 --write",
|
"prettier --single-quote --trailing-comma es5 --print-width 100 --write",
|
||||||
"git add"
|
"git add"
|
||||||
],
|
],
|
||||||
"ui/app/styles/**/*.*": [
|
"ui/app/styles/**/*.*": ["prettier --write", "git add"]
|
||||||
"prettier --write",
|
|
||||||
"git add"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -69,7 +66,6 @@
|
||||||
"ember-welcome-page": "^3.0.0",
|
"ember-welcome-page": "^3.0.0",
|
||||||
"eslint": "^4.0.0",
|
"eslint": "^4.0.0",
|
||||||
"flat": "^2.0.1",
|
"flat": "^2.0.1",
|
||||||
"fuse.js": "^3.0.5",
|
|
||||||
"husky": "^0.13.4",
|
"husky": "^0.13.4",
|
||||||
"json-formatter-js": "^2.2.0",
|
"json-formatter-js": "^2.2.0",
|
||||||
"lint-staged": "^3.6.1",
|
"lint-staged": "^3.6.1",
|
||||||
|
@ -81,9 +77,6 @@
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"ember-addon": {
|
"ember-addon": {
|
||||||
"paths": [
|
"paths": ["lib/bulma", "lib/calendar"]
|
||||||
"lib/bulma",
|
|
||||||
"lib/calendar"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4086,10 +4086,6 @@ functional-red-black-tree@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
|
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
|
||||||
|
|
||||||
fuse.js@^3.0.5:
|
|
||||||
version "3.0.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-3.0.5.tgz#b58d85878802321de94461654947b93af1086727"
|
|
||||||
|
|
||||||
gauge@~2.7.3:
|
gauge@~2.7.3:
|
||||||
version "2.7.4"
|
version "2.7.4"
|
||||||
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
|
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
|
||||||
|
|
Loading…
Reference in New Issue