Skip to content
Snippets Groups Projects
Commit 8c1e3c77 authored by Jacob Schatz's avatar Jacob Schatz
Browse files

Add multi select stay open functionality

parent 22aef628
No related branches found
No related tags found
1 merge request!3175Updates sidebar to use new dropdowns for issues and merge requests
Loading
@@ -129,7 +129,7 @@ class GitLabDropdown
Loading
@@ -129,7 +129,7 @@ class GitLabDropdown
   
@dropdown.on "shown.bs.dropdown", @opened @dropdown.on "shown.bs.dropdown", @opened
@dropdown.on "hidden.bs.dropdown", @hidden @dropdown.on "hidden.bs.dropdown", @hidden
@dropdown.on "click", ".dropdown-menu", @shouldPropagate @dropdown.on "click", ".dropdown-menu, .dropdown-menu-close", @shouldPropagate
   
if @dropdown.find(".dropdown-toggle-page").length if @dropdown.find(".dropdown-toggle-page").length
@dropdown.find(".dropdown-toggle-page, .dropdown-menu-back").on "click", (e) => @dropdown.find(".dropdown-toggle-page, .dropdown-menu-back").on "click", (e) =>
Loading
@@ -181,7 +181,12 @@ class GitLabDropdown
Loading
@@ -181,7 +181,12 @@ class GitLabDropdown
   
shouldPropagate: (e) => shouldPropagate: (e) =>
if @options.multiSelect if @options.multiSelect
$target = $(e.target)
if not $target.hasClass('dropdown-menu-close') and not $target.hasClass('dropdown-menu-close-icon')
e.stopPropagation() e.stopPropagation()
return false
else
return true
   
opened: => opened: =>
contentHtml = $('.dropdown-content', @dropdown).html() contentHtml = $('.dropdown-content', @dropdown).html()
Loading
Loading
Loading
@@ -82,6 +82,23 @@ class @LabelsSelect
Loading
@@ -82,6 +82,23 @@ class @LabelsSelect
# This allows us to enable the button when ready # This allows us to enable the button when ready
enableLabelCreateButton = -> enableLabelCreateButton = ->
if newLabelField.val() isnt '' and newColorField.val() isnt '' if newLabelField.val() isnt '' and newColorField.val() isnt ''
$newLabelError.hide()
$('.js-new-label-btn').disable()
# Create new label with API
Api.newLabel projectId, {
name: newLabelField.val()
color: newColorField.val()
}, (label) ->
$('.js-new-label-btn').enable()
if label.message?
$newLabelError
.text label.message
.show()
else
$('.dropdown-menu-back', $dropdown.parent()).trigger 'click'
$newLabelCreateButton.enable() $newLabelCreateButton.enable()
else else
$newLabelCreateButton.disable() $newLabelCreateButton.disable()
Loading
@@ -115,6 +132,35 @@ class @LabelsSelect
Loading
@@ -115,6 +132,35 @@ class @LabelsSelect
else else
$('.dropdown-menu-back', $dropdown.parent()).trigger 'click' $('.dropdown-menu-back', $dropdown.parent()).trigger 'click'
   
saveLabelData = ->
selected = $dropdown
.closest('.selectbox')
.find("input[name='#{$dropdown.data('field-name')}']")
.map(->
@value
).get()
data = {}
data[abilityName] = {}
data[abilityName].label_ids = selected
if not selected.length
data[abilityName].label_ids = ['']
$loading.fadeIn()
$.ajax(
type: 'PUT'
url: issueURL
data: data
).done (data) ->
$loading.fadeOut()
$selectbox.hide()
if not data.labels.length
template = labelNoneHTMLTemplate()
else
template = labelHTMLTemplate(data)
href = $value
.show()
.html(template)
>>>>>>> Add multi select stay open functionality
$dropdown.glDropdown( $dropdown.glDropdown(
data: (term, callback) -> data: (term, callback) ->
$.ajax( $.ajax(
Loading
@@ -190,31 +236,8 @@ class @LabelsSelect
Loading
@@ -190,31 +236,8 @@ class @LabelsSelect
else if $dropdown.hasClass 'js-filter-submit' else if $dropdown.hasClass 'js-filter-submit'
$dropdown.closest('form').submit() $dropdown.closest('form').submit()
else else
selected = $dropdown if $dropdown.hasClass 'js-multiselect'
.closest('.selectbox') return
.find("input[name='#{$dropdown.data('field-name')}']")
.map(->
@value
).get()
console.log 'selected', selected
data = {}
data[abilityName] = {}
data[abilityName].label_ids = selected
if not selected.length
data[abilityName].label_ids = ['']
$loading.fadeIn()
$.ajax(
type: 'PUT'
url: issueURL
data: data
).done (data) ->
$loading.fadeOut()
$selectbox.hide()
if not data.labels.length
template = labelNoneHTMLTemplate()
else else
template = labelHTMLTemplate(data) saveLabelData()
href = $value
.show()
.html(template)
) )
Loading
@@ -90,7 +90,6 @@ class @UsersSelect
Loading
@@ -90,7 +90,6 @@ class @UsersSelect
data = {} data = {}
data[abilityName] = {} data[abilityName] = {}
data[abilityName].assignee_id = selected data[abilityName].assignee_id = selected
console.log 'data',data
$loading $loading
.fadeIn() .fadeIn()
$.ajax( $.ajax(
Loading
Loading
Loading
@@ -60,7 +60,7 @@ module DropdownsHelper
Loading
@@ -60,7 +60,7 @@ module DropdownsHelper
title_output << content_tag(:span, title) title_output << content_tag(:span, title)
   
title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: { label: "Close" }, type: "button") do title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: { label: "Close" }, type: "button") do
icon('times') icon('times', class: 'dropdown-menu-close-icon')
end end
   
title_output.html_safe title_output.html_safe
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment