Move functionality to label[]
This commit is contained in:
parent
e684480eeb
commit
1617d1e026
|
@ -50,45 +50,8 @@
|
||||||
, 500)
|
, 500)
|
||||||
|
|
||||||
filterResults: (form) =>
|
filterResults: (form) =>
|
||||||
# Assume for now there is only 1 multi select field
|
|
||||||
# Find the hidden inputs with square brackets
|
formData = form.serialize()
|
||||||
$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')
|
$('.issues-holder, .merge-requests-holder').css("opacity", '0.5')
|
||||||
formAction = form.attr('action')
|
formAction = form.attr('action')
|
||||||
|
|
|
@ -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
|
||||||
|
current_labels[0]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
default_label
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if current_labels.nil?
|
||||||
|
default_label
|
||||||
else
|
else
|
||||||
current_labels
|
current_labels
|
||||||
end
|
end
|
||||||
else
|
|
||||||
default_label
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue