Skip to content

Commit

Permalink
feat(VDataIterator): propagate and add toggle-select-all event (#8975)
Browse files Browse the repository at this point in the history
The toggle-select-all event from the VDataTable header mixin is propogated upwards and made
available in the VDataIterator. This event is explicitly triggered when all items are
selected/deselected with the top checkbox.

closes #8974
  • Loading branch information
AndreasBackx authored and johnleider committed Sep 24, 2019
1 parent 00c6a73 commit c9b00db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/api-generator/src/maps/v-data-iterator.js
Expand Up @@ -19,6 +19,7 @@ const DataIteratorEvents = DataEvents.concat([
{ name: 'update:expanded', source: 'v-data-iterator', value: 'any[]' },
{ name: 'item-selected', source: 'v-data-iterator', value: '{ item: any, value: boolean }' },
{ name: 'item-expanded', source: 'v-data-iterator', value: '{ item: any, value: boolean }' },
{ name: 'toggle-select-all', source: 'v-data-iterator', value: '{ value: boolean }' },
])

const DataIteratorSlots = [
Expand Down
Expand Up @@ -142,6 +142,7 @@ export default Themeable.extend({
})

this.selection = selection
this.$emit('toggle-select-all', { value })
},
isSelected (item: any): boolean {
return !!this.selection[getObjectValueByPath(item, this.itemKey)] || false
Expand Down
Expand Up @@ -172,13 +172,15 @@ describe('VDataIterator.ts', () => {
{ id: 'foo' },
{ id: 'bar' },
]
const toggleSelectAll = jest.fn()

const wrapper = mountFunction({
propsData: {
items,
},
listeners: {
input,
'toggle-select-all': toggleSelectAll,
},
scopedSlots: {
header (props) {
Expand All @@ -200,6 +202,7 @@ describe('VDataIterator.ts', () => {
await wrapper.vm.$nextTick()

expect(input).toHaveBeenCalledWith(items)
expect(toggleSelectAll).toHaveBeenCalledWith({ value: true })
})

it('should update expansion from the outside', async () => {
Expand Down

0 comments on commit c9b00db

Please sign in to comment.