diff --git a/src/components/list/list.vue b/src/components/list/list.vue index 7d62283a..e63fea63 100644 --- a/src/components/list/list.vue +++ b/src/components/list/list.vue @@ -1,7 +1,7 @@ <template> <div class="list"> <div v-for="item in items" class="list-item" :key="getKey(item)"> - <slot name="item" :item="item" /> + <slot name="item" :item="item" :keyVal="getKey(item)" /> </div> <div class="list-empty-content faint" v-if="items.length === 0"> <slot name="empty" /> diff --git a/src/components/selectable_list/selectable_list.js b/src/components/selectable_list/selectable_list.js index 7856d725..93efa840 100644 --- a/src/components/selectable_list/selectable_list.js +++ b/src/components/selectable_list/selectable_list.js @@ -13,10 +13,9 @@ const SelectableList = { } }, methods: { - toggle (checked, item) { - const oldChecked = this.isSelected(item) + toggle (checked, key) { + const oldChecked = this.isSelected(key) if (checked !== oldChecked) { - const key = this.getKey(item) if (checked) { this.selected.push(key) } else { @@ -24,8 +23,8 @@ const SelectableList = { } } }, - isSelected (item) { - return this.selected.indexOf(this.getKey(item)) !== -1 + isSelected (key) { + return this.selected.indexOf(key) !== -1 } } } diff --git a/src/components/selectable_list/selectable_list.vue b/src/components/selectable_list/selectable_list.vue index e55a4ad3..d8938062 100644 --- a/src/components/selectable_list/selectable_list.vue +++ b/src/components/selectable_list/selectable_list.vue @@ -1,9 +1,9 @@ <template> <List class="selectable-list" :items="items" :getKey="getKey"> <template slot="item" scope="p"> - <div class="selectable-list-item-inner" :class="{ 'selectable-list-item-selected-inner': isSelected(p.item) }"> + <div class="selectable-list-item-inner" :class="{ 'selectable-list-item-selected-inner': isSelected(p.keyVal) }"> <div class="selectable-list-checkbox-wrapper"> - <Checkbox :checked="isSelected(p.item)" @change="checked => toggle(checked, p.item)" /> + <Checkbox :checked="isSelected(p.keyVal)" @change="checked => toggle(checked, p.keyVal)" /> </div> <slot name="item" :item="p.item" /> </div>