Commit d17b5499 authored by Jacob Schatz's avatar Jacob Schatz

Make remove multi and remove single work.

Make add single and add multi work properly.
Multiple inputs for multiselect
parent c81b2613
...@@ -270,7 +270,6 @@ class GitLabDropdown ...@@ -270,7 +270,6 @@ class GitLabDropdown
rowClicked: (el) -> rowClicked: (el) ->
fieldName = @options.fieldName fieldName = @options.fieldName
field = @dropdown.parent().find("input[name='#{fieldName}']")
selectedIndex = el.parent().index() selectedIndex = el.parent().index()
if @renderedData if @renderedData
selectedObject = @renderedData[selectedIndex] selectedObject = @renderedData[selectedIndex]
...@@ -278,10 +277,6 @@ class GitLabDropdown ...@@ -278,10 +277,6 @@ class GitLabDropdown
field = @dropdown.parent().find("input[name='#{fieldName}'][value='#{value}']") field = @dropdown.parent().find("input[name='#{fieldName}'][value='#{value}']")
if el.hasClass(ACTIVE_CLASS) if el.hasClass(ACTIVE_CLASS)
console.log 'has ACTIVE_CLASS'
# if @options.multiSelect
# console.log field.val(), value
# else
field.remove() field.remove()
else else
fieldName = @options.fieldName fieldName = @options.fieldName
...@@ -296,6 +291,7 @@ class GitLabDropdown ...@@ -296,6 +291,7 @@ class GitLabDropdown
if not @options.multiSelect if not @options.multiSelect
@dropdown.find(".#{ACTIVE_CLASS}").removeClass ACTIVE_CLASS @dropdown.find(".#{ACTIVE_CLASS}").removeClass ACTIVE_CLASS
@dropdown.parent().find("input[name='#{fieldName}']").remove()
# Toggle active class for the tick mark # Toggle active class for the tick mark
el.toggleClass "is-active" el.toggleClass "is-active"
...@@ -308,8 +304,6 @@ class GitLabDropdown ...@@ -308,8 +304,6 @@ class GitLabDropdown
# Create hidden input for form # Create hidden input for form
input = "<input type='hidden' name='#{fieldName}' value='#{value}' />" input = "<input type='hidden' name='#{fieldName}' value='#{value}' />"
@dropdown.before input @dropdown.before input
else
console.log 'has field???'
selectFirstRow: -> selectFirstRow: ->
selector = '.dropdown-content li:first-child a' selector = '.dropdown-content li:first-child a'
......
...@@ -191,11 +191,13 @@ class @LabelsSelect ...@@ -191,11 +191,13 @@ class @LabelsSelect
else else
selected = $dropdown selected = $dropdown
.closest('.selectbox') .closest('.selectbox')
.find('input[type="hidden"]') .find("input[name='#{$dropdown.data('field-name')}']")
.val() .map(->
@value
).get()
# need inline-block here instead of show, # need inline-block here instead of show,
# which will default to the element's style in this case inline. # which will default to the element's style in this case inline.
selected = if selected? then selected.split(',') else [''] selected = if selected.length then selected else ['']
$loading $loading
.fadeIn() .fadeIn()
$.ajax( $.ajax(
......
...@@ -87,9 +87,9 @@ ...@@ -87,9 +87,9 @@
.light None .light None
.selectbox.hide-collapsed .selectbox.hide-collapsed
- issuable.labels.each do |label| - issuable.labels.each do |label|
= f.hidden_field 'label_name', value: label.id, id: nil = hidden_field_tag 'issue[label_names][]', label.id, id: nil
.dropdown .dropdown
%button.dropdown-menu-toggle.js-label-select.js-multiselect{type: "button", data: {toggle: "dropdown", field_name: "issue[label_name]", show_no: "true", show_any: "true", selected: issuable.label_names.join(","), project_id: (@project.id if @project), issue_update: namespace_project_issue_path(@project.namespace, @project, issuable.id, :json), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}} %button.dropdown-menu-toggle.js-label-select.js-multiselect{type: "button", data: {toggle: "dropdown", field_name: "issue[label_names][]", show_no: "true", show_any: "true", selected: issuable.label_names.join(","), project_id: (@project.id if @project), issue_update: namespace_project_issue_path(@project.namespace, @project, issuable.id, :json), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project)}}
%span.dropdown-toggle-text %span.dropdown-toggle-text
Label Label
= icon('chevron-down') = icon('chevron-down')
......
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