diff --git a/tracks/app/models/todo.rb b/tracks/app/models/todo.rb index 07de183c..5d20267d 100644 --- a/tracks/app/models/todo.rb +++ b/tracks/app/models/todo.rb @@ -23,5 +23,14 @@ class Todo < ActiveRecord::Base end end - + # Piggy-back technique to avoid superfluous calls to the DB + # + def self.find_all_with_project_name(filter,sort) + find_by_sql( + "SELECT todos.*, projects.name as project_name " + + "FROM todos, projects " + + "WHERE #{filter} AND todos.project_id = projects.id " + + "ORDER BY #{sort}" + ) + end end diff --git a/tracks/app/views/project/_not_done.rhtml b/tracks/app/views/project/_not_done.rhtml index f0cdb638..e10f617c 100644 --- a/tracks/app/views/project/_not_done.rhtml +++ b/tracks/app/views/project/_not_done.rhtml @@ -1,7 +1,7 @@ <% @item = not_done %> <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %> - <%= link_image_to( "edit", { :action => "edit", :id => @item.id }, :title => "Edit item", :size => "10x10" ) + " " + link_image_to( "delete", { :controller => "todo", :action => "destroy", :id => @item.id }, :title => "Delete item", :size => "10x10", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %> + <%= link_image_to( "edit", { :controller => "todo", :action => "edit", :id => @item.id }, :title => "Edit item", :size => "10x10" ) + " " + link_image_to( "delete", { :controller => "todo", :action => "destroy", :id => @item.id }, :title => "Delete item", :size => "10x10", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %> <%= due_date( @item.due ) %> <%= @item.description %> <% if @item.project_id %> diff --git a/tracks/app/views/todo/_not_done.rhtml b/tracks/app/views/todo/_not_done.rhtml index c2c35661..53d49622 100644 --- a/tracks/app/views/todo/_not_done.rhtml +++ b/tracks/app/views/todo/_not_done.rhtml @@ -7,7 +7,7 @@ <%= due_date( @notdone_item.due ) %> <%= @notdone_item.description %> <% if @notdone_item.project_id %> - <%= link_to( "[P]", { :controller => "project", :action => "show", :id => @notdone_item.project_id }, :title => "View project: #{@notdone_item.project['name']}" ) %> + <%= link_to( "[P]", { :controller => "project", :action => "show", :id => @notdone_item.project_id }, :title => "View project: #{@notdone_item.project.name}" ) %> <% end %> <% if @notdone_item.notes? %> <%= "" + $notes_img + "" %> diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/list.rhtml index 41fd85bc..208f0e98 100644 --- a/tracks/app/views/todo/list.rhtml +++ b/tracks/app/views/todo/list.rhtml @@ -1,6 +1,6 @@
<% for @shown_place in @shown_places %> - <% @not_done = Todo.find_all( "done=0 AND context_id=#{@shown_place.id}", "created ASC" ) %> + <% @not_done = Todo.find_all("done=0 AND context_id=#{@shown_place.id}", "created ASC") %> <% if !@not_done.empty? %>

<%= link_to( "#{@shown_place.name.capitalize}", :controller => "context", :action => "show", :id => @shown_place.id ) %>