2014-10-20 16:48:07 -04:00
|
|
|
class @Milestone
|
2014-06-04 11:51:01 -04:00
|
|
|
@updateIssue: (li, issue_url, data) ->
|
|
|
|
$.ajax
|
|
|
|
type: "PUT"
|
|
|
|
url: issue_url
|
|
|
|
data: data
|
|
|
|
success: (data) ->
|
|
|
|
if data.saved == true
|
2014-06-16 05:17:34 -04:00
|
|
|
if data.assignee_avatar_url
|
|
|
|
img_tag = $('<img/>')
|
|
|
|
img_tag.attr('src', data.assignee_avatar_url)
|
|
|
|
img_tag.addClass('avatar s16')
|
|
|
|
$(li).find('.assignee-icon').html(img_tag)
|
|
|
|
else
|
|
|
|
$(li).find('.assignee-icon').html('')
|
2014-06-04 11:51:01 -04:00
|
|
|
$(li).effect 'highlight'
|
|
|
|
else
|
|
|
|
new Flash("Issue update failed", 'alert')
|
|
|
|
dataType: "json"
|
|
|
|
|
2014-06-11 07:09:45 -04:00
|
|
|
@sortIssues: (data) ->
|
|
|
|
sort_issues_url = location.href + "/sort_issues"
|
|
|
|
|
|
|
|
$.ajax
|
|
|
|
type: "PUT"
|
|
|
|
url: sort_issues_url
|
|
|
|
data: data
|
|
|
|
success: (data) ->
|
|
|
|
if data.saved != true
|
|
|
|
new Flash("Issues update failed", 'alert')
|
|
|
|
dataType: "json"
|
|
|
|
|
2014-06-11 10:11:52 -04:00
|
|
|
@sortMergeRequests: (data) ->
|
|
|
|
sort_mr_url = location.href + "/sort_merge_requests"
|
|
|
|
|
|
|
|
$.ajax
|
|
|
|
type: "PUT"
|
|
|
|
url: sort_mr_url
|
|
|
|
data: data
|
|
|
|
success: (data) ->
|
|
|
|
if data.saved != true
|
|
|
|
new Flash("MR update failed", 'alert')
|
|
|
|
dataType: "json"
|
|
|
|
|
2014-06-05 06:01:49 -04:00
|
|
|
@updateMergeRequest: (li, merge_request_url, data) ->
|
|
|
|
$.ajax
|
|
|
|
type: "PUT"
|
|
|
|
url: merge_request_url
|
|
|
|
data: data
|
|
|
|
success: (data) ->
|
|
|
|
if data.saved == true
|
2015-03-06 08:03:41 -05:00
|
|
|
if data.assignee_avatar_url
|
|
|
|
img_tag = $('<img/>')
|
|
|
|
img_tag.attr('src', data.assignee_avatar_url)
|
|
|
|
img_tag.addClass('avatar s16')
|
|
|
|
$(li).find('.assignee-icon').html(img_tag)
|
|
|
|
else
|
|
|
|
$(li).find('.assignee-icon').html('')
|
2014-06-05 06:01:49 -04:00
|
|
|
$(li).effect 'highlight'
|
|
|
|
else
|
|
|
|
new Flash("Issue update failed", 'alert')
|
|
|
|
dataType: "json"
|
|
|
|
|
2014-06-04 11:51:01 -04:00
|
|
|
constructor: ->
|
2014-06-05 06:01:49 -04:00
|
|
|
@bindIssuesSorting()
|
|
|
|
@bindMergeRequestSorting()
|
2014-06-04 11:51:01 -04:00
|
|
|
|
2014-06-05 06:01:49 -04:00
|
|
|
bindIssuesSorting: ->
|
2014-06-05 02:29:24 -04:00
|
|
|
$("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed").sortable(
|
2014-06-04 11:51:01 -04:00
|
|
|
connectWith: ".issues-sortable-list",
|
|
|
|
dropOnEmpty: true,
|
2014-06-13 08:18:23 -04:00
|
|
|
items: "li:not(.ui-sort-disabled)",
|
2014-06-11 07:09:45 -04:00
|
|
|
update: (event, ui) ->
|
|
|
|
data = $(this).sortable("serialize")
|
|
|
|
Milestone.sortIssues(data)
|
|
|
|
|
2014-06-04 11:51:01 -04:00
|
|
|
receive: (event, ui) ->
|
|
|
|
new_state = $(this).data('state')
|
|
|
|
issue_id = ui.item.data('iid')
|
|
|
|
issue_url = ui.item.data('url')
|
|
|
|
|
|
|
|
data = switch new_state
|
|
|
|
when 'ongoing'
|
|
|
|
"issue[assignee_id]=" + gon.current_user_id
|
|
|
|
when 'unassigned'
|
|
|
|
"issue[assignee_id]="
|
|
|
|
when 'closed'
|
|
|
|
"issue[state_event]=close"
|
2014-06-05 02:29:24 -04:00
|
|
|
|
|
|
|
if $(ui.sender).data('state') == "closed"
|
|
|
|
data += "&issue[state_event]=reopen"
|
2014-06-04 11:51:01 -04:00
|
|
|
|
|
|
|
Milestone.updateIssue(ui.item, issue_url, data)
|
|
|
|
|
|
|
|
).disableSelection()
|
|
|
|
|
2014-06-05 06:01:49 -04:00
|
|
|
bindMergeRequestSorting: ->
|
|
|
|
$("#merge_requests-list-unassigned, #merge_requests-list-ongoing, #merge_requests-list-closed").sortable(
|
|
|
|
connectWith: ".merge_requests-sortable-list",
|
|
|
|
dropOnEmpty: true,
|
2014-06-13 08:18:23 -04:00
|
|
|
items: "li:not(.ui-sort-disabled)",
|
2014-06-11 10:11:52 -04:00
|
|
|
update: (event, ui) ->
|
|
|
|
data = $(this).sortable("serialize")
|
|
|
|
Milestone.sortMergeRequests(data)
|
|
|
|
|
2014-06-05 06:01:49 -04:00
|
|
|
receive: (event, ui) ->
|
|
|
|
new_state = $(this).data('state')
|
|
|
|
merge_request_id = ui.item.data('iid')
|
|
|
|
merge_request_url = ui.item.data('url')
|
|
|
|
|
|
|
|
data = switch new_state
|
|
|
|
when 'ongoing'
|
|
|
|
"merge_request[assignee_id]=" + gon.current_user_id
|
|
|
|
when 'unassigned'
|
|
|
|
"merge_request[assignee_id]="
|
|
|
|
when 'closed'
|
|
|
|
"merge_request[state_event]=close"
|
|
|
|
|
|
|
|
if $(ui.sender).data('state') == "closed"
|
|
|
|
data += "&merge_request[state_event]=reopen"
|
|
|
|
|
|
|
|
Milestone.updateMergeRequest(ui.item, merge_request_url, data)
|
|
|
|
|
|
|
|
).disableSelection()
|