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
Jérome Perrin
gitlab-ce
Commits
e684480e
Commit
e684480e
authored
Apr 07, 2016
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper selecting multiple labels.
parent
19b9df2d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
10 deletions
+62
-10
app/assets/javascripts/issues.js.coffee
app/assets/javascripts/issues.js.coffee
+41
-3
app/assets/javascripts/labels_select.js.coffee
app/assets/javascripts/labels_select.js.coffee
+7
-6
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+13
-0
app/views/shared/issuable/_label_dropdown.html.haml
app/views/shared/issuable/_label_dropdown.html.haml
+1
-1
No files found.
app/assets/javascripts/issues.js.coffee
View file @
e684480e
...
...
@@ -49,11 +49,49 @@
Issues
.
filterResults
$
(
"#issue_search_form"
)
,
500
)
filterResults
:
(
form
,
inputs
)
=>
console
.
log
(
'form'
,
form
)
filterResults
:
(
form
)
=>
# Assume for now there is only 1 multi select field
# Find the hidden inputs with square brackets
$multiInputs
=
form
.
find
(
'input[name$="[]"]'
)
if
$multiInputs
.
length
# get the name of one of them
multiInputName
=
$multiInputs
.
first
()
.
attr
(
'name'
)
# get the singular name by
# removing the square brackets from the name
singularName
=
multiInputName
.
replace
(
'[]'
,
''
)
# clone the form so we can mess around with it.
$clonedForm
=
form
.
clone
()
# get those inputs from the cloned form
$inputs
=
$clonedForm
.
find
(
"input[name='
#{
multiInputName
}
']"
)
# make a comma seperated list of labels
commaSeperated
=
$inputs
.
map
(
->
$
(
this
).
val
())
.
get
()
.
join
(
','
)
# append on a hidden input with the comma
# seperated values in it
$clonedForm
.
append
(
$
(
'<input />'
)
.
attr
(
'type'
,
'hidden'
)
.
attr
(
'name'
,
singularName
)
.
val
(
commaSeperated
)
)
# remove the multi inputs from the
# cloned form so they don't get serialized
$inputs
.
remove
()
# serialize the cloned form
formData
=
$clonedForm
.
serialize
()
else
formData
=
form
.
serialize
()
$
(
'.issues-holder, .merge-requests-holder'
).
css
(
"opacity"
,
'0.5'
)
formAction
=
form
.
attr
(
'action'
)
formData
=
form
.
serialize
()
issuesUrl
=
formAction
issuesUrl
+=
(
"
#{
if
formAction
.
indexOf
(
"?"
)
<
0
then
'?'
else
'&'
}
"
)
issuesUrl
+=
formData
...
...
app/assets/javascripts/labels_select.js.coffee
View file @
e684480e
...
...
@@ -6,7 +6,7 @@ class @LabelsSelect
labelUrl
=
$dropdown
.
data
(
'labels'
)
issueUpdateURL
=
$dropdown
.
data
(
'issueUpdate'
)
selectedLabel
=
$dropdown
.
data
(
'selected'
)
if
selectedLabel
?
if
selectedLabel
?
and
not
$dropdown
.
hasClass
'js-multiselect'
selectedLabel
=
selectedLabel
.
split
(
','
)
newLabelField
=
$
(
'#new_label_name'
)
newColorField
=
$
(
'#new_label_color'
)
...
...
@@ -246,7 +246,12 @@ class @LabelsSelect
selectedLabels
=
$dropdown
.
closest
(
'form'
)
.
find
(
"input[type='hidden'][name='
#{
$dropdown
.
data
(
'field-name'
)
}
']"
)
Issues
.
filterResults
$dropdown
.
closest
(
'form'
),
selectedLabels
Issues
.
filterResults
(
$dropdown
.
closest
(
'form'
),
selectedLabels
,
$dropdown
.
data
(
'singularFieldName'
),
$dropdown
.
data
(
'fieldName'
)
)
else
if
$dropdown
.
hasClass
(
'js-filter-submit'
)
$dropdown
.
closest
(
'form'
).
submit
()
else
...
...
@@ -257,18 +262,14 @@ class @LabelsSelect
page
=
$
(
'body'
).
data
'page'
isIssueIndex
=
page
is
'projects:issues:index'
isMRIndex
=
page
is
page
is
'projects:merge_requests:index'
console
.
log
'clicked'
if
$dropdown
.
hasClass
(
'js-filter-submit'
)
and
(
isIssueIndex
or
isMRIndex
)
if
not
$dropdown
.
hasClass
'js-multiselect'
selectedLabel
=
label
.
title
Issues
.
filterResults
$dropdown
.
closest
(
'form'
)
else
if
$dropdown
.
hasClass
'js-filter-submit'
console
.
log
'clicked else if'
$dropdown
.
closest
(
'form'
).
submit
()
else
console
.
log
'clicked else'
if
$dropdown
.
hasClass
'js-multiselect'
console
.
log
'clicked else --> if'
return
else
saveLabelData
()
...
...
app/helpers/issuables_helper.rb
View file @
e684480e
...
...
@@ -16,6 +16,19 @@ module IssuablesHelper
base_issuable_scope
(
issuable
).
where
(
'iid > ?'
,
issuable
.
iid
).
last
end
def
multi_label_name
(
current_labels
,
default_label
)
if
current_labels
.
presence
if
current_labels
.
include?
','
labels
=
current_labels
.
split
(
','
)
"
#{
labels
[
0
]
}
+
#{
labels
.
count
-
1
}
more"
else
current_labels
end
else
default_label
end
end
def
issuable_json_path
(
issuable
)
project
=
issuable
.
project
...
...
app/views/shared/issuable/_label_dropdown.html.haml
View file @
e684480e
...
...
@@ -4,7 +4,7 @@
%button
.dropdown-menu-toggle.js-label-select.js-filter-submit.js-extra-options
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"label_name"
,
show_no:
"true"
,
show_any:
"true"
,
selected:
params
[
:label_name
],
project_id:
@project
.
try
(
:id
),
labels:
labels_filter_path
,
default_label:
"Label"
}}
%button
.dropdown-menu-toggle.js-label-select.js-filter-submit.js-multiselect.js-extra-options
{
type:
"button"
,
data:
{
toggle:
"dropdown"
,
field_name:
"label_name[]"
,
show_no:
"true"
,
show_any:
"true"
,
selected:
params
[
:label_name
],
project_id:
@project
.
try
(
:id
),
labels:
labels_filter_path
,
default_label:
"Label"
}}
%span
.dropdown-toggle-text
=
h
(
params
[
:label_name
].
presence
||
"Label"
)
=
h
(
multi_label_name
(
params
[
:label_name
],
"Label"
)
)
=
icon
(
'chevron-down'
)
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
.dropdown-page-one
...
...
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