Commit dd833d28ad91498070b4c72243c57022f4513544
1 parent
4e063dea
Exists in
master
and in
4 other branches
Sortable issues
Showing
16 changed files
with
59 additions
and
16 deletions
Show diff stats
Gemfile
Gemfile.lock
... | ... | @@ -61,6 +61,7 @@ GEM |
61 | 61 | activesupport (= 3.1.0) |
62 | 62 | activesupport (3.1.0) |
63 | 63 | multi_json (~> 1.0) |
64 | + acts_as_list (0.1.4) | |
64 | 65 | addressable (2.2.6) |
65 | 66 | ansi (1.3.0) |
66 | 67 | archive-tar-minitar (0.5.2) |
... | ... | @@ -240,6 +241,7 @@ PLATFORMS |
240 | 241 | ruby |
241 | 242 | |
242 | 243 | DEPENDENCIES |
244 | + acts_as_list | |
243 | 245 | albino! |
244 | 246 | annotate! |
245 | 247 | autotest | ... | ... |
app/assets/javascripts/dashboard.js.coffee
app/assets/javascripts/issues.js.coffee
app/assets/javascripts/profile.js.coffee
app/assets/javascripts/projects.js
app/assets/stylesheets/projects.css.scss
app/controllers/issues_controller.rb
... | ... | @@ -69,4 +69,14 @@ class IssuesController < ApplicationController |
69 | 69 | format.js { render :nothing => true } |
70 | 70 | end |
71 | 71 | end |
72 | + | |
73 | + def sort | |
74 | + @issues = @project.issues.all | |
75 | + @issues.each do |issue| | |
76 | + issue.position = params['issue'].index(issue.id.to_s) + 1 | |
77 | + issue.save | |
78 | + end | |
79 | + | |
80 | + render :nothing => true | |
81 | + end | |
72 | 82 | end | ... | ... |
app/models/issue.rb
app/models/project.rb
... | ... | @@ -3,7 +3,7 @@ require "grit" |
3 | 3 | class Project < ActiveRecord::Base |
4 | 4 | belongs_to :owner, :class_name => "User" |
5 | 5 | |
6 | - has_many :issues, :dependent => :destroy | |
6 | + has_many :issues, :dependent => :destroy, :order => "position" | |
7 | 7 | has_many :users_projects, :dependent => :destroy |
8 | 8 | has_many :users, :through => :users_projects |
9 | 9 | has_many :notes, :dependent => :destroy | ... | ... |
app/views/issues/_show.html.haml
1 | 1 | %tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) } |
2 | 2 | %td |
3 | - = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" | |
3 | + = image_tag gravatar_icon(issue.assignee.email), :class => ["left", "handle"], :width => 40, :style => "padding:0 5px;" | |
4 | 4 | = truncate issue.assignee.name, :lenght => 20 |
5 | 5 | %td ##{issue.id} |
6 | 6 | %td= html_escape issue.title | ... | ... |
app/views/issues/index.html.haml
... | ... | @@ -22,3 +22,29 @@ |
22 | 22 | :javascript |
23 | 23 | $('.delete-issue').live('ajax:success', function() { |
24 | 24 | $(this).closest('tr').fadeOut(); }); |
25 | + | |
26 | + function setSortable(){ | |
27 | + $('#issues-table>tbody').sortable({ | |
28 | + axis: 'y', | |
29 | + dropOnEmpty: false, | |
30 | + handle: '.handle', | |
31 | + cursor: 'crosshair', | |
32 | + items: 'tr', | |
33 | + opacity: 0.4, | |
34 | + scroll: true, | |
35 | + update: function(){ | |
36 | + $.ajax({ | |
37 | + type: 'post', | |
38 | + data: $('#issues-table>tbody').sortable('serialize'), | |
39 | + dataType: 'script', | |
40 | + complete: function(request){ | |
41 | + $('#issues-table>tbody').effect('highlight'); | |
42 | + }, | |
43 | + url: "#{sort_project_issues_path(@project)}"}) | |
44 | + } | |
45 | + }); | |
46 | + } | |
47 | + | |
48 | + $(function(){ | |
49 | + setSortable(); | |
50 | + }); | ... | ... |
app/views/issues/index.js.haml
config/initializers/rails_footnotes.rb
config/routes.rb
... | ... | @@ -40,7 +40,11 @@ Gitlab::Application.routes.draw do |
40 | 40 | end |
41 | 41 | resources :commits |
42 | 42 | resources :team_members |
43 | - resources :issues | |
43 | + resources :issues do | |
44 | + collection do | |
45 | + post :sort | |
46 | + end | |
47 | + end | |
44 | 48 | resources :notes, :only => [:create, :destroy] |
45 | 49 | end |
46 | 50 | root :to => "projects#index" | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(:version => 20111009111204) do | |
14 | +ActiveRecord::Schema.define(:version => 20111015154310) do | |
15 | 15 | |
16 | 16 | create_table "issues", :force => true do |t| |
17 | 17 | t.string "title" |
... | ... | @@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20111009111204) do |
22 | 22 | t.datetime "created_at" |
23 | 23 | t.datetime "updated_at" |
24 | 24 | t.boolean "closed", :default => false, :null => false |
25 | + t.integer "position", :default => 0 | |
25 | 26 | end |
26 | 27 | |
27 | 28 | create_table "keys", :force => true do |t| | ... | ... |