名师列表局部搜索
This commit is contained in:
parent
91f3fddb16
commit
660cf7ef73
|
@ -164,16 +164,17 @@ class OrganizationsController < ApplicationController
|
|||
return
|
||||
end
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
if params[:type] == "courses" || params[:type].nil?
|
||||
@type = params[:type]
|
||||
if @type == "courses" || @type.nil?
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif params[:type] == "students"
|
||||
elsif @type == "students"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif params[:type] == "resources"
|
||||
elsif @type == "resources"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif params[:type] == "famous"
|
||||
elsif @type == "famous"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% @org_teachers.each do |org_teacher| %>
|
||||
<% org_teachers.each do |org_teacher| %>
|
||||
<% school = School.where("id =?", org_teacher.school_id).first %>
|
||||
<div class="teacher-list-row">
|
||||
<div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="resources mt10">
|
||||
<div class="function-row">
|
||||
<%= form_tag( url_for(:controller => 'organizations', :action => 'teachers'),
|
||||
<div class="function-row" id="org_teacher_search">
|
||||
<%= form_tag( url_for(:controller => 'organizations', :action => 'teachers', :type => @type),
|
||||
:remote => true , :method => 'get', :id => 'resource_search_form') do %>
|
||||
<input type="text" name="search" placeholder="输入教师名进行搜索" class="teacher-list-search fl" />
|
||||
<%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :class => "teacher-search-icon fl" %>
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list')%>');
|
||||
$("#pages").html('<%= pagination_links_full @atta_pages, @teachers_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list', :locals => {:org_teachers => @org_teachers})%>');
|
||||
$("#pages").html('<%= pagination_links_full @atta_pages, @teachers_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#org_teacher_search").attr('href','<%= teachers_organization_path(@organization, :type => @type) %>');
|
Loading…
Reference in New Issue