diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 055c59f06..3de491421 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -121,7 +121,7 @@ class UsersController < ApplicationController
messages = MessageAll.where("user_id =?", @user).order("created_at desc")
messages.each do |message_all|
# 在点击或者刷新消息列表后未读的消息存放在数组
- if message_all.message_type != "SystemMessage" && message_all.message.viewed == 0
+ if message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0
@message_alls << message_all.message
end
end
@@ -522,6 +522,7 @@ class UsersController < ApplicationController
@atta_count = @attachments.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
+ @seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids]
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,7
respond_to do |format|
@@ -555,6 +556,7 @@ class UsersController < ApplicationController
@atta_count = @attachments.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
+ @seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids]
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,7
respond_to do |format|
@@ -586,6 +588,7 @@ class UsersController < ApplicationController
@atta_count = @attachments.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
+ @seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids]
#@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,7
respond_to do |format|
@@ -596,8 +599,8 @@ class UsersController < ApplicationController
#将资源批量引入
def import_resources_to_homework
@attachments = []
- unless params[:checkbox1].nil? || params[:checkbox1].blank?
- params[:checkbox1].each do |id|
+ unless session[:seleted_resource_ids].nil? || session[:seleted_resource_ids].blank?
+ session[:seleted_resource_ids].each do |id|
atta = Attachment.find(id)
att_copy = atta.copy
att_copy.container_id = nil
@@ -608,11 +611,23 @@ class UsersController < ApplicationController
@attachments << att_copy
end
end
+ session[:seleted_resource_ids] = [] #保存后清空
respond_to do |format|
format.js
end
end
+ # ajax 用session保存选择的资源id
+ def store_selected_resource
+ session[:seleted_resource_ids] = [] if session[:seleted_resource_ids].nil?
+ if params[:save] == 'y'
+ session[:seleted_resource_ids] << params[:res_id]
+ else
+ session[:seleted_resource_ids].delete( params[:res_id])
+ end
+ render :nothing => true
+ end
+
include CoursesHelper
def user_courses
diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb
index e2e1dcfc2..44b72868d 100644
--- a/app/views/courses/_course_activity.html.erb
+++ b/app/views/courses/_course_activity.html.erb
@@ -94,7 +94,7 @@
$('#reply_content_<%= activity.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
});
- <% if activity %>
+ <% if activity && activity.course_act%>
<% act = activity.course_act %>
<% case activity.course_act_type.to_s %>
<% when 'HomeworkCommon' %>
diff --git a/app/views/files/_tag_yun.html.erb b/app/views/files/_tag_yun.html.erb
index 4889e538d..41ae5f335 100644
--- a/app/views/files/_tag_yun.html.erb
+++ b/app/views/files/_tag_yun.html.erb
@@ -1,6 +1,6 @@
-<% if course %>
+<% if course && tag_list.empty? == false%>
- 全部
<% end %>
diff --git a/app/views/forums/_forum_tag_list.html.erb b/app/views/forums/_forum_tag_list.html.erb
index b074cbca3..1cae58619 100644
--- a/app/views/forums/_forum_tag_list.html.erb
+++ b/app/views/forums/_forum_tag_list.html.erb
@@ -1,6 +1,6 @@
-<% forum.tag_list.each do |tag|%>
+<% forum.reload.tag_list.each do |tag|%>
- <%= tag %>
+ <%= tag %>
<%if forum.creator.id == User.current.id%>
×
<% end %>
diff --git a/app/views/layouts/base_forums.html.erb b/app/views/layouts/base_forums.html.erb
index 8677bc705..d32fbf4ed 100644
--- a/app/views/layouts/base_forums.html.erb
+++ b/app/views/layouts/base_forums.html.erb
@@ -98,13 +98,8 @@
domEle.parent().css("border","1px solid #ffffff");
$("#renameTagName").focus();
}
- //监听所有的单击事件
- $(document).click(function(e){
- node = document.elementFromPoint(e.clientX, e.clientY);
- if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了
- return;
- }
- if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
+ $("#renameTagName").live('blur',function(){
+ if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态
ele.parent().css("border","");
ele.parent().html(tagNameHtml);
@@ -122,6 +117,30 @@
}
}
});
+ //监听所有的单击事件
+// $(document).click(function(e){
+// node = document.elementFromPoint(e.clientX, e.clientY);
+// if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了
+// return;
+// }
+// if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
+// if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态
+// ele.parent().css("border","");
+// ele.parent().html(tagNameHtml);
+//
+// }else{ //否则就要更新tag名称了
+// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){
+// $.post(
+// '<%#= update_tag_name_path %>',
+// {"taggableId": taggableId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim()}
+// )
+// }else{
+// ele.parent().css("border","");
+// ele.parent().html(tagNameHtml);
+// }
+// }
+// }
+// });
function del_forum_confirm(){
if(confirm('您确定要删除么?')){
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index c7f1d45c4..09544d004 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -21,6 +21,19 @@
"");
$('#ajax-modal').parent().css("top","30%").css("left","20%").css("position","fixed");
}
+
+ // 点击 checkbox选中引用的资源的时候,保存该资源的id到session里去
+ function store_seleted_resource(dom){
+ if(dom.attr('checked') == 'checked' ){
+ $.get(
+ '<%= store_selected_resource_user_path(User.current) %>'+'?save=y&res_id='+dom.val()
+ )
+ }else {
+ $.get(
+ '<%= store_selected_resource_user_path(User.current) %>'+'?save=n&res_id='+dom.val()
+ )
+ }
+ }