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

Move functionality to label[]

parent e684480e
...@@ -50,44 +50,7 @@ ...@@ -50,44 +50,7 @@
, 500) , 500)
filterResults: (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() formData = form.serialize()
$('.issues-holder, .merge-requests-holder').css("opacity", '0.5') $('.issues-holder, .merge-requests-holder').css("opacity", '0.5')
......
...@@ -17,15 +17,23 @@ module IssuablesHelper ...@@ -17,15 +17,23 @@ module IssuablesHelper
end end
def multi_label_name(current_labels, default_label) def multi_label_name(current_labels, default_label)
if current_labels.presence # current_labels may be a string from before
if current_labels.include? ',' if current_labels.respond_to?('any?')
labels = current_labels.split(',') if current_labels.any?
"#{labels[0]} +#{labels.count - 1} more" if current_labels.count > 1
"#{current_labels[0]} +#{current_labels.count - 1} more"
else else
current_labels current_labels[0]
end
else
default_label
end end
else else
if current_labels.nil?
default_label default_label
else
current_labels
end
end 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