diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-05 14:25:47 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-05 14:25:47 +0400 |
commit | 7e41eca38ae4598e083372777c20ff6aa2b491ad (patch) | |
tree | fd683b23682de4e9b0ccb74e99f173b115ad653a /app | |
parent | 9bd1afd7219d18771aef7d26415d85453629fcc0 (diff) | |
parent | 336d50d008e8efcaef89ce5656620cbe068aa064 (diff) |
Merge branch 'milestone-mr-dragging' into 'master'
Milestone merge request dragging
This is part of #1207.
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/milestone.js.coffee | 41 | ||||
-rw-r--r-- | app/views/projects/milestones/_merge_request.html.haml | 10 | ||||
-rw-r--r-- | app/views/projects/milestones/_merge_requests.html.haml | 6 | ||||
-rw-r--r-- | app/views/projects/milestones/show.html.haml | 18 |
4 files changed, 56 insertions, 19 deletions
diff --git a/app/assets/javascripts/milestone.js.coffee b/app/assets/javascripts/milestone.js.coffee index d2857948cd7..4a2c5068bab 100644 --- a/app/assets/javascripts/milestone.js.coffee +++ b/app/assets/javascripts/milestone.js.coffee @@ -11,10 +11,23 @@ class Milestone new Flash("Issue update failed", 'alert') dataType: "json" + @updateMergeRequest: (li, merge_request_url, data) -> + $.ajax + type: "PUT" + url: merge_request_url + data: data + success: (data) -> + if data.saved == true + $(li).effect 'highlight' + else + new Flash("Issue update failed", 'alert') + dataType: "json" + constructor: -> - @bindSorting() + @bindIssuesSorting() + @bindMergeRequestSorting() - bindSorting: -> + bindIssuesSorting: -> $("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed").sortable( connectWith: ".issues-sortable-list", dropOnEmpty: true, @@ -38,4 +51,28 @@ class Milestone ).disableSelection() + bindMergeRequestSorting: -> + $("#merge_requests-list-unassigned, #merge_requests-list-ongoing, #merge_requests-list-closed").sortable( + connectWith: ".merge_requests-sortable-list", + dropOnEmpty: true, + 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() + @Milestone = Milestone diff --git a/app/views/projects/milestones/_merge_request.html.haml b/app/views/projects/milestones/_merge_request.html.haml index faa35a25f2f..4787da51e6d 100644 --- a/app/views/projects/milestones/_merge_request.html.haml +++ b/app/views/projects/milestones/_merge_request.html.haml @@ -1,5 +1,5 @@ -%li - = link_to [@project, merge_request] do - %span.label.label-info ##{merge_request.iid} - – - = link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request] +%li{ class: 'mr-row', 'data-iid' => merge_request.iid, 'data-url' => project_merge_request_path(@project, merge_request) } + %span.str-truncated + = link_to [@project, merge_request] do + %span.cgray ##{merge_request.iid} + = link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request] diff --git a/app/views/projects/milestones/_merge_requests.html.haml b/app/views/projects/milestones/_merge_requests.html.haml new file mode 100644 index 00000000000..18c46601834 --- /dev/null +++ b/app/views/projects/milestones/_merge_requests.html.haml @@ -0,0 +1,6 @@ +.panel.panel-default + .panel-heading= title + %ul{ class: "well-list merge_requests-sortable-list", id: "merge_requests-list-#{id}", "data-state" => id } + - merge_requests.each do |merge_request| + = render 'merge_request', merge_request: merge_request + %li.light Drag and drop available diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index 67b45fc30ba..206bf474493 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -84,18 +84,12 @@ .tab-pane#tab-merge-requests .row - .col-md-6 - .panel.panel-default - .panel-heading Open - %ul.well-list - - @merge_requests.opened.each do |merge_request| - = render 'merge_request', merge_request: merge_request - .col-md-6 - .panel.panel-default - .panel-heading Closed - %ul.well-list - - @merge_requests.closed.each do |merge_request| - = render 'merge_request', merge_request: merge_request + .col-md-4 + = render('merge_requests', title: 'Work in progress (open and unassigned)', merge_requests: @merge_requests.opened.unassigned, id: 'unassigned') + .col-md-4 + = render('merge_requests', title: 'Assigned (open and assigned)', merge_requests: @merge_requests.opened.assigned, id: 'ongoing') + .col-md-4 + = render('merge_requests', title: 'Declined (closed)', merge_requests: @merge_requests.closed, id: 'closed') .tab-pane#tab-participants %ul.bordered-list |