Add js milestone class. Activate drag-drop for issues on milestone page

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-06-04 18:51:01 +03:00
parent ad60701e9e
commit 47937802a2
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
2 changed files with 42 additions and 0 deletions

View file

@ -21,6 +21,8 @@ class Dispatcher
Issues.init()
when 'projects:issues:show'
new Issue()
when 'projects:milestones:show'
new Milestone()
when 'projects:issues:new', 'projects:merge_requests:new'
GitLab.GfmAutoComplete.setup()
when 'dashboard:show'

View file

@ -0,0 +1,40 @@
class Milestone
@updateIssue: (li, issue_url, data) ->
$.ajax
type: "PUT"
url: issue_url
data: data
success: (data) ->
if data.saved == true
$(li).effect 'highlight'
else
new Flash("Issue update failed", 'alert')
dataType: "json"
constructor: ->
@bindSorting()
bindSorting: ->
$("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed, #issues-list-reopened").sortable(
connectWith: ".issues-sortable-list",
dropOnEmpty: true,
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"
when 'reopened'
"issue[state_event]=reopen"
Milestone.updateIssue(ui.item, issue_url, data)
).disableSelection()
@Milestone = Milestone