From 654bec22391a3c82194763deb853e9e0168a73f9 Mon Sep 17 00:00:00 2001 From: bsag Date: Sat, 1 Apr 2006 15:30:31 +0000 Subject: [PATCH] Added Luke's patch to fix the expand/collapse icons, which were formerly not working after an Ajax action had been performed without a refresh. This works properly now. Fixes #230. I also modified the context pages slightly so that it only shows the last n completed actions in that project, where n is the number of completed actions user preference (no_completed). I'll do the same for projects. It prevents the context and project individual pages getting unmanageably long when you've been using it for a while. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@214 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/models/context.rb | 3 ++- tracks/app/views/context/_context.rhtml | 2 +- tracks/app/views/context/show.rhtml | 2 +- tracks/app/views/todo/add_item.rjs | 4 ++-- tracks/app/views/todo/completed.rhtml | 2 +- tracks/app/views/todo/destroy_action.rjs | 5 +---- tracks/app/views/todo/error.rjs | 2 +- tracks/public/stylesheets/standard.css | 3 +++ 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tracks/app/models/context.rb b/tracks/app/models/context.rb index e4133370..a65ead83 100644 --- a/tracks/app/models/context.rb +++ b/tracks/app/models/context.rb @@ -25,7 +25,8 @@ class Context < ActiveRecord::Base def find_done_todos todos = Todo.find :all, :conditions => ["todos.context_id = #{id} AND todos.done = ?", true], :include => [:context, :project], - :order => "due IS NULL, due ASC, created_at ASC" + :order => "due IS NULL, due ASC, created_at ASC", + :limit => @user.preferences["no_completed"] end # Returns a count of next actions in the given context diff --git a/tracks/app/views/context/_context.rhtml b/tracks/app/views/context/_context.rhtml index 3ddad253..4fc2328a 100644 --- a/tracks/app/views/context/_context.rhtml +++ b/tracks/app/views/context/_context.rhtml @@ -6,7 +6,7 @@ <% end -%> <%= link_to( sanitize("#{context.name}"), { :controller => "context", :action => "show", :name => urlize(context.name) }, { :title => "Go to the #{context.name} context page" } ) %> -
+

Currently there are no uncompleted actions in this context

diff --git a/tracks/app/views/context/show.rhtml b/tracks/app/views/context/show.rhtml index 13b816f4..1c6c8774 100644 --- a/tracks/app/views/context/show.rhtml +++ b/tracks/app/views/context/show.rhtml @@ -7,7 +7,7 @@ <% end %> <%= render :partial => "context/context", :locals => { :context => @context, :collapsible => false } %> -<%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this context" } %> +<%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this context (last #{@user.preferences["no_completed"]})" } %>
diff --git a/tracks/app/views/todo/add_item.rjs b/tracks/app/views/todo/add_item.rjs index 79a86559..09f25f8d 100644 --- a/tracks/app/views/todo/add_item.rjs +++ b/tracks/app/views/todo/add_item.rjs @@ -3,9 +3,9 @@ if @saved page.replace_html "status", content_tag("div", "Added new next action", "class" => "confirmation") page.visual_effect :appear, 'status', :duration => 0.5 page.replace_html "badge_count", @up_count - page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3 page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')" - page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item' + page.insert_html :bottom, "c#{@item.context_id}items", :partial => 'todo/item' + page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3 else page.hide "status" page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation") diff --git a/tracks/app/views/todo/completed.rhtml b/tracks/app/views/todo/completed.rhtml index 5dd4d5b6..60c42d1a 100644 --- a/tracks/app/views/todo/completed.rhtml +++ b/tracks/app/views/todo/completed.rhtml @@ -15,7 +15,7 @@
-

Completed in the last 31 days

+

Completed in the last 28 days

<%= render :partial => "done", :collection => @done_this_month %>
diff --git a/tracks/app/views/todo/destroy_action.rjs b/tracks/app/views/todo/destroy_action.rjs index 44c2e091..f7b6ca64 100644 --- a/tracks/app/views/todo/destroy_action.rjs +++ b/tracks/app/views/todo/destroy_action.rjs @@ -1,9 +1,6 @@ if @saved page["item-#{@item.id}-container"].remove -# For some reason, the code below works on the project and context pages, but -# not on the todo/list page when the item being deleted has just been added -# page.visual_effect :fade, "item-#{@item.id}-container", :duration => 0.4 page['badge_count'].replace_html @down_count else - page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation") + page["status"].replace_html content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation") end \ No newline at end of file diff --git a/tracks/app/views/todo/error.rjs b/tracks/app/views/todo/error.rjs index 90996ca6..9a5a0dcc 100644 --- a/tracks/app/views/todo/error.rjs +++ b/tracks/app/views/todo/error.rjs @@ -1 +1 @@ -page.replace_html "status", "An error occurred on the server." \ No newline at end of file +page["status"].replace_html "An error occurred on the server." \ No newline at end of file diff --git a/tracks/public/stylesheets/standard.css b/tracks/public/stylesheets/standard.css index c6caec2f..60fca1ee 100644 --- a/tracks/public/stylesheets/standard.css +++ b/tracks/public/stylesheets/standard.css @@ -279,6 +279,9 @@ a.footer_link:hover {color: #fff; background-color: #cc3334 !important;} text-align: center; } +#status .confirmation { + width: 220px; +} #warning, .warning { padding: 2px; border: 1px solid #ED2E38;