From 5ce97df3f4bb186e115722dec61610b00183bef7 Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 9 Oct 2005 17:51:31 +0000 Subject: [PATCH] Quite a few changes in this revision: 1. The contexts and projects lists are now drag and droppable. In other words, if you visit [tracks_url]/projects or [tracks_url]/contexts, you can grab the 'DRAG' handle with the mouse and drag and drop the projects or contexts into your preferred order. At the same time, this re-orders the 'position' column appropriately, so that changes in order will be reflected on other pages. '''NB''': At the moment, deleting projects and contexts is a bit buggy. The item doesn't disappear, but if you refresh the page it will update appropriately. Also, if you add a new item, you can't drag it until you refresh. I'll try to fix these things. Fixes #115. 2. Fixed typo of 'tomorrow' due date label. Fixes #131 3. I updated the syntax for some of the visual effects to use the new {{{visual_effect(:fade, 'element')}}} syntax. Also removed the javascript files effects2 and prototype-ex, which aren't used now. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@148 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/context_controller.rb | 35 +- tracks/app/controllers/project_controller.rb | 36 +- tracks/app/helpers/application_helper.rb | 2 +- tracks/app/helpers/todo_helper.rb | 10 +- .../app/views/context/_context_listing.rhtml | 28 +- tracks/app/views/context/_show_items.rhtml | 8 +- tracks/app/views/context/list.rhtml | 6 + tracks/app/views/layouts/standard.rhtml | 5 +- tracks/app/views/note/_notes.rhtml | 2 +- .../app/views/project/_project_listing.rhtml | 28 +- tracks/app/views/project/_show_items.rhtml | 8 +- tracks/app/views/project/list.rhtml | 6 + tracks/config/routes.rb | 2 + tracks/public/javascripts/effects2.js | 349 ------------------ tracks/public/javascripts/prototype-ex.js | 55 --- tracks/public/stylesheets/standard.css | 17 +- 16 files changed, 78 insertions(+), 519 deletions(-) delete mode 100644 tracks/public/javascripts/effects2.js delete mode 100644 tracks/public/javascripts/prototype-ex.js diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index 7e1abd2d..8956919e 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -72,36 +72,15 @@ class ContextController < ApplicationController end end - # Methods for changing the sort order of the contexts in the list + # Methods for changing the sort order of the projects in the list # - def move_up - check_user_set_context - @context.move_higher - @context.save - redirect_to(:controller => "context", :action => "list") + def order + @params["list-contexts"].each_with_index do |id, position| + Context.update(id, :position => position + 1) + end + render_text "" end - - def move_down - check_user_set_context - @context.move_lower - @context.save - redirect_to(:controller => "context", :action => "list") - end - - def move_top - check_user_set_context - @context.move_to_top - @context.save - redirect_to(:controller => "context", :action => "list") - end - - def move_bottom - check_user_set_context - @context.move_to_bottom - @context.save - redirect_to(:controller => "context", :action => "list" ) - end - + protected def check_user_set_context diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index c04d2c97..8e5f9174 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -71,34 +71,13 @@ class ProjectController < ApplicationController # Methods for changing the sort order of the projects in the list # - def move_up - check_user_set_project - @project.move_higher - @project.save - redirect_to(:controller => "project", :action => "list") + def order + @params["list-projects"].each_with_index do |id, position| + Project.update(id, :position => position + 1) + end + render_text "" end - - def move_down - check_user_set_project - @project.move_lower - @project.save - redirect_to(:controller => "project", :action => "list") - end - - def move_top - check_user_set_project - @project.move_to_top - @project.save - redirect_to(:controller => "project", :action => "list") - end - - def move_bottom - check_user_set_project - @project.move_to_bottom - @project.save - redirect_to(:controller => "project", :action => "list" ) - end - + protected def check_user_set_project @@ -118,8 +97,7 @@ class ProjectController < ApplicationController render_text "" end end - - + def init @user = @session['user'] @projects = @user.projects diff --git a/tracks/app/helpers/application_helper.rb b/tracks/app/helpers/application_helper.rb index 2f27d0ff..018eb0b1 100644 --- a/tracks/app/helpers/application_helper.rb +++ b/tracks/app/helpers/application_helper.rb @@ -51,7 +51,7 @@ module ApplicationHelper when 0 "Due Today " when 1 - "Due Tommorrow " + "Due Tomorrow " # due 2-7 days away when 2..7 "Due in " + @days.to_s + " days " diff --git a/tracks/app/helpers/todo_helper.rb b/tracks/app/helpers/todo_helper.rb index c96e3466..0b4096b8 100644 --- a/tracks/app/helpers/todo_helper.rb +++ b/tracks/app/helpers/todo_helper.rb @@ -12,7 +12,7 @@ module TodoHelper :update => "completed", :position => "top", :loading => "Form.disable('checkbox-notdone-#{item.id}');", - :complete => "new Effect2.Fade('item-#{item.id}-container', true);" + :complete => visual_effect(:fade, "item-#{item.id}-container") ) end @@ -22,7 +22,7 @@ module TodoHelper :update => "new_actions", :position => "bottom", :loading => "Form.disable('checkbox-done-#{item.id}');", - :complete => "Element.toggle('new_actions');new Effect2.Fade('done-item-#{item.id}-container', true);" + :complete => "Element.toggle('new_actions');new Effect.Fade('done-item-#{item.id}-container');" ) end @@ -30,7 +30,7 @@ module TodoHelper form_remote_tag( :url => { :controller => 'todo', :action => 'update_action', :id => item.id }, :html => { :id => "form-action-#{item.id}", :class => "inline-form" }, :update => "item-#{item.id}-container", - :complete => "new Effect.Appear('item-#{item.id}-container');" + :complete => visual_effect(:appear, "item-#{item.id}-container") ) end @@ -40,7 +40,7 @@ module TodoHelper str << " Form.focusFirstElement('form-action-#{item.id}')" link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"), :update => "item-#{item.id}-container", - :loading => "new Effect2.Fade('item-#{item.id}-container', true)", + :loading => visual_effect(:fade, "item-#{item.id}-container"), :url => { :controller => "todo", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action, \'#{item.description}\'?") + " " + link_to_function(image_tag( "blank", :title => "Edit action", :class => "edit_item"), @@ -50,7 +50,7 @@ module TodoHelper def link_to_remote_todo_done( item ) link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"), :update => "done-item-#{item.id}-container", - :loading => "new Effect2.Fade('done-item-#{item.id}-container', true)", + :loading => visual_effect(:fade, "done-item-#{item.id}-container"), :url => { :controller => "todo", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + "" + image_tag("blank") + " " diff --git a/tracks/app/views/context/_context_listing.rhtml b/tracks/app/views/context/_context_listing.rhtml index 82863e6c..2ddcbeab 100644 --- a/tracks/app/views/context/_context_listing.rhtml +++ b/tracks/app/views/context/_context_listing.rhtml @@ -1,21 +1,10 @@ <% context = context_listing %> -
+
-
-<% if context.position % 2 == 0 %> +
-<% else %> -
-<% end %>
- <%= link_to(image_tag("blank", :title=>"Move to top", :border=>"0", :width=>"16", :height=>"16"), - {:action => "move_top", :id => context.id}, :title => "Move to top", :class=>"to_top") %> - <%= link_to(image_tag("blank", :title=>"Move up", :border=>"0", :width=>"16", :height=>"16"), - {:action => "move_up", :id => context.id}, :title => "Move up", :class=>"up" ) %> - <%= link_to(image_tag("blank", :title=>"Move down", :border=>"0", :width=>"16", :height=>"16"), - {:action => "move_down", :id => context.id}, :title => "Move down", :class=>"down") %> - <%= link_to(image_tag("blank", :title=>"Move to bottom", :border=>"0", :width=>"16", :height=>"16"), - {:action => "move_bottom", :id => context.id}, :title => "Move to bottom", :class=>"to_bottom") %> + DRAG
<%= link_to( sanitize("#{context.name}"), :action => "show", :name => urlize(context.name) ) %> @@ -30,9 +19,10 @@ <% end %> <%= link_to_remote( image_tag("blank", :title =>"Delete context", :class=>"delete_item"), - :update => "context-#{context.id}-container", - :loading => "new Effect2.Fade('context-#{context.id}-container', true)", - :url => { :controller => "context", :action => "destroy", :id => context.id }, :confirm => "Are you sure that you want to delete the context \'#{context.name}\'?" ) + " " + + :update => "container_#{context.id}", + :loading => visual_effect(:fade, 'container_#{context.id}'), + :url => { :controller => "context", :action => "destroy", :id => context.id }, + :confirm => "Are you sure that you want to delete the context \'#{context.name}\'?" ) + " " + link_to_function( image_tag( "blank", :title => "Edit context", :class=>"edit_item"), "Element.toggle('context-#{context.id}','context-#{context.id}-edit-form'); new Effect.Appear('context-#{context.id}-edit-form'); Form.focus_first('form-context-#{context.id}');" ) %>
@@ -41,8 +31,8 @@