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
...
@@ -231,6 +231,13 @@ class GitLabDropdown
html
=
@
options
.
renderRow
(
data
)
html
=
@
options
.
renderRow
(
data
)
else
else
selected
=
if
@
options
.
isSelected
then
@
options
.
isSelected
(
data
)
else
false
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
"#"
url
=
if
@
options
.
url
then
@
options
.
url
(
data
)
else
"#"
text
=
if
@
options
.
text
then
@
options
.
text
(
data
)
else
""
text
=
if
@
options
.
text
then
@
options
.
text
(
data
)
else
""
cssClass
=
""
;
cssClass
=
""
;
...
@@ -263,7 +270,7 @@ class GitLabDropdown
...
@@ -263,7 +270,7 @@ class GitLabDropdown
rowClicked
:
(
el
)
->
rowClicked
:
(
el
)
->
fieldName
=
@
options
.
fieldName
fieldName
=
@
options
.
fieldName
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
)
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
)
selectedIndex
=
el
.
parent
().
index
()
selectedIndex
=
el
.
parent
().
index
()
if
@
renderedData
if
@
renderedData
selectedObject
=
@
renderedData
[
selectedIndex
]
selectedObject
=
@
renderedData
[
selectedIndex
]
...
@@ -271,10 +278,11 @@ class GitLabDropdown
...
@@ -271,10 +278,11 @@ class GitLabDropdown
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
if
@
options
.
multiSelect
console
.
log
'has ACTIVE_CLASS'
console
.
log
field
.
val
(),
value
# if @options.multiSelect
else
# console.log field.val(), value
field
.
remove
()
# else
field
.
remove
()
else
else
fieldName
=
@
options
.
fieldName
fieldName
=
@
options
.
fieldName
selectedIndex
=
el
.
parent
().
index
()
selectedIndex
=
el
.
parent
().
index
()
...
@@ -286,11 +294,7 @@ class GitLabDropdown
...
@@ -286,11 +294,7 @@ class GitLabDropdown
if
!
value
?
if
!
value
?
field
.
remove
()
field
.
remove
()
if
@
options
.
multiSelect
if
not
@
options
.
multiSelect
oldValue
=
field
.
val
()
if
oldValue
value
=
"
#{
oldValue
}
,
#{
value
}
"
else
@
dropdown
.
find
(
".
#{
ACTIVE_CLASS
}
"
).
removeClass
ACTIVE_CLASS
@
dropdown
.
find
(
".
#{
ACTIVE_CLASS
}
"
).
removeClass
ACTIVE_CLASS
# Toggle active class for the tick mark
# Toggle active class for the tick mark
...
@@ -299,14 +303,13 @@ class GitLabDropdown
...
@@ -299,14 +303,13 @@ class GitLabDropdown
# Toggle the dropdown label
# Toggle the dropdown label
if
@
options
.
toggleLabel
if
@
options
.
toggleLabel
$
(
@
el
).
find
(
".dropdown-toggle-text"
).
text
@
options
.
toggleLabel
(
selectedObject
)
$
(
@
el
).
find
(
".dropdown-toggle-text"
).
text
@
options
.
toggleLabel
(
selectedObject
)
if
value
?
if
value
?
if
!
field
.
length
if
!
field
.
length
# Create hidden input for form
# Create hidden input for form
input
=
"<input type='hidden' name='
#{
fieldName
}
' />"
input
=
"<input type='hidden' name='
#{
fieldName
}
'
value='
#{
value
}
'
/>"
@
dropdown
.
before
input
@
dropdown
.
before
input
else
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
).
val
value
console
.
log
'has field???'
selectFirstRow
:
->
selectFirstRow
:
->
selector
=
'.dropdown-content li:first-child a'
selector
=
'.dropdown-content li:first-child a'
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
c81b2613
...
@@ -65,7 +65,8 @@
...
@@ -65,7 +65,8 @@
.light
None
.light
None
.selectbox.hide-collapsed
.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?
-
if
issuable
.
project
.
labels
.
any?
.block.labels
.block.labels
...
@@ -85,7 +86,8 @@
...
@@ -85,7 +86,8 @@
-
else
-
else
.light
None
.light
None
.selectbox.hide-collapsed
.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
.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
)}}
%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
%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