Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
f3afcb87
Commit
f3afcb87
authored
Mar 08, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handles multi-selected values
Fixes an issue where values couldnlt be unselected
parent
6c891962
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
19 deletions
+40
-19
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+29
-17
app/assets/javascripts/labels_select.js.coffee
app/assets/javascripts/labels_select.js.coffee
+11
-2
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
f3afcb87
...
@@ -39,7 +39,7 @@ class GitLabDropdownFilter
...
@@ -39,7 +39,7 @@ class GitLabDropdownFilter
key
:
@
options
.
keys
key
:
@
options
.
keys
)
)
@
callback
results
@
options
.
callback
results
class
GitLabDropdownRemote
class
GitLabDropdownRemote
constructor
:
(
@
dataEndpoint
,
@
options
)
->
constructor
:
(
@
dataEndpoint
,
@
options
)
->
...
@@ -75,6 +75,7 @@ class GitLabDropdownRemote
...
@@ -75,6 +75,7 @@ class GitLabDropdownRemote
class
GitLabDropdown
class
GitLabDropdown
LOADING_CLASS
=
"is-loading"
LOADING_CLASS
=
"is-loading"
PAGE_TWO_CLASS
=
"is-page-two"
PAGE_TWO_CLASS
=
"is-page-two"
ACTIVE_CLASS
=
"is-active"
constructor
:
(
@
el
,
@
options
)
->
constructor
:
(
@
el
,
@
options
)
->
self
=
@
self
=
@
...
@@ -226,24 +227,35 @@ class GitLabDropdown
...
@@ -226,24 +227,35 @@ class GitLabDropdown
rowClicked
:
(
el
)
->
rowClicked
:
(
el
)
->
fieldName
=
@
options
.
fieldName
fieldName
=
@
options
.
fieldName
selectedIndex
=
el
.
parent
().
index
()
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
)
if
@
renderedData
selectedObject
=
@
renderedData
[
selectedIndex
]
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
if
@
options
.
multiSelect
if
el
.
hasClass
(
ACTIVE_CLASS
)
field
Name
=
"
#{
fieldName
}
[]"
field
.
remove
()
else
else
@
dropdown
.
find
(
'.is-active'
).
removeClass
'is-active'
fieldName
=
@
options
.
fieldName
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
).
remove
()
selectedIndex
=
el
.
parent
().
index
()
if
@
renderedData
# Toggle active class for the tick mark
selectedObject
=
@
renderedData
[
selectedIndex
]
el
.
toggleClass
"is-active"
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
if
value
if
@
options
.
multiSelect
# Create hidden input for form
oldValue
=
field
.
val
()
input
=
"<input type='hidden' name='
#{
fieldName
}
' value='
#{
value
}
' />"
if
oldValue
@
dropdown
.
before
input
value
=
"
#{
oldValue
}
,
#{
value
}
"
else
@
dropdown
.
find
(
ACTIVE_CLASS
).
removeClass
ACTIVE_CLASS
field
.
remove
()
# Toggle active class for the tick mark
el
.
toggleClass
"is-active"
if
value
if
!
field
.
length
# Create hidden input for form
input
=
"<input type='hidden' name='
#{
fieldName
}
' />"
@
dropdown
.
before
input
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
).
val
value
selectFirstRow
:
->
selectFirstRow
:
->
selector
=
'.dropdown-content li:first-child a'
selector
=
'.dropdown-content li:first-child a'
...
...
app/assets/javascripts/labels_select.js.coffee
View file @
f3afcb87
...
@@ -4,6 +4,8 @@ class @LabelsSelect
...
@@ -4,6 +4,8 @@ class @LabelsSelect
projectId
=
$
(
dropdown
).
data
(
'project-id'
)
projectId
=
$
(
dropdown
).
data
(
'project-id'
)
labelUrl
=
$
(
dropdown
).
data
(
"labels"
)
labelUrl
=
$
(
dropdown
).
data
(
"labels"
)
selectedLabel
=
$
(
dropdown
).
data
(
'selected'
)
selectedLabel
=
$
(
dropdown
).
data
(
'selected'
)
if
selectedLabel
selectedLabel
=
selectedLabel
.
split
(
","
)
newLabelField
=
$
(
'#new_label_name'
)
newLabelField
=
$
(
'#new_label_name'
)
newColorField
=
$
(
'#new_label_color'
)
newColorField
=
$
(
'#new_label_color'
)
showNo
=
$
(
dropdown
).
data
(
'show-no'
)
showNo
=
$
(
dropdown
).
data
(
'show-no'
)
...
@@ -60,10 +62,17 @@ class @LabelsSelect
...
@@ -60,10 +62,17 @@ class @LabelsSelect
if
data
.
length
>
2
if
data
.
length
>
2
data
.
splice
2
,
0
,
"divider"
data
.
splice
2
,
0
,
"divider"
callback
data
callback
data
renderRow
:
(
label
)
->
renderRow
:
(
label
)
->
selected
=
if
label
.
title
is
selectedLabel
then
"is-active"
else
""
if
$
.
isArray
(
selectedLabel
)
selected
=
""
$
.
each
selectedLabel
,
(
i
,
selectedLbl
)
->
selectedLbl
=
selectedLbl
.
trim
()
if
selected
is
""
&&
label
.
title
is
selectedLbl
selected
=
"is-active"
else
selected
=
if
label
.
title
is
selectedLabel
then
"is-active"
else
""
"<li>
"<li>
<a href='#' class='
#{
selected
}
'>
<a href='#' class='
#{
selected
}
'>
...
...
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