2013-04-07 06:19:36 -04:00
|
|
|
@Issues =
|
|
|
|
init: ->
|
|
|
|
Issues.initSearch()
|
|
|
|
Issues.initSelects()
|
2013-04-09 04:17:24 -04:00
|
|
|
Issues.initChecks()
|
2013-04-07 06:19:36 -04:00
|
|
|
|
|
|
|
$("body").on "ajax:success", ".close_issue, .reopen_issue", ->
|
|
|
|
t = $(this)
|
|
|
|
totalIssues = undefined
|
|
|
|
reopen = t.hasClass("reopen_issue")
|
|
|
|
$(".issue_counter").each ->
|
|
|
|
issue = $(this)
|
|
|
|
totalIssues = parseInt($(this).html(), 10)
|
|
|
|
if reopen and issue.closest(".main_menu").length
|
|
|
|
$(this).html totalIssues + 1
|
|
|
|
else
|
|
|
|
$(this).html totalIssues - 1
|
2015-02-19 18:47:10 -05:00
|
|
|
$("body").on "click", ".issues-other-filters .dropdown-menu a", ->
|
2013-05-08 06:43:21 -04:00
|
|
|
$('.issues-list').block(
|
|
|
|
message: null,
|
|
|
|
overlayCSS:
|
|
|
|
backgroundColor: '#DDD'
|
|
|
|
opacity: .4
|
|
|
|
)
|
2013-11-29 08:05:32 -05:00
|
|
|
|
2013-04-07 06:19:36 -04:00
|
|
|
reload: ->
|
|
|
|
Issues.initSelects()
|
|
|
|
Issues.initChecks()
|
|
|
|
$('#filter_issue_search').val($('#issue_search').val())
|
|
|
|
|
|
|
|
initSelects: ->
|
2014-01-14 14:07:59 -05:00
|
|
|
$("select#update_status").select2(width: 'resolve', dropdownAutoWidth: true)
|
|
|
|
$("select#update_assignee_id").select2(width: 'resolve', dropdownAutoWidth: true)
|
|
|
|
$("select#update_milestone_id").select2(width: 'resolve', dropdownAutoWidth: true)
|
|
|
|
$("select#label_name").select2(width: 'resolve', dropdownAutoWidth: true)
|
2013-04-07 06:19:36 -04:00
|
|
|
$("#milestone_id, #assignee_id, #label_name").on "change", ->
|
|
|
|
$(this).closest("form").submit()
|
|
|
|
|
|
|
|
initChecks: ->
|
|
|
|
$(".check_all_issues").click ->
|
2014-06-12 14:39:08 -04:00
|
|
|
$(".selected_issue").prop("checked", @checked)
|
2013-04-07 06:19:36 -04:00
|
|
|
Issues.checkChanged()
|
|
|
|
|
|
|
|
$(".selected_issue").bind "change", Issues.checkChanged
|
|
|
|
|
2014-09-03 12:18:23 -04:00
|
|
|
# Make sure we trigger ajax request only after user stop typing
|
2013-04-07 06:19:36 -04:00
|
|
|
initSearch: ->
|
2014-09-03 12:18:23 -04:00
|
|
|
@timer = null
|
2013-04-07 06:19:36 -04:00
|
|
|
$("#issue_search").keyup ->
|
2015-03-12 19:20:58 -04:00
|
|
|
clearTimeout(@timer)
|
2014-09-03 12:18:23 -04:00
|
|
|
@timer = setTimeout(Issues.filterResults, 500)
|
|
|
|
|
|
|
|
filterResults: =>
|
|
|
|
form = $("#issue_search_form")
|
|
|
|
search = $("#issue_search").val()
|
|
|
|
$('.issues-holder').css("opacity", '0.5')
|
|
|
|
issues_url = form.attr('action') + '? '+ form.serialize()
|
|
|
|
|
|
|
|
$.ajax
|
|
|
|
type: "GET"
|
|
|
|
url: form.attr('action')
|
|
|
|
data: form.serialize()
|
|
|
|
complete: ->
|
|
|
|
$('.issues-holder').css("opacity", '1.0')
|
|
|
|
success: (data) ->
|
|
|
|
$('.issues-holder').html(data.html)
|
|
|
|
# Change url so if user reload a page - search results are saved
|
|
|
|
History.replaceState {page: issues_url}, document.title, issues_url
|
|
|
|
Issues.reload()
|
|
|
|
dataType: "json"
|
2013-04-07 06:19:36 -04:00
|
|
|
|
|
|
|
checkChanged: ->
|
|
|
|
checked_issues = $(".selected_issue:checked")
|
|
|
|
if checked_issues.length > 0
|
|
|
|
ids = []
|
|
|
|
$.each checked_issues, (index, value) ->
|
|
|
|
ids.push $(value).attr("data-id")
|
|
|
|
|
|
|
|
$("#update_issues_ids").val ids
|
2015-02-19 18:47:10 -05:00
|
|
|
$(".issues-other-filters").hide()
|
2013-04-07 06:19:36 -04:00
|
|
|
$(".issues_bulk_update").show()
|
|
|
|
else
|
|
|
|
$("#update_issues_ids").val []
|
|
|
|
$(".issues_bulk_update").hide()
|
2015-02-19 18:47:10 -05:00
|
|
|
$(".issues-other-filters").show()
|