修复管理员界面,项目列表的搜索功能

This commit is contained in:
daiao 2016-09-18 15:16:31 +08:00
parent 43a3ad1ce8
commit 4504308403
2 changed files with 7 additions and 2 deletions

View File

@ -31,6 +31,7 @@ class AdminController < ApplicationController
@no_configuration_data = Redmine::DefaultData::Loader::no_data?
end
# 管理员界面 项目列表
def projects
=begin
@status = params[:status] || 1
@ -39,7 +40,11 @@ class AdminController < ApplicationController
scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all
=end
@projects = Project.like(@name).order('created_on desc')
# 搜索功能
@name = params[:name] || ""
condition = "#{@name.strip}".gsub(" ","")
@projects = Project.like(condition).order('created_on desc')
# 分页
@projects = paginateHelper @projects,30
@page = (params['page'] || 1).to_i - 1
render :action => "projects", :layout => false if request.xhr?

View File

@ -18,7 +18,7 @@
<label for='name'>
<%= l(:label_project) %>:
</label>
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入项目名称进行搜索' %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'projects'}, :class => 'icon icon-reload' %>
</fieldset>