Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-04-07 21:57:21 +0300
committerJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-04-13 23:10:49 +0300
commite684480eebe803c21545b3a8ea5a972c54ba7ea4 (patch)
treef211dd6f280ccb86943290db349b3fd12e211c7c /app/assets/javascripts/issues.js.coffee
parent19b9df2d4fe73bb30de1711a15664eedb2e46afa (diff)
Proper selecting multiple labels.
Diffstat (limited to 'app/assets/javascripts/issues.js.coffee')
-rw-r--r--app/assets/javascripts/issues.js.coffee44
1 files changed, 41 insertions, 3 deletions
diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee
index dca5bc55eb2..40a89d8c2f4 100644
--- a/app/assets/javascripts/issues.js.coffee
+++ b/app/assets/javascripts/issues.js.coffee
@@ -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