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
No related merge requests found
......@@ -270,7 +270,6 @@ class GitLabDropdown
rowClicked: (el) ->
fieldName = @options.fieldName
field = @dropdown.parent().find("input[name='#{fieldName}']")
selectedIndex = el.parent().index()
if @renderedData
selectedObject = @renderedData[selectedIndex]
......@@ -278,10 +277,6 @@ class GitLabDropdown
field = @dropdown.parent().find("input[name='#{fieldName}'][value='#{value}']")
if el.hasClass(ACTIVE_CLASS)
console.log 'has ACTIVE_CLASS'
# if @options.multiSelect
# console.log field.val(), value
# else
field.remove()
else
fieldName = @options.fieldName
......@@ -296,6 +291,7 @@ class GitLabDropdown
if not @options.multiSelect
@dropdown.find(".#{ACTIVE_CLASS}").removeClass ACTIVE_CLASS
@dropdown.parent().find("input[name='#{fieldName}']").remove()
# Toggle active class for the tick mark
el.toggleClass "is-active"
......@@ -308,8 +304,6 @@ class GitLabDropdown
# Create hidden input for form
input = "<input type='hidden' name='#{fieldName}' value='#{value}' />"
@dropdown.before input
else
console.log 'has field???'
selectFirstRow: ->
selector = '.dropdown-content li:first-child a'
......
......@@ -191,11 +191,13 @@ class @LabelsSelect
else
selected = $dropdown
.closest('.selectbox')
.find('input[type="hidden"]')
.val()
.find("input[name='#{$dropdown.data('field-name')}']")
.map(->
@value
).get()
# need inline-block here instead of show,
# 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
.fadeIn()
$.ajax(
......
......@@ -87,9 +87,9 @@
.light None
.selectbox.hide-collapsed
- 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
%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
Label
= 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