个人主页列表细分tab显示

This commit is contained in:
daiao 2017-07-18 15:24:12 +08:00
parent d54d49f08b
commit 75930637c0
7 changed files with 98 additions and 16 deletions

View File

@ -45,7 +45,7 @@ class UsersController < ApplicationController
:user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community,
:shixuns, :user_show_course_list]
:shixuns, :user_show_course_list, :shixuns_or_courses_filter]
before_filter :auth_user_extension, only: :show
before_filter :show_system_message, :only => [:show]
#before_filter :rest_user_score, only: :show
@ -2030,6 +2030,7 @@ class UsersController < ApplicationController
@user_fanlist_count = fan_query.count();
@user_fanlist = fan_query.order("#{Watcher.table_name}.id desc").limit(12);
=begin
# 合作者及创建者
ids = Shixun.find_by_sql("select shixun_id from shixun_members where user_id=#{@user.id}")
# 已挑战过
@ -2038,12 +2039,13 @@ class UsersController < ApplicationController
ids2 = ids2.map{|shixun| shixun.id} unless ids2.blank?
id = ids + ids2
id = id.uniq
=end
if @user == User.current
@shixuns = Shixun.where(:id => id).order("created_at desc")
@shixuns = Shixun.where(:user_id => @user).order("created_at desc")
else
@shixuns = Shixun.where(:status => [2, 3], :id => id).order("created_at desc")
@shixuns = Shixun.where(:status => [2, 3], :id => @user).order("created_at desc")
end
@limit = 8
@limit = 5
@is_remote = true
@shixuns_count = @shixuns.count
@shixuns_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1
@ -2193,11 +2195,67 @@ class UsersController < ApplicationController
end
end
# @params: index表示 "实训" 或 "课程" 那个的筛选
# filter 表示筛选的条件[challenge => "我挑战的", create => "我创建的", cooperative => "合作者"]
def shixuns_or_courses_filter
if params[:index] == "shixun"
if params[:filter] == "challenge"
# 已挑战过
id = Shixun.find_by_sql("select id from shixuns where id in (select shixun_id from myshixuns where user_id = #{@user.id})")
if @user == User.current
@shixuns = Shixun.where(:id => id).order("created_at desc")
else
@shixuns = Shixun.where(:status => [2, 3], :id => id).order("created_at desc")
end
elsif params[:filter] == "create"
if @user == User.current
@shixuns = Shixun.where(:user_id => @user).order("created_at desc")
else
@shixuns = Shixun.where(:status => [2, 3], :id => @user).order("created_at desc")
end
elsif params[:filter] == "cooperative"
# 合作者及创建者
ids = Shixun.find_by_sql("select shixun_id from shixun_members where user_id=#{@user.id}")
ids = ids.map{|shixun| shixun.shixun_id} unless ids.blank?
# 我创建的id
create_id = Shixun.where(:user_id => @user).pluck(:id)
id = ids - create_id
if @user == User.current
@shixuns = Shixun.where(:id => id).order("created_at desc")
else
@shixuns = Shixun.where(:status => [2, 3], :id => id).order("created_at desc")
end
end
@limit = 5
@is_remote = true
@shixuns_count = @shixuns.count
@shixuns_pages = Paginator.new @shixuns_count, @limit, params['page'] || 1
@offset ||= @shixuns_pages.offset
@shixuns = paginateHelper @shixuns, @limit
elsif params[:index] == "course"
if params[:filter] == "manage"
@courses = @user.courses.not_deleted_not_end.where(:tea_id => @user.id).order("updated_at desc")
elsif params[:filter] == "join"
@courses = @user.courses.not_deleted_not_end.where("tea_id != #{@user.id}").order("updated_at desc")
end
@limit = 5
@is_remote = true
@courses_count = @courses.count
@courses_pages = Paginator.new @courses_count, @limit, params['page'] || 1
@offset ||= @courses_pages.offset
@courses = paginateHelper @courses, @limit
end
respond_to do |format|
format.js
end
end
def user_show_course_list
@courses = @user.courses.not_deleted_not_end
@courses = @user.courses.not_deleted_not_end.where(:tea_id => @user.id).order("updated_at desc")
@courses_count = @courses.count
@courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc")
@limit = 8
@limit = 5
@is_remote = true
@courses_pages = Paginator.new @courses_count, @limit, params['page'] || 1
@offset ||= @courses_pages.offset

View File

@ -2,10 +2,15 @@
<% str = current_user == @user ? '我' : 'TA' %>
<ul id="edu-user-tab-nav">
<li class="edu-user-tab-hover new-tab-nav">
<a href="javascript:void(0);" class="font-16 tab_type"><%= str %>的课堂 <%= @courses_count %></a>
<a href="javascript:void(0);" class="font-16 tab_type"><%= str %>的课堂 <span id="user_course_count"> <%= @courses_count %></span></a>
</li>
</ul>
<div class="user_bg_shadow">
<div style="height: 40px; margin-top: 10px;margin-left: 12px;">
<a href="<%= shixuns_or_courses_filter_user_path(@user, :index => "course", :filter => "manage") %>" class="course_filtrate_bg course_filtrate fl" data-remote="true">我管理的</a>
<a href="<%= shixuns_or_courses_filter_user_path(@user, :index => "course", :filter => "join") %>" class="course_filtrate fl" data-remote="true">我参与的</a>
</div>
</div>
<div class="lesson clearfix" id="my_courses_list">
<%= render :partial => "my_homepage_courses_list" %>
</div>

View File

@ -11,8 +11,8 @@
<p class="clearfix pl10">
<a href="<%= course_path(course) %>" target="_blank" class="font-16 first link-color-grey03"><i class="fa fa-circle-o color-orange02 font-12 ml5 mr5" aria-hidden="true"></i><%= course.name %></a>
<span class="font-14 hasmargin"><a href="<%= syllabus_path(course.syllabus) %>" target="_blank" class="link-color-grey03"><%= course.syllabus.title %></a></span>
<span class="font-14 hasmargin"><a href="<%= user_path(course.syllabus.user_id) %>" class="link-color-grey03" target="_blank"><%= User.where(:id => course.syllabus.user_id).first.show_name %></a></span>
<span class="font-14 mr25 color-grey fr"><%= format_time course.updatetime %></span>
<span class="font-14 hasmargin"><a href="<%= user_path(course.syllabus.user_id) %>" class="link-color-grey03" target="_blank"><%= User.where(:id => course.tea_id).first.show_name %></a></span>
<span class="font-14 mr25 color-grey fr"><%= format_time course.updated_at %></span>
<span class="font-14 last cl" style="display: none;">分享&nbsp;&nbsp;<i class="fa fa-weixin font-14 blue" aria-hidden="true"></i></span>
</p>
<% end %>

View File

@ -0,0 +1,7 @@
<% if params[:index] == "shixun" %>
$("#my_shixuns_list").html("<%= j ( render :partial => "my_homepage_shixuns_list") %>");
$("#user_shixun_count").html(" <%= @shixuns_count %>");
<% elsif params[:index] == "course" %>
$("#my_courses_list").html("<%= j (render :partial => "my_homepage_courses_list") %>");
$("#user_course_count").html(" <%= @courses_count %>");
<% end %>

View File

@ -226,10 +226,16 @@
<% str = current_user ? '我' : 'TA' %>
<ul id="edu-user-tab-nav">
<li class="edu-user-tab-hover new-tab-nav">
<a href="javascript:void(0);" class="tab_type font-16"><%= str %>的实训 <%= @shixuns_count %></a>
<a href="javascript:void(0);" class="tab_type font-16"><%= str %>的实训<span id="user_shixun_count"> <%= @shixuns_count %></span></a>
</li>
</ul>
<div class="user_bg_shadow">
<div style="height: 40px; margin-top: 10px;margin-left: 12px;">
<a href="<%= shixuns_or_courses_filter_user_path(@user, :index => "shixun", :filter => "create") %>" class="course_filtrate fl course_filtrate_bg" data-remote="true">我创建的</a>
<a href="<%= shixuns_or_courses_filter_user_path(@user, :index => "shixun", :filter => "cooperative") %>" class="course_filtrate fl" data-remote="true">我合作的</a>
<a href="<%= shixuns_or_courses_filter_user_path(@user, :index => "shixun", :filter => "challenge") %>" class="course_filtrate fl" data-remote="true">我挑战的</a>
</div>
</div>
<div class="lesson clearfix user_bg_shadow" id="my_shixuns_list">
<%= render :partial => "my_homepage_shixuns_list" %>
</div>
@ -288,4 +294,9 @@
$('#edu-tab-con-'+n).removeClass('undis');
$('#edu-tab-nav-'+n).addClass('edu-new-tab-hover');
}
/* --------------- 课程/实训 tab小图标的点击效果---------------------- */
$(".course_filtrate").live("click", function(ev){
$(this).parent().find(".course_filtrate_bg").removeClass("course_filtrate_bg");
$(ev.target).addClass("course_filtrate_bg");
})
</script>

View File

@ -898,6 +898,7 @@ RedmineApp::Application.routes.draw do
match 'watch_projects', :to => 'users#watch_projects', :via => :get
get 'update_message_viewed'
get 'change_user_email'
get 'shixuns_or_courses_filter'
#
# added by bai
match 'show_score', :to => 'users#show_score', :via => :get

View File

@ -281,9 +281,9 @@ html>body #ajax-indicator { position: fixed; }
.white_bg {background: #fff}
.user_tab_type {background: #FF6610}
.course_filtrate{width: 70px;text-align: center;background: #fff;border-radius: 10px;margin-right: 10px}
.course_filtrate:hover{background: #FFDAC1; color: #FF6610;}
.course_filtrate_bg{background: #FFDAC1; color: #FF6610!important;}
.course_filtrate{width: 70px;text-align: center;background: #fff;border-radius: 10px;margin-right: 10px; border:1px solid #ccc;}
.course_filtrate:hover{background: #FFDAC1; color: #FF6610; border:1px solid #FFDAC1;}
.course_filtrate_bg{background: #FFDAC1; color: #FF6610!important;border:1px solid #FFDAC1;}
/*最新和最热导航条的公用样式*/