diff --git a/app/controllers/costlog_controller.rb b/app/controllers/costlog_controller.rb index 16f95274f0..923384a8cf 100644 --- a/app/controllers/costlog_controller.rb +++ b/app/controllers/costlog_controller.rb @@ -16,6 +16,7 @@ class CostlogController < ApplicationController include SortHelper helper :issues include CostlogHelper + include PaginationHelper def index sort_init 'spent_on', 'desc' @@ -47,15 +48,11 @@ class CostlogController < ApplicationController respond_to do |format| format.html { - # Paginate results - @entry_count = CostEntry.count(:include => [:project, :user, :issue], :conditions => cond.conditions) - @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] - @entries = CostEntry.find(:all, - :include => [:project, :cost_type, :user, {:issue => :tracker}], - :conditions => cond.conditions, - :order => sort_clause, - :limit => @entry_pages.items_per_page, - :offset => @entry_pages.current.offset) + @entries = CostEntry.includes(:project, :cost_type, :user, {:work_package => :tracker}) + .where(cond.conditions) + .order(sort_clause) + .page(page_param) + .per_page(per_page_param) render :layout => !request.xhr? } @@ -154,8 +151,11 @@ private end def find_optional_project - if !params[:work_package_id].blank? - @issue = Issue.find(params[:work_package_id]) + if !params[:issue_id].blank? + @issue = Issue.find(params[:issue_id]) + @project = @issue.project + elsif !params[:work_package_id].blank? + @issue = WorkPackage.find(params[:work_package_id]) @project = @issue.project elsif !params[:project_id].blank? @project = Project.find(params[:project_id]) diff --git a/app/views/costlog/_list.html.erb b/app/views/costlog/_list.html.erb index 0d52302171..3073647451 100644 --- a/app/views/costlog/_list.html.erb +++ b/app/views/costlog/_list.html.erb @@ -18,8 +18,8 @@
<%= pagination_links_full @entry_pages, @entry_count %>
+<%= pagination_links_full @entries %> <% end %> <% html_title Issue.human_attribute_name(:spent_costs), l(:label_details) %>