Skip to content

Commit

Permalink
Use vue-select defaults
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Feb 13, 2023
1 parent 7d1be49 commit ac7a84c
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/components/NcSelect/NcSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ export default {
/**
* Key of the displayed label for object options
*
* Defaults to `'label'`
* Defaults to the internal vue-select string documented at the link
* below
*
* Enabling `userSelect` will automatically set this to `'displayName'`
* unless this prop is set explicitly
Expand Down Expand Up @@ -855,35 +856,29 @@ export default {
if (this.filterBy !== null) {
return this.filterBy
}
if (this.userSelect) {
return (option, label, search) => {
return (`${label} ${option.subtitle}` || '')
.toLocaleLowerCase()
.indexOf(search.toLocaleLowerCase()) > -1
}
}
return null
return VueSelect.props.filterBy.default
},
localLabel() {
if (this.label !== null) {
return this.label
}
if (this.userSelect) {
return 'displayName'
}
return 'label'
return VueSelect.props.label.default
},
propsToForward() {
const {
// Custom overrides of vue-select props
calculatePosition,
filterBy,
label,
// Props handled by the component itself
// Props handled by this component
noWrap,
placement,
userSelect,
Expand All @@ -893,14 +888,12 @@ export default {
const propsToForward = {
...initialPropsToForward,
// Custom overrides of vue-select props
calculatePosition: this.localCalculatePosition,
filterBy: this.localFilterBy,
label: this.localLabel,
}
if (this.localFilterBy) {
propsToForward.filterBy = this.localFilterBy
}
return propsToForward
},
},
Expand Down

0 comments on commit ac7a84c

Please sign in to comment.