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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
c81b2613
Commit
c81b2613
authored
Mar 15, 2016
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bugs with select dropdown and multiselection
parent
ed517c5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+17
-14
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+4
-2
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
c81b2613
...
...
@@ -231,6 +231,13 @@ class GitLabDropdown
html
=
@
options
.
renderRow
(
data
)
else
selected
=
if
@
options
.
isSelected
then
@
options
.
isSelected
(
data
)
else
false
if
not
selected
value
=
if
@
options
.
id
then
@
options
.
id
(
data
)
else
data
.
id
fieldName
=
@
options
.
fieldName
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
if
field
.
length
selected
=
true
url
=
if
@
options
.
url
then
@
options
.
url
(
data
)
else
"#"
text
=
if
@
options
.
text
then
@
options
.
text
(
data
)
else
""
cssClass
=
""
;
...
...
@@ -263,7 +270,7 @@ class GitLabDropdown
rowClicked
:
(
el
)
->
fieldName
=
@
options
.
fieldName
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
)
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
)
selectedIndex
=
el
.
parent
().
index
()
if
@
renderedData
selectedObject
=
@
renderedData
[
selectedIndex
]
...
...
@@ -271,10 +278,11 @@ class GitLabDropdown
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
if
@
options
.
multiSelect
console
.
log
field
.
val
(),
value
else
field
.
remove
()
console
.
log
'has ACTIVE_CLASS'
# if @options.multiSelect
# console.log field.val(), value
# else
field
.
remove
()
else
fieldName
=
@
options
.
fieldName
selectedIndex
=
el
.
parent
().
index
()
...
...
@@ -286,11 +294,7 @@ class GitLabDropdown
if
!
value
?
field
.
remove
()
if
@
options
.
multiSelect
oldValue
=
field
.
val
()
if
oldValue
value
=
"
#{
oldValue
}
,
#{
value
}
"
else
if
not
@
options
.
multiSelect
@
dropdown
.
find
(
".
#{
ACTIVE_CLASS
}
"
).
removeClass
ACTIVE_CLASS
# Toggle active class for the tick mark
...
...
@@ -299,14 +303,13 @@ class GitLabDropdown
# Toggle the dropdown label
if
@
options
.
toggleLabel
$
(
@
el
).
find
(
".dropdown-toggle-text"
).
text
@
options
.
toggleLabel
(
selectedObject
)
if
value
?
if
!
field
.
length
# Create hidden input for form
input
=
"<input type='hidden' name='
#{
fieldName
}
' />"
input
=
"<input type='hidden' name='
#{
fieldName
}
'
value='
#{
value
}
'
/>"
@
dropdown
.
before
input
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
).
val
value
else
console
.
log
'has field???'
selectFirstRow
:
->
selector
=
'.dropdown-content li:first-child a'
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
c81b2613
...
...
@@ -65,7 +65,8 @@
.light
None
.selectbox.hide-collapsed
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable"
,
placeholder:
"Search milestones"
,
data:
{
show_no:
true
,
field_name:
"milestone_id"
,
project_id:
@project
.
id
,
issuable_id:
issuable
.
id
,
milestones:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
,
:json
),
issue_update:
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
issuable
.
id
,
:json
),
use_id:
true
}})
=
f
.
hidden_field
'milestone_id'
,
value:
issuable
.
milestone
.
id
,
id:
nil
=
dropdown_tag
(
"Milestone"
,
options:
{
title:
"Assign milestone"
,
toggle_class:
'js-milestone-select'
,
filter:
true
,
dropdown_class:
"dropdown-menu-selectable"
,
placeholder:
"Search milestones"
,
data:
{
show_no:
true
,
field_name:
"issue[milestone_id]"
,
project_id:
@project
.
id
,
issuable_id:
issuable
.
id
,
milestones:
namespace_project_milestones_path
(
@project
.
namespace
,
@project
,
:json
),
issue_update:
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
issuable
.
id
,
:json
),
use_id:
true
}})
-
if
issuable
.
project
.
labels
.
any?
.block.labels
...
...
@@ -85,7 +86,8 @@
-
else
.light
None
.selectbox.hide-collapsed
=
f
.
hidden_field
'label_name'
,
value:
issuable
.
labels
.
map
(
&
:id
).
join
(
','
)
-
issuable
.
labels
.
each
do
|
label
|
=
f
.
hidden_field
'label_name'
,
value:
label
.
id
,
id:
nil
.dropdown
%button
.dropdown-menu-toggle.js-label-select.js-multiselect
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"issue[label_name]"
,
show_no:
"true"
,
show_any:
"true"
,
selected:
issuable
.
label_names
.
join
(
","
),
project_id:
(
@project
.
id
if
@project
),
issue_update:
namespace_project_issue_path
(
@project
.
namespace
,
@project
,
issuable
.
id
,
:json
),
labels:
(
namespace_project_labels_path
(
@project
.
namespace
,
@project
,
:json
)
if
@project
)}}
%span
.dropdown-toggle-text
...
...
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