Skip to content

Commit

Permalink
Merge pull request #271 from checkr/zz/tune-search-feature
Browse files Browse the repository at this point in the history
Use lower case and computed for search terms
  • Loading branch information
zhouzhuojie authored Jun 20, 2019
2 parents 6dd6c33 + f704f71 commit 7979b1d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions browser/flagr-ui/src/components/Flags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export default {
return {
loaded: false,
flags: [],
filteredFlags: [],
searchTerm: '',
newFlag: {
description: ''
Expand All @@ -128,21 +127,18 @@ export default {
this.loaded = true
flags.reverse()
this.flags = flags
this.filteredFlags = [...flags];
}, handleErr.bind(this))
},
watch: {
searchTerm: function() {
computed: {
filteredFlags: function() {
if (this.searchTerm) {
this.filteredFlags = this.flags.filter(
return this.flags.filter(
({ id, description}) =>
id.toString().includes(this.searchTerm) ||
description.includes(this.searchTerm)
description.toLowerCase().includes(this.searchTerm.toLowerCase())
)
}
else {
this.filteredFlags = [...this.flags]
}
return this.flags
}
},
methods: {
Expand Down

0 comments on commit 7979b1d

Please sign in to comment.