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
2f0ba607
Commit
2f0ba607
authored
Oct 25, 2016
by
杨奕
Committed by
FuryBean
Oct 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Select: add test (#636)
parent
cfe8b895
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
439 additions
and
16 deletions
+439
-16
examples/docs/zh-cn/select.md
examples/docs/zh-cn/select.md
+1
-1
packages/select/src/option-group.vue
packages/select/src/option-group.vue
+7
-1
packages/select/src/option.vue
packages/select/src/option.vue
+12
-9
packages/select/src/select.vue
packages/select/src/select.vue
+9
-5
test/unit/specs/select.spec.js
test/unit/specs/select.spec.js
+410
-0
No files found.
examples/docs/zh-cn/select.md
View file @
2f0ba607
...
...
@@ -262,7 +262,7 @@
包含清空按钮,可将选择器清空为初始状态
:::demo 为
`el-select`
设置
`clearable`
属性,则可将选择器清空。需要注意的是,
`clearable`
属性仅
使
用于单选。
:::demo 为
`el-select`
设置
`clearable`
属性,则可将选择器清空。需要注意的是,
`clearable`
属性仅
适
用于单选。
```
html
<template>
<el-select
v-model=
"value4"
clearable
>
...
...
packages/select/src/option-group.vue
View file @
2f0ba607
...
...
@@ -25,9 +25,15 @@
}
},
watch
:
{
disabled
(
val
)
{
this
.
broadcast
(
'
option
'
,
'
handleGroupDisabled
'
,
val
);
}
},
mounted
()
{
if
(
this
.
disabled
)
{
this
.
broadcast
(
'
option
'
,
'
disableOptions
'
);
this
.
broadcast
(
'
option
'
,
'
handleGroupDisabled
'
,
this
.
disabled
);
}
}
};
...
...
packages/select/src/option.vue
View file @
2f0ba607
...
...
@@ -4,7 +4,7 @@
@
click.stop=
"selectOptionClick"
class=
"el-select-dropdown__item"
v-show=
"queryPassed"
:class=
"
{ 'selected': itemSelected, 'is-disabled': disabled, 'hover': parent.hoverIndex === index }">
:class=
"
{ 'selected': itemSelected, 'is-disabled': disabled
|| groupDisabled
, 'hover': parent.hoverIndex === index }">
<slot>
<span>
{{
currentLabel
}}
</span>
</slot>
...
...
@@ -39,13 +39,17 @@
data
()
{
return
{
index
:
-
1
,
groupDisabled
:
false
,
queryPassed
:
true
,
hitState
:
false
,
currentLabel
:
this
.
label
hitState
:
false
};
},
computed
:
{
currentLabel
()
{
return
this
.
label
||
((
typeof
this
.
value
===
'
string
'
||
typeof
this
.
value
===
'
number
'
)
?
this
.
value
:
''
);
},
parent
()
{
let
result
=
this
.
$parent
;
while
(
!
result
.
isSelect
)
{
...
...
@@ -76,18 +80,18 @@
},
methods
:
{
disableOptions
(
)
{
this
.
disabled
=
true
;
handleGroupDisabled
(
val
)
{
this
.
groupDisabled
=
val
;
},
hoverItem
()
{
if
(
!
this
.
disabled
)
{
if
(
!
this
.
disabled
&&
!
this
.
groupDisabled
)
{
this
.
parent
.
hoverIndex
=
this
.
parent
.
options
.
indexOf
(
this
);
}
},
selectOptionClick
()
{
if
(
this
.
disabled
!==
true
)
{
if
(
this
.
disabled
!==
true
&&
this
.
groupDisabled
!==
true
)
{
this
.
dispatch
(
'
select
'
,
'
handleOptionClick
'
,
this
);
}
},
...
...
@@ -107,7 +111,6 @@
},
created
()
{
this
.
currentLabel
=
this
.
currentLabel
||
((
typeof
this
.
value
===
'
string
'
||
typeof
this
.
value
===
'
number
'
)
?
this
.
value
:
''
);
this
.
parent
.
options
.
push
(
this
);
this
.
parent
.
optionsCount
++
;
this
.
parent
.
filteredOptionsCount
++
;
...
...
@@ -118,7 +121,7 @@
}
this
.
$on
(
'
queryChange
'
,
this
.
queryChange
);
this
.
$on
(
'
disableOptions
'
,
this
.
disableOptions
);
this
.
$on
(
'
handleGroupDisabled
'
,
this
.
handleGroupDisabled
);
this
.
$on
(
'
resetIndex
'
,
this
.
resetIndex
);
},
...
...
packages/select/src/select.vue
View file @
2f0ba607
...
...
@@ -53,11 +53,11 @@
<transition
name=
"md-fade-bottom"
@
after-leave=
"doDestroy"
>
<el-select-menu
ref=
"popper"
v-show=
"visible &&
nodata
Text !== false"
>
v-show=
"visible &&
empty
Text !== false"
>
<ul
class=
"el-select-dropdown__list"
v-show=
"options.length > 0 && filteredOptionsCount > 0 && !loading"
>
<slot></slot>
</ul>
<p
class=
"el-select-dropdown__nodata"
v-if=
"
nodataText"
>
{{
nodata
Text
}}
</p>
<p
class=
"el-select-dropdown__nodata"
v-if=
"
emptyText"
>
{{
empty
Text
}}
</p>
</el-select-menu>
</transition>
</div>
...
...
@@ -106,7 +106,7 @@
return
criteria
;
},
nodata
Text
()
{
empty
Text
()
{
if
(
this
.
loading
)
{
return
'
加载中
'
;
}
else
{
...
...
@@ -439,7 +439,9 @@
this
.
hoverIndex
=
0
;
}
this
.
resetScrollTop
();
if
(
this
.
options
[
this
.
hoverIndex
].
disabled
===
true
||
!
this
.
options
[
this
.
hoverIndex
].
queryPassed
)
{
if
(
this
.
options
[
this
.
hoverIndex
].
disabled
===
true
||
this
.
options
[
this
.
hoverIndex
].
groupDisabled
===
true
||
!
this
.
options
[
this
.
hoverIndex
].
queryPassed
)
{
this
.
navigateOptions
(
'
next
'
);
}
}
...
...
@@ -449,7 +451,9 @@
this
.
hoverIndex
=
this
.
options
.
length
-
1
;
}
this
.
resetScrollTop
();
if
(
this
.
options
[
this
.
hoverIndex
].
disabled
===
true
||
!
this
.
options
[
this
.
hoverIndex
].
queryPassed
)
{
if
(
this
.
options
[
this
.
hoverIndex
].
disabled
===
true
||
this
.
options
[
this
.
hoverIndex
].
groupDisabled
===
true
||
!
this
.
options
[
this
.
hoverIndex
].
queryPassed
)
{
this
.
navigateOptions
(
'
prev
'
);
}
}
...
...
test/unit/specs/select.spec.js
0 → 100644
View file @
2f0ba607
This diff is collapsed.
Click to expand it.
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