Sortable issues
This commit is contained in:
parent
4e063deaa9
commit
dd833d28ad
16 changed files with 59 additions and 16 deletions
|
@ -1,3 +0,0 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -1,3 +0,0 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -1,3 +0,0 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -34,6 +34,7 @@ $(document).ready(function(){
|
|||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function focusSearch() {
|
||||
|
|
|
@ -539,3 +539,7 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
|
|||
float:left;
|
||||
}
|
||||
}
|
||||
|
||||
.handle:hover{
|
||||
cursor: move;
|
||||
}
|
||||
|
|
|
@ -69,4 +69,14 @@ class IssuesController < ApplicationController
|
|||
format.js { render :nothing => true }
|
||||
end
|
||||
end
|
||||
|
||||
def sort
|
||||
@issues = @project.issues.all
|
||||
@issues.each do |issue|
|
||||
issue.position = params['issue'].index(issue.id.to_s) + 1
|
||||
issue.save
|
||||
end
|
||||
|
||||
render :nothing => true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,8 @@ class Issue < ActiveRecord::Base
|
|||
scope :opened, where(:closed => false)
|
||||
scope :closed, where(:closed => true)
|
||||
scope :assigned, lambda { |u| where(:assignee_id => u.id)}
|
||||
|
||||
acts_as_list
|
||||
end
|
||||
# == Schema Information
|
||||
#
|
||||
|
|
|
@ -3,7 +3,7 @@ require "grit"
|
|||
class Project < ActiveRecord::Base
|
||||
belongs_to :owner, :class_name => "User"
|
||||
|
||||
has_many :issues, :dependent => :destroy
|
||||
has_many :issues, :dependent => :destroy, :order => "position"
|
||||
has_many :users_projects, :dependent => :destroy
|
||||
has_many :users, :through => :users_projects
|
||||
has_many :notes, :dependent => :destroy
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) }
|
||||
%td
|
||||
= image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;"
|
||||
= image_tag gravatar_icon(issue.assignee.email), :class => ["left", "handle"], :width => 40, :style => "padding:0 5px;"
|
||||
= truncate issue.assignee.name, :lenght => 20
|
||||
%td ##{issue.id}
|
||||
%td= html_escape issue.title
|
||||
|
|
|
@ -22,3 +22,29 @@
|
|||
:javascript
|
||||
$('.delete-issue').live('ajax:success', function() {
|
||||
$(this).closest('tr').fadeOut(); });
|
||||
|
||||
function setSortable(){
|
||||
$('#issues-table>tbody').sortable({
|
||||
axis: 'y',
|
||||
dropOnEmpty: false,
|
||||
handle: '.handle',
|
||||
cursor: 'crosshair',
|
||||
items: 'tr',
|
||||
opacity: 0.4,
|
||||
scroll: true,
|
||||
update: function(){
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
data: $('#issues-table>tbody').sortable('serialize'),
|
||||
dataType: 'script',
|
||||
complete: function(request){
|
||||
$('#issues-table>tbody').effect('highlight');
|
||||
},
|
||||
url: "#{sort_project_issues_path(@project)}"})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function(){
|
||||
setSortable();
|
||||
});
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
:plain
|
||||
$('#issues-table-holder').html("#{escape_javascript(render('issues'))}");
|
||||
setSortable();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue