Skip to content

Commit 52d40dc

Browse files
author
Damian Dulisz
committed
to amend
1 parent 92b5000 commit 52d40dc

File tree

7 files changed

+26
-24
lines changed

7 files changed

+26
-24
lines changed

docs/App.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ section.start
1313
.grid__column.grid__unit--md-6
1414
.multiselect-example__container
1515
multiselect(
16-
:options="options",
17-
:selected="selected",
18-
:multiple="multiple",
16+
:options="source",
17+
:selected="value",
18+
:multiple="true",
1919
:searchable="searchable",
2020
:show-labels="true",
2121
:limit="3",
2222
:taggable="true",
23+
label="name",
24+
track-by="name",
2325
@tag="onTagging"
2426
@update="afterChange",
2527
placeholder="Select option",
@@ -83,7 +85,7 @@ export default {
8385
{ name: 'Laravel', language: 'PHP' },
8486
{ name: 'Phoenix', language: 'Elixir' }
8587
],
86-
value: { name: 'Vue.js', language: 'Javascript' },
88+
value: [{ name: 'Vue.js', language: 'Javascript' }],
8789
valuePrimitive: 'showLabels',
8890
multiValue: [{ name: 'Vue.js', language: 'Javascript' }],
8991
multiple: true,
@@ -131,7 +133,7 @@ export default {
131133
this.selectedCountries = newVal
132134
},
133135
afterChange (selectValue) {
134-
this.selected = selectValue
136+
this.value = selectValue
135137
},
136138
onTagging (newTag) {
137139
this.options.push(newTag)

lib/multiselectMixin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
* @default 'id'
4848
* @type {String}
4949
*/
50-
key: {
50+
trackBy: {
5151
type: String
5252
},
5353
/**
@@ -196,10 +196,10 @@ module.exports = {
196196
return options
197197
},
198198
valueKeys () {
199-
if (this.key) {
199+
if (this.trackBy) {
200200
return this.multiple
201-
? this.value.map(element => element[this.key])
202-
: this.value[this.key]
201+
? this.value.map(element => element[this.trackBy])
202+
: this.value[this.trackBy]
203203
} else {
204204
return this.value
205205
}
@@ -253,8 +253,8 @@ module.exports = {
253253
isSelected (option) {
254254
/* istanbul ignore else */
255255
if (!this.value) return false
256-
const opt = this.key
257-
? option[this.key]
256+
const opt = this.trackBy
257+
? option[this.trackBy]
258258
: option
259259

260260
if (this.multiple) {
@@ -345,7 +345,7 @@ module.exports = {
345345
if (!this.allowEmpty && this.value.length <= 1) return
346346

347347
if (this.multiple && typeof option === 'object') {
348-
const index = this.valueKeys.indexOf(option[this.key])
348+
const index = this.valueKeys.indexOf(option[this.trackBy])
349349
this.value.splice(index, 1)
350350
} else {
351351
const index = this.valueKeys.indexOf(option)

lib/vue-multiselect.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/vue-multiselect.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-multiselect",
3-
"version": "2.0.0-beta.2",
3+
"version": "2.0.0-beta.3",
44
"description": "Multiselect component for vue.js",
55
"author": "Damian Dulisz <damian.dulisz@monterail.com>",
66
"private": false,

src/multiselectMixin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
* @default 'id'
4848
* @type {String}
4949
*/
50-
key: {
50+
trackBy: {
5151
type: String
5252
},
5353
/**
@@ -196,10 +196,10 @@ module.exports = {
196196
return options
197197
},
198198
valueKeys () {
199-
if (this.key) {
199+
if (this.trackBy) {
200200
return this.multiple
201-
? this.value.map(element => element[this.key])
202-
: this.value[this.key]
201+
? this.value.map(element => element[this.trackBy])
202+
: this.value[this.trackBy]
203203
} else {
204204
return this.value
205205
}
@@ -253,8 +253,8 @@ module.exports = {
253253
isSelected (option) {
254254
/* istanbul ignore else */
255255
if (!this.value) return false
256-
const opt = this.key
257-
? option[this.key]
256+
const opt = this.trackBy
257+
? option[this.trackBy]
258258
: option
259259

260260
if (this.multiple) {
@@ -345,7 +345,7 @@ module.exports = {
345345
if (!this.allowEmpty && this.value.length <= 1) return
346346

347347
if (this.multiple && typeof option === 'object') {
348-
const index = this.valueKeys.indexOf(option[this.key])
348+
const index = this.valueKeys.indexOf(option[this.trackBy])
349349
this.value.splice(index, 1)
350350
} else {
351351
const index = this.valueKeys.indexOf(option)

test/unit/specs/Multiselect.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ describe('Multiselect.vue', () => {
12961296
}
12971297
})
12981298
},
1299-
template: '<multiselect :selected="value" :options="source" label="id" key="id" @search-change="afterSearch" :clear-on-select="false"></multiselect>',
1299+
template: '<multiselect :selected="value" :options="source" label="id" track-by="id" @search-change="afterSearch" :clear-on-select="false"></multiselect>',
13001300
components: { Multiselect },
13011301
data: {
13021302
value: null,

0 commit comments

Comments
 (0)