move will_paginate on all_todos pages to will_paginate-bootstrap gem to get the bootstrap

styling for free. Adds caching to todos/done page too
This commit is contained in:
Reinier Balt 2013-07-29 12:25:13 +02:00
parent d139693632
commit 7605ec404f
6 changed files with 46 additions and 31 deletions

View file

@ -35,7 +35,7 @@ gem 'mousetrap-rails'
gem "RedCloth"
gem "sanitize"
gem "will_paginate"
gem "will_paginate-bootstrap"
gem "acts_as_list"
gem "aasm"
gem "htmlentities"

View file

@ -206,6 +206,8 @@ GEM
uniform_notifier (1.2.0)
websocket (1.0.7)
will_paginate (3.0.4)
will_paginate-bootstrap (0.2.3)
will_paginate (>= 3.0.3)
xpath (2.0.0)
nokogiri (~> 1.3)
yard (0.8.7)
@ -250,5 +252,5 @@ DEPENDENCIES
turbolinks
twitter-bootstrap-rails!
uglifier (>= 1.3.0)
will_paginate
will_paginate-bootstrap
yard

View file

@ -32,6 +32,8 @@ class TodosController < ApplicationController
# Set count badge to number of not-done, not hidden context items
@count = current_user.todos.active.not_hidden.count(:all)
@todos_without_project = @not_done_todos.select{|t|t.project.nil?}
@last_updated_todo_without_project = @todos_without_project
.inject(@todos_without_project.first){ |last, todo| todo.updated_at > last.updated_at ? todo : last }
end
format.m do
@page_title = t('todos.mobile_todos_page_title')
@ -536,7 +538,11 @@ class TodosController < ApplicationController
@source_view = 'done'
@page_title = t('todos.completed_tasks_title')
@done = current_user.todos.completed.includes(Todo::DEFAULT_INCLUDES).reorder('completed_at DESC').paginate :page => params[:page], :per_page => 20
@done = current_user.todos.completed
.includes(Todo::DEFAULT_INCLUDES)
.reorder('completed_at DESC')
.page(params[:page]).per_page(20)
@count = @done.size
end

View file

@ -87,11 +87,11 @@ module TodosHelper
end
def todos_container_header(settings={})
header = settings[:link_in_header].nil? ? "" : content_tag(:div, :class=>"add_note_link"){settings[:link_in_header]}
header += content_tag(:h4) do
link = settings[:link_in_header].nil? ? "" : content_tag(:span, :class=>"add-note-link"){"(#{settings[:link_in_header]})".html_safe}
header = content_tag(:h4) do
toggle = ""
# TODO: toggle = settings[:collapsible] ? container_toggle("toggle_#{settings[:id]}") : ""
"#{toggle} #{settings[:title]} #{settings[:append_descriptor]}".html_safe
"#{toggle} #{settings[:title]} #{settings[:append_descriptor]} #{link}".html_safe
end
header.html_safe
end

View file

@ -1,22 +1,24 @@
<%
paginate_options = {
:class => :add_note_link,
:previous_label => '&laquo; '+ t('common.previous'),
:next_label => t('common.next')+' &raquo;',
:inner_window => 2
class: 'pagination pagination-small',
previous_label: '&laquo; '+ t('common.previous'),
next_label: t('common.next')+' &raquo;',
inner_window: 2,
renderer: BootstrapPagination::Rails
}
%>
<div id="display_box_projects">
<div class="container">
<div class="paginate_header"><%= will_paginate @done, paginate_options %></div>
<h2><%= t('todos.all_completed') %></h2>
<% if @done.empty? -%>
<div class="message"><p><%= t('todos.no_completed_actions') %></p></div>
<% else -%>
<%= render :partial => "todos/todo", :collection => @done, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
<% end -%>
</div>
<div class="paginate_footer"><%= will_paginate @done, paginate_options %></div>
<div class="paginate_header">
<%= will_paginate @done, paginate_options %>
</div>
<h2><%= t('todos.all_completed') %></h2>
<% if @done.empty? -%>
<div class="message">
<p><%= t('todos.no_completed_actions') %></p>
</div>
<% else -%>
<%= render :partial => "todos/todo", :collection => @done, :locals => { :parent_container_type => "completed", :suppress_context => false, :suppress_project => false } %>
<% end -%>
<div class="paginate_footer"><%= will_paginate @done, paginate_options %></div>

View file

@ -1,13 +1,18 @@
<div id="display_box_projects">
<%# Template Dependency: todos/collection -%>
<% cache [@done_today.first, "done_today"] do -%>
<%= show_completed_todos_for("today", @done_today) %>
<%= show_completed_todos_for("rest_of_week", @done_rest_of_week) %>
<%= show_completed_todos_for("rest_of_month", @done_rest_of_month) %>
<% end -%>
<p>
<% cache [@done_rest_of_week.first, "done_rest_of_week"] do -%>
<%= show_completed_todos_for("rest_of_week", @done_rest_of_week) %>
<% end -%>
<% cache [@done_rest_of_month.first, "done_rest_of_month"] do -%>
<%= show_completed_todos_for("rest_of_month", @done_rest_of_month) %>
<% end -%>
<p>
<%= raw t('todos.see_all_completed',
:link => link_to(t("todos.all_completed_here"), determine_all_done_path))
%>
</p>
</div>
</p>