From d3b04f9eab895b1660c4c91de72bea4f54c6f8d1 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 27 Jun 2013 12:16:45 +0200 Subject: [PATCH] Fix index form --- app/controllers/costlog_controller.rb | 22 +++++++++++----------- app/views/costlog/_list.html.erb | 6 +++--- app/views/costlog/index.html.erb | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) 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 @@ <%=h entry.user %> <%=h entry.project %> - <% if entry.issue -%> - <%= link_to_issue entry.issue -%> + <% if entry.work_package -%> + <%= link_to_issue entry.work_package -%> <% end -%> @@ -36,7 +36,7 @@ :title => l(:button_edit) %> <%= link_to image_tag('delete.png'), {:controller => '/costlog', :action => 'destroy', :id => entry, :project_id => nil}, :confirm => l(:text_are_you_sure), - :method => :post, + :method => :delete, :title => l(:button_delete) %> <% end -%> diff --git a/app/views/costlog/index.html.erb b/app/views/costlog/index.html.erb index 0f0ad85b03..732790d4c1 100644 --- a/app/views/costlog/index.html.erb +++ b/app/views/costlog/index.html.erb @@ -16,7 +16,7 @@ <% unless @entries.empty? %> <%= render :partial => 'list', :locals => { :entries => @entries }%> -

<%= pagination_links_full @entry_pages, @entry_count %>

+<%= pagination_links_full @entries %> <% end %> <% html_title Issue.human_attribute_name(:spent_costs), l(:label_details) %>