diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-11 16:14:44 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-06-11 16:14:44 +0400 |
commit | ed610043a8d7e60f0bd796005a8d7cdb10565206 (patch) | |
tree | 1bd94aac150d442badd7d543a02ca20ecd704cf3 /app | |
parent | 5117bf6f5348bc754a97ca52b710eacb9f8a7b75 (diff) | |
parent | dd86ce3f062ed84d90aa51ab5aee4cfcce24cda5 (diff) |
Merge branch 'milestone-issue-position' into 'master'
Milestone issues sorting
Now issues save sort position inside milestone lists
Part of #1207
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/milestone.js.coffee | 16 | ||||
-rw-r--r-- | app/controllers/projects/milestones_controller.rb | 12 | ||||
-rw-r--r-- | app/views/projects/milestones/_issue.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/milestones/_issues.html.haml | 2 |
4 files changed, 29 insertions, 3 deletions
diff --git a/app/assets/javascripts/milestone.js.coffee b/app/assets/javascripts/milestone.js.coffee index 4a2c5068bab..3418832a9cc 100644 --- a/app/assets/javascripts/milestone.js.coffee +++ b/app/assets/javascripts/milestone.js.coffee @@ -11,6 +11,18 @@ class Milestone new Flash("Issue update failed", 'alert') dataType: "json" + @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" + @updateMergeRequest: (li, merge_request_url, data) -> $.ajax type: "PUT" @@ -31,6 +43,10 @@ class Milestone $("#issues-list-unassigned, #issues-list-ongoing, #issues-list-closed").sortable( connectWith: ".issues-sortable-list", dropOnEmpty: true, + update: (event, ui) -> + data = $(this).sortable("serialize") + Milestone.sortIssues(data) + receive: (event, ui) -> new_state = $(this).data('state') issue_id = ui.item.data('iid') diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index 227cc1dfba7..139470237d2 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -1,6 +1,6 @@ class Projects::MilestonesController < Projects::ApplicationController before_filter :module_enabled - before_filter :milestone, only: [:edit, :update, :destroy, :show] + before_filter :milestone, only: [:edit, :update, :destroy, :show, :sort_issues] # Allow read any milestone before_filter :authorize_read_milestone! @@ -72,6 +72,16 @@ class Projects::MilestonesController < Projects::ApplicationController end end + def sort_issues + @issues = @milestone.issues.where(id: params['sortable_issue']) + @issues.each do |issue| + issue.position = params['sortable_issue'].index(issue.id.to_s) + 1 + issue.save + end + + render json: { saved: true } + end + protected def milestone diff --git a/app/views/projects/milestones/_issue.html.haml b/app/views/projects/milestones/_issue.html.haml index fe93164a704..7c993e01c23 100644 --- a/app/views/projects/milestones/_issue.html.haml +++ b/app/views/projects/milestones/_issue.html.haml @@ -1,4 +1,4 @@ -%li{ class: 'issue-row', 'data-iid' => issue.iid, 'data-url' => project_issue_path(@project, issue) } +%li{ id: dom_id(issue, 'sortable'), class: 'issue-row', 'data-iid' => issue.iid, 'data-url' => project_issue_path(@project, issue) } %span.str-truncated = link_to [@project, issue] do %span.cgray ##{issue.iid} diff --git a/app/views/projects/milestones/_issues.html.haml b/app/views/projects/milestones/_issues.html.haml index 9dbcab19a2a..95a4a9296cb 100644 --- a/app/views/projects/milestones/_issues.html.haml +++ b/app/views/projects/milestones/_issues.html.haml @@ -1,6 +1,6 @@ .panel.panel-default .panel-heading= title %ul{ class: "well-list issues-sortable-list", id: "issues-list-#{id}", "data-state" => id } - - issues.each do |issue| + - issues.sort_by(&:position).each do |issue| = render 'issue', issue: issue %li.light Drag and drop available |