Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
da7aec9c
Commit
da7aec9c
authored
Aug 27, 2019
by
hetech
Committed by
luckyCao
Aug 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Table: set toggleAllSelection as instance property (#17137)
parent
c3a2d417
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
9 deletions
+50
-9
packages/checkbox/src/checkbox.vue
packages/checkbox/src/checkbox.vue
+1
-1
packages/table/src/store/helper.js
packages/table/src/store/helper.js
+4
-0
packages/table/src/store/watcher.js
packages/table/src/store/watcher.js
+2
-3
test/unit/specs/table.spec.js
test/unit/specs/table.spec.js
+43
-5
No files found.
packages/checkbox/src/checkbox.vue
View file @
da7aec9c
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
'is-focus': focus
'is-focus': focus
}"
}"
:tabindex="indeterminate ? 0 : false"
:tabindex="indeterminate ? 0 : false"
:role="indeterminate ?
checkbox
: false"
:role="indeterminate ?
'checkbox'
: false"
:aria-checked="indeterminate ? 'mixed' : false"
:aria-checked="indeterminate ? 'mixed' : false"
>
>
<span
class=
"el-checkbox__inner"
></span>
<span
class=
"el-checkbox__inner"
></span>
...
...
packages/table/src/store/helper.js
View file @
da7aec9c
import
Store
from
'
./index
'
;
import
Store
from
'
./index
'
;
import
debounce
from
'
throttle-debounce/debounce
'
;
export
function
createStore
(
table
,
initialState
=
{})
{
export
function
createStore
(
table
,
initialState
=
{})
{
if
(
!
table
)
{
if
(
!
table
)
{
...
@@ -7,6 +8,9 @@ export function createStore(table, initialState = {}) {
...
@@ -7,6 +8,9 @@ export function createStore(table, initialState = {}) {
const
store
=
new
Store
();
const
store
=
new
Store
();
store
.
table
=
table
;
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
=>
{
Object
.
keys
(
initialState
).
forEach
(
key
=>
{
store
.
states
[
key
]
=
initialState
[
key
];
store
.
states
[
key
]
=
initialState
[
key
];
});
});
...
...
packages/table/src/store/watcher.js
View file @
da7aec9c
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
debounce
from
'
throttle-debounce/debounce
'
;
import
merge
from
'
element-ui/src/utils/merge
'
;
import
merge
from
'
element-ui/src/utils/merge
'
;
import
{
getKeysMap
,
getRowIdentity
,
getColumnById
,
getColumnByKey
,
orderBy
,
toggleRowStatus
}
from
'
../util
'
;
import
{
getKeysMap
,
getRowIdentity
,
getColumnById
,
getColumnByKey
,
orderBy
,
toggleRowStatus
}
from
'
../util
'
;
import
expand
from
'
./expand
'
;
import
expand
from
'
./expand
'
;
...
@@ -168,7 +167,7 @@ export default Vue.extend({
...
@@ -168,7 +167,7 @@ export default Vue.extend({
}
}
},
},
toggleAllSelection
:
debounce
(
10
,
fun
ction
()
{
_toggleAllSele
ction
()
{
const
states
=
this
.
states
;
const
states
=
this
.
states
;
const
{
data
=
[],
selection
}
=
states
;
const
{
data
=
[],
selection
}
=
states
;
// when only some rows are selected (but not all), select or deselect all of them
// when only some rows are selected (but not all), select or deselect all of them
...
@@ -195,7 +194,7 @@ export default Vue.extend({
...
@@ -195,7 +194,7 @@ export default Vue.extend({
this
.
table
.
$emit
(
'
selection-change
'
,
selection
?
selection
.
slice
()
:
[]);
this
.
table
.
$emit
(
'
selection-change
'
,
selection
?
selection
.
slice
()
:
[]);
}
}
this
.
table
.
$emit
(
'
select-all
'
,
selection
);
this
.
table
.
$emit
(
'
select-all
'
,
selection
);
}
)
,
},
updateSelectionByRowKey
()
{
updateSelectionByRowKey
()
{
const
states
=
this
.
states
;
const
states
=
this
.
states
;
...
...
test/unit/specs/table.spec.js
View file @
da7aec9c
...
@@ -567,12 +567,8 @@ describe('Table', () => {
...
@@ -567,12 +567,8 @@ describe('Table', () => {
</el-table>
</el-table>
`
,
`
,
created
()
{
this
.
testData
=
getTestData
();
},
data
()
{
data
()
{
return
{
testData
:
this
.
testData
};
return
{
testData
:
getTestData
()
};
}
}
});
});
...
@@ -1716,6 +1712,48 @@ describe('Table', () => {
...
@@ -1716,6 +1712,48 @@ describe('Table', () => {
},
50
);
},
50
);
});
});
it
(
'
toggleAllSelection debounce
'
,
async
()
=>
{
const
spy
=
sinon
.
spy
();
const
vm
=
createVue
({
template
:
`
<div>
<el-table ref="table" :data="testData" @selection-change="change">
<el-table-column type="selection" />
<el-table-column prop="name" />
</el-table>
<el-table ref="table1" :data="testData1" @selection-change="change">
<el-table-column type="selection" />
<el-table-column prop="name" />
</el-table>
</div>
`
,
data
()
{
return
{
testData
:
getTestData
(),
testData1
:
getTestData
()
};
},
methods
:
{
change
(
selection
)
{
spy
(
selection
);
}
},
mounted
()
{
this
.
$refs
.
table
.
toggleAllSelection
();
this
.
$refs
.
table1
.
toggleAllSelection
();
}
},
true
);
await
wait
(
50
);
expect
(
spy
.
callCount
).
to
.
be
.
equal
(
2
);
expect
(
spy
.
args
[
0
][
0
].
length
).
to
.
be
.
equal
(
5
);
expect
(
spy
.
args
[
1
][
0
].
length
).
to
.
be
.
equal
(
5
);
destroyVM
(
vm
);
});
it
(
'
clearSelection
'
,
()
=>
{
it
(
'
clearSelection
'
,
()
=>
{
const
vm
=
createTable
(
'
selection-change
'
);
const
vm
=
createTable
(
'
selection-change
'
);
vm
.
$refs
.
table
.
toggleRowSelection
(
vm
.
testData
[
0
]);
vm
.
$refs
.
table
.
toggleRowSelection
(
vm
.
testData
[
0
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment