Move functionality to label[]
This commit is contained in:
parent
e684480eeb
commit
1617d1e026
|
@ -50,44 +50,7 @@
|
|||
, 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()
|
||||
|
||||
$('.issues-holder, .merge-requests-holder').css("opacity", '0.5')
|
||||
|
|
|
@ -17,16 +17,24 @@ 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
|
||||
current_labels[0]
|
||||
end
|
||||
else
|
||||
default_label
|
||||
end
|
||||
else
|
||||
if current_labels.nil?
|
||||
default_label
|
||||
else
|
||||
current_labels
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def issuable_json_path(issuable)
|
||||
|
|
Loading…
Reference in New Issue