Commit 1617d1e0 authored by Jacob Schatz's avatar Jacob Schatz Committed by Jacob Schatz

Move functionality to label[]

parent e684480e
......@@ -50,45 +50,8 @@
, 500)
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()
formData = form.serialize()
$('.issues-holder, .merge-requests-holder').css("opacity", '0.5')
formAction = form.attr('action')
......
......@@ -17,15 +17,23 @@ module IssuablesHelper
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"
# current_labels may be a string from before
if current_labels.respond_to?('any?')
if current_labels.any?
if current_labels.count > 1
"#{current_labels[0]} +#{current_labels.count - 1} more"
else
current_labels[0]
end
else
current_labels
default_label
end
else
default_label
if current_labels.nil?
default_label
else
current_labels
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment