Commit 47937802a2c29f6ec4a1bd15bb06e8e2866fdb7f
1 parent
ad60701e
Exists in
spb-stable
and in
2 other branches
Add js milestone class. Activate drag-drop for issues on milestone page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
42 additions
and
0 deletions
Show diff stats
app/assets/javascripts/dispatcher.js.coffee
| ... | ... | @@ -21,6 +21,8 @@ class Dispatcher |
| 21 | 21 | Issues.init() |
| 22 | 22 | when 'projects:issues:show' |
| 23 | 23 | new Issue() |
| 24 | + when 'projects:milestones:show' | |
| 25 | + new Milestone() | |
| 24 | 26 | when 'projects:issues:new', 'projects:merge_requests:new' |
| 25 | 27 | GitLab.GfmAutoComplete.setup() |
| 26 | 28 | when 'dashboard:show' | ... | ... |
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +class Milestone | |
| 2 | + @updateIssue: (li, issue_url, data) -> | |
| 3 | + $.ajax | |
| 4 | + type: "PUT" | |
| 5 | + url: issue_url | |
| 6 | + data: data | |
| 7 | + success: (data) -> | |
| 8 | + if data.saved == true | |
| 9 | + $(li).effect 'highlight' | |
| 10 | + else | |
| 11 | + new Flash("Issue update failed", 'alert') | |
| 12 | + dataType: "json" | |
| 13 | + | |
| 14 | + constructor: -> | |
| 15 | + @bindSorting() | |
| 16 | + | |
| 17 | + bindSorting: -> | |
| 18 | + $("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed, #issues-list-reopened").sortable( | |
| 19 | + connectWith: ".issues-sortable-list", | |
| 20 | + dropOnEmpty: true, | |
| 21 | + receive: (event, ui) -> | |
| 22 | + new_state = $(this).data('state') | |
| 23 | + issue_id = ui.item.data('iid') | |
| 24 | + issue_url = ui.item.data('url') | |
| 25 | + | |
| 26 | + data = switch new_state | |
| 27 | + when 'ongoing' | |
| 28 | + "issue[assignee_id]=" + gon.current_user_id | |
| 29 | + when 'unassigned' | |
| 30 | + "issue[assignee_id]=" | |
| 31 | + when 'closed' | |
| 32 | + "issue[state_event]=close" | |
| 33 | + when 'reopened' | |
| 34 | + "issue[state_event]=reopen" | |
| 35 | + | |
| 36 | + Milestone.updateIssue(ui.item, issue_url, data) | |
| 37 | + | |
| 38 | + ).disableSelection() | |
| 39 | + | |
| 40 | +@Milestone = Milestone | ... | ... |