Skip to content

Commit

Permalink
Table: make toggleAllSelection instance property
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyoung committed Aug 22, 2019
1 parent fc822fe commit 5872368
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/table/src/store/helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Store from './index';
import debounce from 'throttle-debounce/debounce';

export function createStore(table, initialState = {}) {
if (!table) {
Expand All @@ -7,6 +8,9 @@ export function createStore(table, initialState = {}) {

const store = new Store();
store.table = table;
// fix https://github.com/ElemeFE/element/issues/14075
// related pr https://github.com/ElemeFE/element/pull/14146
store.toggleAllSelection = debounce(10, store._toggleAllSelection);
Object.keys(initialState).forEach(key => {
store.states[key] = initialState[key];
});
Expand Down
5 changes: 2 additions & 3 deletions packages/table/src/store/watcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Vue from 'vue';
import debounce from 'throttle-debounce/debounce';
import merge from 'element-ui/src/utils/merge';
import { getKeysMap, getRowIdentity, getColumnById, getColumnByKey, orderBy, toggleRowStatus } from '../util';
import expand from './expand';
Expand Down Expand Up @@ -168,7 +167,7 @@ export default Vue.extend({
}
},

toggleAllSelection: debounce(10, function() {
_toggleAllSelection() {
const states = this.states;
const { data = [], selection } = states;
// when only some rows are selected (but not all), select or deselect all of them
Expand All @@ -195,7 +194,7 @@ export default Vue.extend({
this.table.$emit('selection-change', selection ? selection.slice() : []);
}
this.table.$emit('select-all', selection);
}),
},

updateSelectionByRowKey() {
const states = this.states;
Expand Down

0 comments on commit 5872368

Please sign in to comment.