首页左侧班级和项目列表的收藏功能
This commit is contained in:
parent
56b74b755b
commit
60beb2abab
|
@ -42,7 +42,7 @@ class UsersController < ApplicationController
|
|||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
|
||||
:user_courses4show,:user_projects4show,: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_collect]
|
||||
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
#before_filter :rest_user_score, only: :show
|
||||
#before_filter :select_entry, only: :user_projects
|
||||
|
@ -1459,15 +1459,15 @@ class UsersController < ApplicationController
|
|||
#显示更多用户课程
|
||||
def user_courses4show
|
||||
@page = params[:page].to_i + 1
|
||||
@courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10).offset(@page * 10)
|
||||
@all_count = @user.courses.visible.where("is_delete =?", 0).count
|
||||
@courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10).offset(@page * 10)
|
||||
@all_count = @user.favorite_courses.visible.where("is_delete =?", 0).count
|
||||
end
|
||||
|
||||
#显示更多用户项目
|
||||
def user_projects4show
|
||||
@page = params[:page].to_i + 1
|
||||
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10).offset(@page * 10)
|
||||
@all_count = @user.projects.visible.count
|
||||
@projects = @user.favorite_projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10).offset(@page * 10)
|
||||
@all_count = @user.favorite_projects.visible.count
|
||||
end
|
||||
|
||||
def user_course_activities
|
||||
|
@ -3424,20 +3424,27 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#取消收藏班级/项目
|
||||
def cancel_collect
|
||||
#收藏班级/项目
|
||||
def cancel_or_collect
|
||||
if params[:project]
|
||||
member = Member.where("user_id = #{@user.id} and project_id = #{params[:project].to_i}")
|
||||
@project = Project.find params[:project]
|
||||
member = Member.where("user_id = #{@user.id} and project_id = #{@project.id}")
|
||||
elsif params[:course]
|
||||
member = Member.where("user_id = #{@user.id} and course_id = #{params[:course].to_i}")
|
||||
@course = Course.find params[:course]
|
||||
member = Member.where("user_id = #{@user.id} and course_id = #{@course.id}")
|
||||
end
|
||||
unless member.empty?
|
||||
member.first.update_attribute(:is_collect => 0)
|
||||
member.first.update_attribute(:is_collect, member.first.is_collect == 0 ? 1 : 0)
|
||||
end
|
||||
if @project
|
||||
@projects = @user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)
|
||||
elsif @course
|
||||
@courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def user_projectlist
|
||||
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<% all_count = @user.favorite_courses.visible.where("is_delete =?", 0).count%>
|
||||
<div id="homepageLeftMenuCourses">
|
||||
<ul class="user_sub_menu" id="user_courses_li">
|
||||
<%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user,:all_count => all_count,:page => 0} %>
|
||||
</ul>
|
||||
</div>
|
||||
<% if !courses.empty? %>
|
||||
<a class="user_navmorebox" href="javascript:void(0);" id="user_hide_course" onclick="leftCourseslistChange();">
|
||||
<span id="hide_show_courseicon" class="user_icons_closeclass"></span>
|
||||
</a>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#user_hide_course').hide();
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,17 @@
|
|||
<% all_count = @user.favorite_projects.visible.count%>
|
||||
<div id="homepageLeftMenuForge">
|
||||
<ul class="user_sub_menu" id="user_projects_li">
|
||||
<%= render :partial => 'layouts/user_projects', :locals => {:projects => projects,:user => @user, :all_count => all_count, :page => 0} %>
|
||||
</ul>
|
||||
</div>
|
||||
<% if !projects.empty? %>
|
||||
<a class="user_navmorebox" href="javascript:void(0);" id="user_hide_project" onclick="leftProjectslistChange();">
|
||||
<span id="hide_show_projecticon" class="user_icons_closeclass"></span>
|
||||
</a>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#user_hide_project').hide();
|
||||
})
|
||||
</script>
|
|
@ -53,7 +53,7 @@
|
|||
<% end %>
|
||||
<% if User.current == user %>
|
||||
<li>
|
||||
<%= link_to "取消收藏", cancel_collect_user_path(user, :course => course.id), :class => 'user_navmore_li',:target => '_blank' %>
|
||||
<%= link_to "取消收藏", cancel_or_collect_user_path(user, :course => course.id), :class => 'user_navmore_li',:target => '_blank', :remote => true %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
</li>
|
||||
<% end %>
|
||||
<% if User.current == @user %>
|
||||
<li>
|
||||
<%= link_to "取消收藏", cancel_or_collect_user_path(user, :project => project.id), :class => 'user_navmore_li',:target => '_blank', :remote => true %>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li>
|
||||
<% if ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count == 0 %>
|
||||
<%= link_to "屏蔽动态", shield_activities_path(:user_id => user.id, :project_id => project.id), :method => 'post',:remote => true,:class => "user_navmore_li" %>
|
||||
|
|
|
@ -159,18 +159,8 @@
|
|||
<li id="user_01" class="user_icons_course">
|
||||
<%= link_to '班级',{:controller => "users", :action => "user_courselist", :id => @user.id}, :id => "user_course_list" %>
|
||||
<% courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10) %>
|
||||
<% all_count = @user.favorite_courses.visible.where("is_delete =?", 0).count%>
|
||||
<div class="<%= courses.empty? ? 'none' : ''%>" >
|
||||
<div id="homepageLeftMenuCourses">
|
||||
<ul class="user_sub_menu" id="user_courses_li">
|
||||
<%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user,:all_count => all_count,:page => 0} %>
|
||||
</ul>
|
||||
</div>
|
||||
<% if !courses.empty? %>
|
||||
<a class="user_navmorebox" href="javascript:void(0);" id="user_hide_course" onclick="leftCourseslistChange();">
|
||||
<span id="hide_show_courseicon" class="user_icons_closeclass"></span>
|
||||
</a>
|
||||
<% end %>
|
||||
<div class="<%= courses.empty? ? 'none' : ''%>" id="homepage_left_course_list">
|
||||
<%=render :partial => 'layouts/homepage_left_course_list', :locals => {:courses => courses} %>
|
||||
</div>
|
||||
</li>
|
||||
<% if is_current_user %>
|
||||
|
@ -195,19 +185,9 @@
|
|||
<ul class="users_accordion mb10">
|
||||
<li id="user_06" class="user_icons_project">
|
||||
<%= link_to '项目',{:controller => "users", :action => "user_projectlist", :id => @user.id}, :id => 'user_project_list'%>
|
||||
<% all_count = @user.favorite_projects.visible.count%>
|
||||
<% projects = @user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)%>
|
||||
<div class="<%= projects.empty? ? 'none' : ''%>" >
|
||||
<div id="homepageLeftMenuForge">
|
||||
<ul class="user_sub_menu" id="user_projects_li">
|
||||
<%= render :partial => 'layouts/user_projects', :locals => {:projects => projects,:user => @user, :all_count => all_count, :page => 0} %>
|
||||
</ul>
|
||||
</div>
|
||||
<% if !projects.empty? %>
|
||||
<a class="user_navmorebox" href="javascript:void(0);" id="user_hide_project" onclick="leftProjectslistChange();">
|
||||
<span id="hide_show_projecticon" class="user_icons_closeclass"></span>
|
||||
</a>
|
||||
<% end %>
|
||||
<div class="<%= projects.empty? ? 'none' : ''%>" id="homepage_left_project_list">
|
||||
<%=render :partial => 'layouts/homepage_left_project_list', :locals => {:projects => projects} %>
|
||||
</div>
|
||||
</li>
|
||||
<% if is_current_user %>
|
||||
|
@ -292,7 +272,6 @@
|
|||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#user_hide_course').hide();
|
||||
$('#user_hide_project').hide();
|
||||
autoUrl("user_brief_introduction_show");
|
||||
if(<%= @is_course == 1 %>) {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<% member = Member.where("user_id = #{@user.id} and course_id = #{course.id}").first %>
|
||||
<% if User.current == @user %>
|
||||
<% if member %>
|
||||
<%= link_to "", cancel_or_collect_user_path(@user, :course => course.id), :class => "#{member.is_collect == 1 ? 'icons_sy_favorite' : 'icons_sy_star'}",:target => '_blank', :remote => true, :title => "#{member.is_collect == 1 ? '点击将其从个人主页的班级列表中移除' : '点击将其添加至个人主页的班级列表中'}" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if member %>
|
||||
<span class="<%= member.is_collect == 1 ? 'icons_sy_favorite' : 'icons_sy_star'%>"></span>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,10 @@
|
|||
<% member = Member.where("user_id = #{@user.id} and project_id = #{project.id}").first %>
|
||||
<% if User.current == @user %>
|
||||
<% if member %>
|
||||
<%= link_to "", cancel_or_collect_user_path(@user, :project => project.id), :class => "#{member.is_collect == 1 ? 'icons_sy_favorite' : 'icons_sy_star'}",:target => '_blank', :remote => true, :title => "#{member.is_collect == 1 ? '点击将其从个人主页的班级列表中移除' : '点击将其添加至个人主页的班级列表中'}" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if member %>
|
||||
<span class="<%= member.is_collect == 1 ? 'icons_sy_favorite' : 'icons_sy_star'%>"></span>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -2,8 +2,9 @@
|
|||
<% courses.each_with_index do |course, i| %>
|
||||
<li class="syllabus_class_list <%= i > 2 ? 'none' : '' %>">
|
||||
<% allow_visit = User.current.member_of_course?(course) || User.current.admin? || course.is_public == 1 %>
|
||||
<span class="icons_sy_favorite " title="点击将其从个人主页的班级列表中移除"></span>
|
||||
<span class="icons_sy_star " title="点击将其添加至个人主页的班级列表中"></span>
|
||||
<span id="collect_course_icon_<%=course.id %>">
|
||||
<%=render :partial => 'collect_course', :locals => {:course => course} %>
|
||||
</span>
|
||||
|
||||
<div class="fl">
|
||||
<div class="syllabus_class_w ">
|
||||
|
|
|
@ -32,10 +32,13 @@
|
|||
<% projects.each_with_index do |project, i| %>
|
||||
<div class="syllabus_courses_list <%= i > 4 ? 'none' : ''%>" style="cursor: default;">
|
||||
<div class="sy_courses_open">
|
||||
<span id="collect_project_icon_<%=project.id %>">
|
||||
<%=render :partial => 'collect_project', :locals => {:project => project} %>
|
||||
</span>
|
||||
<span class="icons_project_list fl mt5 mr10"></span>
|
||||
<h3><%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
|
||||
<% unless project.is_public? %>
|
||||
<span class="hw_icon_private fl"></span>
|
||||
<span class="syllabus_class_private fl"></span>
|
||||
<% end %>
|
||||
<% projectUser = User.where("id=?",project.user_id).first %>
|
||||
<%=link_to "<span class='fr grayTxt'>创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}</span>".html_safe, user_path(projectUser) %>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<% if @course %>
|
||||
$("#homepage_left_course_list").html("<%= escape_javascript(render :partial => 'layouts/homepage_left_course_list', :locals => {:courses => @courses}) %>");
|
||||
if($("#collect_course_icon_<%=@course.id %>").length > 0){
|
||||
$("#collect_course_icon_<%=@course.id %>").html("<%= escape_javascript(render :partial => 'users/collect_course', :locals => {:course => @course}) %>");
|
||||
}
|
||||
<% elsif @project %>
|
||||
$("#homepage_left_project_list").html("<%= escape_javascript(render :partial => 'layouts/homepage_left_project_list', :locals => {:projects => @projects}) %>");
|
||||
if($("#collect_project_icon_<%=@project.id %>").length > 0){
|
||||
$("#collect_project_icon_<%=@project.id %>").html("<%= escape_javascript(render :partial => 'users/collect_project', :locals => {:project => @project}) %>");
|
||||
}
|
||||
<% end %>
|
|
@ -27,8 +27,9 @@
|
|||
} else if(count > 0) {
|
||||
var str = div.next().children().eq(0).attr('id');
|
||||
var id = str.substring(19);
|
||||
var user_id = <%= @user.id%>;
|
||||
$.get(
|
||||
'/users/expand_courses?syllabus_id=' + id
|
||||
'/users/'+user_id+'/expand_courses?syllabus_id=' + id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -567,7 +567,6 @@ RedmineApp::Application.routes.draw do
|
|||
post 'user_select_homework'
|
||||
post 'check_homework'
|
||||
get 'all_journals'
|
||||
get 'expand_courses'
|
||||
end
|
||||
|
||||
member do
|
||||
|
@ -667,7 +666,8 @@ RedmineApp::Application.routes.draw do
|
|||
post 'apply_for_resource'
|
||||
match 'manage_or_receive_homeworks', :to => 'users#manage_or_receive_homeworks', :via => :get
|
||||
get 'search_m_r_homeworks'
|
||||
post 'cancel_collect'
|
||||
get 'expand_courses'
|
||||
get 'cancel_or_collect'
|
||||
# end
|
||||
end
|
||||
#resources :blogs
|
||||
|
|
Loading…
Reference in New Issue