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
@@ -19,6 +19,7 @@ gem "albino", :git => "git://github.com/gitlabhq/albino.git" | @@ -19,6 +19,7 @@ gem "albino", :git => "git://github.com/gitlabhq/albino.git" | ||
19 | gem "kaminari" | 19 | gem "kaminari" |
20 | gem "thin" | 20 | gem "thin" |
21 | gem "git" | 21 | gem "git" |
22 | +gem "acts_as_list" | ||
22 | 23 | ||
23 | group :assets do | 24 | group :assets do |
24 | gem 'sass-rails', " ~> 3.1.0" | 25 | gem 'sass-rails', " ~> 3.1.0" |
Gemfile.lock
@@ -61,6 +61,7 @@ GEM | @@ -61,6 +61,7 @@ GEM | ||
61 | activesupport (= 3.1.0) | 61 | activesupport (= 3.1.0) |
62 | activesupport (3.1.0) | 62 | activesupport (3.1.0) |
63 | multi_json (~> 1.0) | 63 | multi_json (~> 1.0) |
64 | + acts_as_list (0.1.4) | ||
64 | addressable (2.2.6) | 65 | addressable (2.2.6) |
65 | ansi (1.3.0) | 66 | ansi (1.3.0) |
66 | archive-tar-minitar (0.5.2) | 67 | archive-tar-minitar (0.5.2) |
@@ -240,6 +241,7 @@ PLATFORMS | @@ -240,6 +241,7 @@ PLATFORMS | ||
240 | ruby | 241 | ruby |
241 | 242 | ||
242 | DEPENDENCIES | 243 | DEPENDENCIES |
244 | + acts_as_list | ||
243 | albino! | 245 | albino! |
244 | annotate! | 246 | annotate! |
245 | autotest | 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,4 +69,14 @@ class IssuesController < ApplicationController | ||
69 | format.js { render :nothing => true } | 69 | format.js { render :nothing => true } |
70 | end | 70 | end |
71 | end | 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 | end | 82 | end |
app/models/issue.rb
@@ -21,6 +21,8 @@ class Issue < ActiveRecord::Base | @@ -21,6 +21,8 @@ class Issue < ActiveRecord::Base | ||
21 | scope :opened, where(:closed => false) | 21 | scope :opened, where(:closed => false) |
22 | scope :closed, where(:closed => true) | 22 | scope :closed, where(:closed => true) |
23 | scope :assigned, lambda { |u| where(:assignee_id => u.id)} | 23 | scope :assigned, lambda { |u| where(:assignee_id => u.id)} |
24 | + | ||
25 | + acts_as_list | ||
24 | end | 26 | end |
25 | # == Schema Information | 27 | # == Schema Information |
26 | # | 28 | # |
app/models/project.rb
@@ -3,7 +3,7 @@ require "grit" | @@ -3,7 +3,7 @@ require "grit" | ||
3 | class Project < ActiveRecord::Base | 3 | class Project < ActiveRecord::Base |
4 | belongs_to :owner, :class_name => "User" | 4 | belongs_to :owner, :class_name => "User" |
5 | 5 | ||
6 | - has_many :issues, :dependent => :destroy | 6 | + has_many :issues, :dependent => :destroy, :order => "position" |
7 | has_many :users_projects, :dependent => :destroy | 7 | has_many :users_projects, :dependent => :destroy |
8 | has_many :users, :through => :users_projects | 8 | has_many :users, :through => :users_projects |
9 | has_many :notes, :dependent => :destroy | 9 | has_many :notes, :dependent => :destroy |
app/views/issues/_show.html.haml
1 | %tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) } | 1 | %tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) } |
2 | %td | 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 | = truncate issue.assignee.name, :lenght => 20 | 4 | = truncate issue.assignee.name, :lenght => 20 |
5 | %td ##{issue.id} | 5 | %td ##{issue.id} |
6 | %td= html_escape issue.title | 6 | %td= html_escape issue.title |
app/views/issues/index.html.haml
@@ -22,3 +22,29 @@ | @@ -22,3 +22,29 @@ | ||
22 | :javascript | 22 | :javascript |
23 | $('.delete-issue').live('ajax:success', function() { | 23 | $('.delete-issue').live('ajax:success', function() { |
24 | $(this).closest('tr').fadeOut(); }); | 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,7 +40,11 @@ Gitlab::Application.routes.draw do | ||
40 | end | 40 | end |
41 | resources :commits | 41 | resources :commits |
42 | resources :team_members | 42 | resources :team_members |
43 | - resources :issues | 43 | + resources :issues do |
44 | + collection do | ||
45 | + post :sort | ||
46 | + end | ||
47 | + end | ||
44 | resources :notes, :only => [:create, :destroy] | 48 | resources :notes, :only => [:create, :destroy] |
45 | end | 49 | end |
46 | root :to => "projects#index" | 50 | root :to => "projects#index" |
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 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 | create_table "issues", :force => true do |t| | 16 | create_table "issues", :force => true do |t| |
17 | t.string "title" | 17 | t.string "title" |
@@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20111009111204) do | @@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20111009111204) do | ||
22 | t.datetime "created_at" | 22 | t.datetime "created_at" |
23 | t.datetime "updated_at" | 23 | t.datetime "updated_at" |
24 | t.boolean "closed", :default => false, :null => false | 24 | t.boolean "closed", :default => false, :null => false |
25 | + t.integer "position", :default => 0 | ||
25 | end | 26 | end |
26 | 27 | ||
27 | create_table "keys", :force => true do |t| | 28 | create_table "keys", :force => true do |t| |