Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat-completed-#536 #537

Open
wants to merge 1 commit 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
9 changes: 7 additions & 2 deletions src/components/MultiValueItem.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script>
import { onLeftClick } from '../utils'
import treeselectMixin from '../mixins/treeselectMixin'
import DeleteIcon from './icons/Delete'

export default {
name: 'vue-treeselect--multi-value-item',
inject: [ 'instance' ],
mixins: [ treeselectMixin ],

props: {
node: {
Expand All @@ -31,11 +33,14 @@
}
const customValueLabelRenderer = instance.$scopedSlots['value-label']
const labelRenderer = customValueLabelRenderer ? customValueLabelRenderer({ node }) : node.label

let value = labelRenderer
if (this.trimLength > 0) {
value = labelRenderer.length > this.trimLength ? labelRenderer.slice(0, this.trimLength) + '...' : labelRenderer
}
return (
<div class="vue-treeselect__multi-value-item-container">
<div class={itemClass} onMousedown={this.handleMouseDown}>
<span class="vue-treeselect__multi-value-label">{ labelRenderer }</span>
<span class="vue-treeselect__multi-value-label" title={ this.showTitle ? labelRenderer : null }>{ value }</span>
<span class="vue-treeselect__icon vue-treeselect__value-remove"><DeleteIcon /></span>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/mixins/treeselectMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,22 @@ export default {
type: [ Number, String ],
default: 999,
},

/**
* to trim the label
*/
trimLength: {
type: Number,
default: 0,
},

/**
*to show the title
*/
showTitle: {
type: Boolean,
default: false,
},
},

data() {
Expand Down