Commit ed610043 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'milestone-issue-position' into 'master'

Milestone issues sorting

Now issues save sort position inside milestone lists

Part of #1207
parents 5117bf6f dd86ce3f
......@@ -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')
......
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
......
%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}
......
.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
......@@ -278,7 +278,11 @@ Gitlab::Application.routes.draw do
end
resources :team, controller: 'team_members', only: [:index]
resources :milestones, except: [:destroy], constraints: {id: /\d+/}
resources :milestones, except: [:destroy], constraints: {id: /\d+/} do
member do
put :sort_issues
end
end
resources :labels, only: [:index] do
collection do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment