Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Add justList property to only shows the data given #86

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/VueBootstrapTypeahead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
:text-variant="textVariant"
:maxMatches="maxMatches"
:minMatchingChars="minMatchingChars"
:showAllResults="showAllResults"
@hit="handleHit"
>
<!-- pass down all scoped slots -->
Expand Down Expand Up @@ -92,6 +93,10 @@ export default {
type: Number,
default: 2
},
showAllResults: {
type: Boolean,
default: false
},
placeholder: String,
prepend: String,
append: String
Expand Down
8 changes: 8 additions & 0 deletions src/components/VueBootstrapTypeaheadList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export default {
minMatchingChars: {
type: Number,
default: 2
},
showAllResults: {
type: Boolean,
default: false
}
},

Expand All @@ -80,6 +84,10 @@ export default {
if (this.query.length === 0 || this.query.length < this.minMatchingChars) {
return []
}
// If the user only just want to list the possible suggestions (e.g. the filter are on backend) the showAllResults property is turn on
if (this.showAllResults) {
return this.data.slice(0, this.maxMatches)
}

const re = new RegExp(this.escapedQuery, 'gi')

Expand Down