Commit 882ebfc2 authored by Phil Hughes's avatar Phil Hughes

Changing filter dropdowns shows loading

Instead of doing a full refresh of the page - i've modified the filterResults method on the Issues object to work for this form as well
parent bdbc9884
...@@ -246,11 +246,15 @@ class GitLabDropdown ...@@ -246,11 +246,15 @@ class GitLabDropdown
if oldValue if oldValue
value = "#{oldValue},#{value}" value = "#{oldValue},#{value}"
else else
@dropdown.find(ACTIVE_CLASS).removeClass ACTIVE_CLASS @dropdown.find(".#{ACTIVE_CLASS}").removeClass ACTIVE_CLASS
# Toggle active class for the tick mark # Toggle active class for the tick mark
el.toggleClass "is-active" el.toggleClass "is-active"
# Toggle the dropdown label
if @options.toggleLabel
$(@el).find(".dropdown-toggle-text").text @options.toggleLabel(selectedObject)
if value? if value?
if !field.length if !field.length
# Create hidden input for form # Create hidden input for form
......
...@@ -41,18 +41,20 @@ ...@@ -41,18 +41,20 @@
@timer = null @timer = null
$("#issue_search").keyup -> $("#issue_search").keyup ->
clearTimeout(@timer) clearTimeout(@timer)
@timer = setTimeout(Issues.filterResults, 500) @timer = setTimeout( ->
Issues.filterResults $("#issue_search_form")
, 500)
filterResults: => filterResults: (form) =>
form = $("#issue_search_form")
search = $("#issue_search").val()
$('.issues-holder').css("opacity", '0.5') $('.issues-holder').css("opacity", '0.5')
issues_url = form.attr('action') + '?' + form.serialize() form_action = form.attr('action')
form_data = form.serialize()
issues_url = form_action + ("#{if form_action.indexOf("?") < 0 then '?' else '&'}") + form_data
$.ajax $.ajax
type: "GET" type: "GET"
url: form.attr('action') url: form_action
data: form.serialize() data: form_data
complete: -> complete: ->
$('.issues-holder').css("opacity", '1.0') $('.issues-holder').css("opacity", '1.0')
success: (data) -> success: (data) ->
......
...@@ -10,6 +10,7 @@ class @LabelsSelect ...@@ -10,6 +10,7 @@ class @LabelsSelect
newColorField = $('#new_label_color') newColorField = $('#new_label_color')
showNo = $(dropdown).data('show-no') showNo = $(dropdown).data('show-no')
showAny = $(dropdown).data('show-any') showAny = $(dropdown).data('show-any')
defaultLabel = $(dropdown).text().trim()
if newLabelField.length if newLabelField.length
$('.suggest-colors-dropdown a').on "click", (e) -> $('.suggest-colors-dropdown a').on "click", (e) ->
...@@ -51,13 +52,13 @@ class @LabelsSelect ...@@ -51,13 +52,13 @@ class @LabelsSelect
if showNo if showNo
data.unshift( data.unshift(
id: "0" id: 0
title: 'No label' title: 'No Label'
) )
if showAny if showAny
data.unshift( data.unshift(
title: 'Any label' title: 'Any Label'
) )
if data.length > 2 if data.length > 2
...@@ -83,10 +84,18 @@ class @LabelsSelect ...@@ -83,10 +84,18 @@ class @LabelsSelect
search: search:
fields: ['title'] fields: ['title']
selectable: true selectable: true
toggleLabel: (selected) ->
if selected && selected.title isnt "Any Label"
selected.title
else
defaultLabel
fieldName: $(dropdown).data('field-name') fieldName: $(dropdown).data('field-name')
id: (label) -> id: (label) ->
if label.title is "Any Label"
""
else
label.title label.title
clicked: -> clicked: ->
if $(dropdown).hasClass "js-filter-submit" if $(dropdown).hasClass "js-filter-submit"
$(dropdown).parents('form').submit() Issues.filterResults $(dropdown).parents("form")
) )
...@@ -7,6 +7,7 @@ class @MilestoneSelect ...@@ -7,6 +7,7 @@ class @MilestoneSelect
showNo = $(dropdown).data('show-no') showNo = $(dropdown).data('show-no')
showAny = $(dropdown).data('show-any') showAny = $(dropdown).data('show-any')
useId = $(dropdown).data('use-id') useId = $(dropdown).data('use-id')
defaultLabel = $(dropdown).text().trim()
$(dropdown).glDropdown( $(dropdown).glDropdown(
data: (term, callback) -> data: (term, callback) ->
...@@ -42,6 +43,11 @@ class @MilestoneSelect ...@@ -42,6 +43,11 @@ class @MilestoneSelect
search: search:
fields: ['title'] fields: ['title']
selectable: true selectable: true
toggleLabel: (selected) ->
if selected && selected.id
selected.title
else
defaultLabel
fieldName: $(dropdown).data('field-name') fieldName: $(dropdown).data('field-name')
text: (milestone) -> text: (milestone) ->
milestone.title milestone.title
...@@ -57,5 +63,5 @@ class @MilestoneSelect ...@@ -57,5 +63,5 @@ class @MilestoneSelect
milestone.title is selectedMilestone milestone.title is selectedMilestone
clicked: -> clicked: ->
if $(dropdown).hasClass "js-filter-submit" if $(dropdown).hasClass "js-filter-submit"
$(dropdown).parents('form').submit() Issues.filterResults $(dropdown).parents("form")
) )
...@@ -10,6 +10,7 @@ class @UsersSelect ...@@ -10,6 +10,7 @@ class @UsersSelect
showAnyUser = $(dropdown).data('any-user') showAnyUser = $(dropdown).data('any-user')
firstUser = $(dropdown).data('first-user') firstUser = $(dropdown).data('first-user')
selectedId = $(dropdown).data('selected') selectedId = $(dropdown).data('selected')
defaultLabel = $(dropdown).text().trim()
$(dropdown).glDropdown( $(dropdown).glDropdown(
data: (term, callback) => data: (term, callback) =>
...@@ -53,9 +54,14 @@ class @UsersSelect ...@@ -53,9 +54,14 @@ class @UsersSelect
fields: ['name', 'username'] fields: ['name', 'username']
selectable: true selectable: true
fieldName: $(dropdown).data('field-name') fieldName: $(dropdown).data('field-name')
toggleLabel: (selected) ->
if selected && selected.id?
selected.name
else
defaultLabel
clicked: -> clicked: ->
if $(dropdown).hasClass "js-filter-submit" if $(dropdown).hasClass "js-filter-submit"
$(dropdown).parents('form').submit() Issues.filterResults $(dropdown).parents("form")
renderRow: (user) -> renderRow: (user) ->
username = if user.username then "@#{user.username}" else "" username = if user.username then "@#{user.username}" else ""
avatar = if user.avatar_url then user.avatar_url else false avatar = if user.avatar_url then user.avatar_url else false
......
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