diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index a6df49dc..777c31d7 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -29,16 +29,20 @@ class AdminController < ApplicationController sort_init 'name', 'asc' sort_update - @status = params[:status] ? params[:status].to_i : 0 - conditions = nil - conditions = ["status=?", @status] unless @status == 0 + @status = params[:status] ? params[:status].to_i : 1 + c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status]) - @project_count = Project.count(:conditions => conditions) + unless params[:name].blank? + name = "%#{params[:name].strip.downcase}%" + c << ["LOWER(identifier) LIKE ? OR LOWER(name) LIKE ?", name, name] + end + + @project_count = Project.count(:conditions => c.conditions) @project_pages = Paginator.new self, @project_count, per_page_option, params['page'] @projects = Project.find :all, :order => sort_clause, - :conditions => conditions, + :conditions => c.conditions, :limit => @project_pages.items_per_page, :offset => @project_pages.current.offset diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 1b41d837..8f81f66b 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -17,7 +17,7 @@ module AdminHelper def project_status_options_for_select(selected) - options_for_select([[l(:label_all), "*"], + options_for_select([[l(:label_all), ''], [l(:status_active), 1]], selected) end end diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml index c4284562..6c7a21fb 100644 --- a/app/views/admin/projects.rhtml +++ b/app/views/admin/projects.rhtml @@ -4,11 +4,13 @@