资源库 多选发送
This commit is contained in:
parent
f97a55e164
commit
7ddf6d1e7d
|
@ -880,7 +880,9 @@ class UsersController < ApplicationController
|
||||||
@course = @user.courses
|
@course = @user.courses
|
||||||
.select { |course| @user.allowed_to?(:as_teacher,course)}
|
.select { |course| @user.allowed_to?(:as_teacher,course)}
|
||||||
end
|
end
|
||||||
|
#这里仅仅是传递需要发送的资源id
|
||||||
@send_id = params[:send_id]
|
@send_id = params[:send_id]
|
||||||
|
@send_ids = params[:checkbox1] || params[:send_ids]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -894,19 +896,22 @@ class UsersController < ApplicationController
|
||||||
else
|
else
|
||||||
@projects = @user.projects
|
@projects = @user.projects
|
||||||
end
|
end
|
||||||
|
#这里仅仅是传递需要发送的资源id
|
||||||
@send_id = params[:send_id]
|
@send_id = params[:send_id]
|
||||||
|
@send_ids = params[:checkbox1] || params[:send_ids] #搜索的时候 和 直接 用表格提交的时候的send_ids
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 将资源发送到对应的课程
|
# 将资源发送到对应的课程,分为发送单个,或者批量发送
|
||||||
def add_exist_file_to_course
|
def add_exist_file_to_course
|
||||||
|
if params[:send_id].present?
|
||||||
send_id = params[:send_id]
|
send_id = params[:send_id]
|
||||||
|
ori = Attachment.find_by_id(send_id)
|
||||||
course_ids = params[:course_ids]
|
course_ids = params[:course_ids]
|
||||||
unless course_ids.nil?
|
unless course_ids.nil?
|
||||||
course_ids.each do |id|
|
course_ids.each do |id|
|
||||||
ori = Attachment.find_by_id(send_id)
|
|
||||||
next if ori.blank?
|
next if ori.blank?
|
||||||
attach_copied_obj = ori.copy
|
attach_copied_obj = ori.copy
|
||||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||||
|
@ -920,6 +925,28 @@ class UsersController < ApplicationController
|
||||||
@save_message = attach_copied_obj.errors.full_messages
|
@save_message = attach_copied_obj.errors.full_messages
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elsif params[:send_ids].present?
|
||||||
|
send_ids = params[:send_ids].split(" ")
|
||||||
|
send_ids.each do |send_id|
|
||||||
|
ori = Attachment.find_by_id(send_id)
|
||||||
|
course_ids = params[:course_ids]
|
||||||
|
unless course_ids.nil?
|
||||||
|
course_ids.each do |id|
|
||||||
|
next if ori.blank?
|
||||||
|
attach_copied_obj = ori.copy
|
||||||
|
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||||
|
attach_copied_obj.container = Course.find(id)
|
||||||
|
attach_copied_obj.created_on = Time.now
|
||||||
|
attach_copied_obj.author_id = User.current.id
|
||||||
|
if attach_copied_obj.attachtype == nil
|
||||||
|
attach_copied_obj.attachtype = 4
|
||||||
|
end
|
||||||
|
attach_copied_obj.save
|
||||||
|
@save_message = attach_copied_obj.errors.full_messages
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -927,6 +954,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 添加资源到对应的项目
|
# 添加资源到对应的项目
|
||||||
def add_exist_file_to_project
|
def add_exist_file_to_project
|
||||||
|
if params[:send_id].present?
|
||||||
send_id = params[:send_id]
|
send_id = params[:send_id]
|
||||||
project_ids = params[:projects_ids]
|
project_ids = params[:projects_ids]
|
||||||
ori = Attachment.find_by_id(send_id)
|
ori = Attachment.find_by_id(send_id)
|
||||||
|
@ -944,6 +972,28 @@ class UsersController < ApplicationController
|
||||||
attach_copied_obj.save
|
attach_copied_obj.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elsif params[:send_ids].present?
|
||||||
|
send_ids = params[:send_ids].split(" ")
|
||||||
|
send_ids.each do |send_id|
|
||||||
|
project_ids = params[:projects_ids]
|
||||||
|
ori = Attachment.find_by_id(send_id)
|
||||||
|
unless project_ids.nil?
|
||||||
|
project_ids.each do |project_id|
|
||||||
|
next if ori.blank?
|
||||||
|
attach_copied_obj = ori.copy
|
||||||
|
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||||
|
attach_copied_obj.container = Project.find(project_id)
|
||||||
|
attach_copied_obj.created_on = Time.now
|
||||||
|
attach_copied_obj.author_id = User.current.id
|
||||||
|
if attach_copied_obj.attachtype == nil
|
||||||
|
attach_copied_obj.attachtype = 1
|
||||||
|
end
|
||||||
|
attach_copied_obj.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="sendText fl">将资源发送至</div>
|
<div class="sendText fl">将资源发送至</div>
|
||||||
<div class="resourcesSendTo">
|
<div class="resourcesSendTo">
|
||||||
<select class="resourcesSendType" onclick="chooseSendType();">
|
<select class="resourcesSendType" onclick="chooseSendType('<%= send_id%>','<%= send_ids%>');">
|
||||||
<option value="1">课程</option>
|
<option value="1">课程</option>
|
||||||
<option value="2" selected>项目</option>
|
<option value="2" selected>项目</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -14,7 +14,8 @@
|
||||||
<div class="fl">
|
<div class="fl">
|
||||||
<%= form_tag search_user_project_user_path(user),:method => 'get',
|
<%= form_tag search_user_project_user_path(user),:method => 'get',
|
||||||
:remote=>true,:id=>'search_user_project_form',:class=>'resourcesSearchBox' do %>
|
:remote=>true,:id=>'search_user_project_form',:class=>'resourcesSearchBox' do %>
|
||||||
<%= hidden_field_tag(:send_id, @send_id) %>
|
<%= hidden_field_tag(:send_id, send_id) %>
|
||||||
|
<%= hidden_field_tag(:send_ids, send_ids) %>
|
||||||
<input type="text" name="search" placeholder="输入项目ID或者名称搜索" class="searchResourcePopup" />
|
<input type="text" name="search" placeholder="输入项目ID或者名称搜索" class="searchResourcePopup" />
|
||||||
<!--<a href="javascript:void(0);" class="searchIconPopup"></a>-->
|
<!--<a href="javascript:void(0);" class="searchIconPopup"></a>-->
|
||||||
<%= submit_tag '',:class=>'searchIconPopup',:onfocus=>"this.blur();",:style=>'border-style:none' %>
|
<%= submit_tag '',:class=>'searchIconPopup',:onfocus=>"this.blur();",:style=>'border-style:none' %>
|
||||||
|
@ -23,7 +24,8 @@
|
||||||
<%= form_tag add_exist_file_to_project_user_path(user),:remote=>true,:id=>'projects_list_form' %>
|
<%= form_tag add_exist_file_to_project_user_path(user),:remote=>true,:id=>'projects_list_form' %>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<%= hidden_field_tag(:send_id, @send_id) %>
|
<%= hidden_field_tag(:send_id, send_id) %>
|
||||||
|
<%= hidden_field_tag(:send_ids, send_ids) %>
|
||||||
<% if !projects.empty? %>
|
<% if !projects.empty? %>
|
||||||
<% projects.each do |project| %>
|
<% projects.each do |project| %>
|
||||||
<ul class="courseSend fl">
|
<ul class="courseSend fl">
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="sendText fl">将资源发送至</div>
|
<div class="sendText fl">将资源发送至</div>
|
||||||
<div class="resourcesSendTo">
|
<div class="resourcesSendTo">
|
||||||
<select class="resourcesSendType" onclick="chooseSendType();">
|
<select class="resourcesSendType" onclick="chooseSendType('<%= send_id%>','<%= send_ids%>');">
|
||||||
<option value="1">课程</option>
|
<option value="1">课程</option>
|
||||||
<option value="2">项目</option>
|
<option value="2">项目</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -14,7 +14,8 @@
|
||||||
<div class="fl">
|
<div class="fl">
|
||||||
<%= form_tag search_user_course_user_path(user),:method => 'get',
|
<%= form_tag search_user_course_user_path(user),:method => 'get',
|
||||||
:remote=>true,:id=>'search_user_course_form',:class=>'resourcesSearchBox' do %>
|
:remote=>true,:id=>'search_user_course_form',:class=>'resourcesSearchBox' do %>
|
||||||
<%= hidden_field_tag(:send_id, @send_id) %>
|
<%= hidden_field_tag(:send_id, send_id) %>
|
||||||
|
<%= hidden_field_tag(:send_ids, send_ids) %>
|
||||||
<input type="text" name="search" placeholder="输入课程ID或者名称搜索" class="searchResourcePopup" />
|
<input type="text" name="search" placeholder="输入课程ID或者名称搜索" class="searchResourcePopup" />
|
||||||
<!--<a href="javascript:void(0);" class="searchIconPopup"></a>-->
|
<!--<a href="javascript:void(0);" class="searchIconPopup"></a>-->
|
||||||
<%= submit_tag '',:class=>'searchIconPopup',:onfocus=>"this.blur();",:style=>'border-style:none' %>
|
<%= submit_tag '',:class=>'searchIconPopup',:onfocus=>"this.blur();",:style=>'border-style:none' %>
|
||||||
|
@ -23,7 +24,8 @@
|
||||||
<%= form_tag add_exist_file_to_course_user_path(user),:remote=>true,:id=>'course_list_form' %>
|
<%= form_tag add_exist_file_to_course_user_path(user),:remote=>true,:id=>'course_list_form' %>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<%= hidden_field_tag(:send_id, @send_id) %>
|
<%= hidden_field_tag(:send_id, send_id) %>
|
||||||
|
<%= hidden_field_tag(:send_ids, send_ids) %>
|
||||||
<% if !courses.empty? %>
|
<% if !courses.empty? %>
|
||||||
<% courses.each do |course| %>
|
<% courses.each do |course| %>
|
||||||
<ul class="courseSend fl">
|
<ul class="courseSend fl">
|
||||||
|
|
|
@ -7,5 +7,5 @@ var popupHeight = $(".resourceSharePopup").outerHeight(true);
|
||||||
$(".resourceSharePopup").css("marginTop",-popupHeight/2);
|
$(".resourceSharePopup").css("marginTop",-popupHeight/2);
|
||||||
|
|
||||||
$("#upload_box").css('left',objLeft).css('top',objTop);
|
$("#upload_box").css('left',objLeft).css('top',objTop);
|
||||||
$("#upload_box").html('<%= escape_javascript( render :partial => "resource_share_popup" ,:locals => {:courses=>@course,:user=>@user})%>');
|
$("#upload_box").html('<%= escape_javascript( render :partial => "resource_share_popup" ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
|
||||||
$("#upload_box").css('display','block');
|
$("#upload_box").css('display','block');
|
|
@ -7,5 +7,5 @@ var popupHeight = $(".resourceSharePopup").outerHeight(true);
|
||||||
$(".resourceSharePopup").css("marginTop",-popupHeight/2);
|
$(".resourceSharePopup").css("marginTop",-popupHeight/2);
|
||||||
|
|
||||||
$("#upload_box").css('left',objLeft).css('top',objTop);
|
$("#upload_box").css('left',objLeft).css('top',objTop);
|
||||||
$("#upload_box").html('<%= escape_javascript( render :partial => "resource_share_for_project_popup" ,:locals => {:projects=>@projects,:user=>@user})%>');
|
$("#upload_box").html('<%= escape_javascript( render :partial => "resource_share_for_project_popup" ,:locals => {:projects=>@projects,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
|
||||||
$("#upload_box").css('display','block');
|
$("#upload_box").css('display','block');
|
|
@ -96,8 +96,8 @@
|
||||||
<a href="javascript:void(0);" class="replyGrey" onclick="batch_delete();">删除</a>
|
<a href="javascript:void(0);" class="replyGrey" onclick="batch_delete();">删除</a>
|
||||||
<div class="resourcesSelectSend">
|
<div class="resourcesSelectSend">
|
||||||
<div class="fl">选择 <span class="c_red" id="res_count">0</span> 个资源</div>
|
<div class="fl">选择 <span class="c_red" id="res_count">0</span> 个资源</div>
|
||||||
<div class="resourcesSelectSendButton">
|
<div class="resourcesSelectSendButton" onclick="batch_send();">
|
||||||
<a href="javascript:void(0);" class="c_blue db" onclick="batch_send();">发送</a>
|
<a href="javascript:void(0);" class="sendButtonBlue db" >发送</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -261,9 +261,10 @@ $(".resourcesList").click(function(e) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function show_send(){
|
function show_send(){
|
||||||
$("#contextMenu").hide();
|
$("#contextMenu").hide();
|
||||||
document.oncontextmenu = function() {return true;}
|
document.oncontextmenu = function() {return true;}
|
||||||
|
@ -282,6 +283,20 @@ $(".resourcesList").click(function(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function batch_send(){
|
||||||
|
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
|
||||||
|
$.ajax({
|
||||||
|
type: 'get',
|
||||||
|
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$.ajax({
|
||||||
|
type: 'get',
|
||||||
|
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function preview(){
|
function preview(){
|
||||||
$("#contextMenu").hide();
|
$("#contextMenu").hide();
|
||||||
document.oncontextmenu = function() {return true;}
|
document.oncontextmenu = function() {return true;}
|
||||||
|
@ -375,23 +390,41 @@ $(".resourcesList").click(function(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function chooseSendType(){
|
//id 发送的id
|
||||||
|
//发送的id数组
|
||||||
|
function chooseSendType(res_id,res_ids){
|
||||||
|
|
||||||
sendType = $(".resourcesSendType").val();
|
sendType = $(".resourcesSendType").val();
|
||||||
if(sendType === lastSendType){
|
if (sendType === lastSendType) {
|
||||||
return;
|
return;
|
||||||
}else if(lastSendType != null){ //不是第一次点击的时候
|
} else if (lastSendType != null) { //不是第一次点击的时候
|
||||||
if(sendType === '1'){
|
if(res_ids == "") {//如果是单个发送
|
||||||
|
if (sendType === '1') {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:'get',
|
type: 'get',
|
||||||
url:'<%= search_user_course_user_path(@user)%>'+'?send_id='+id
|
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.ajax({
|
||||||
|
type: 'get',
|
||||||
|
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}else{//如果是多个发送
|
||||||
|
if (sendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
|
||||||
|
$.ajax({
|
||||||
|
type: 'get',
|
||||||
|
url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:'get',
|
type: 'get',
|
||||||
url:'<%= search_user_project_user_path(@user)%>'+'?send_id='+id
|
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lastSendType = sendType;
|
lastSendType = sendType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -490,7 +490,13 @@ a.resourcesBlack:hover {font-size:12px; color:#000000;}
|
||||||
.resourcesListOption {width:710px; height:40px; line-height:40px; vertical-align:middle; margin-left:auto; margin-right:auto; background-color:#f6f6f6;}
|
.resourcesListOption {width:710px; height:40px; line-height:40px; vertical-align:middle; margin-left:auto; margin-right:auto; background-color:#f6f6f6;}
|
||||||
.resourcesCheckAll {width:20px; height:40px; line-height:40px; text-align:center; vertical-align:middle; float:left;}
|
.resourcesCheckAll {width:20px; height:40px; line-height:40px; text-align:center; vertical-align:middle; float:left;}
|
||||||
.resourcesSelectSend {float:right;}
|
.resourcesSelectSend {float:right;}
|
||||||
|
/*.resourcesSelectSendButton {width:75px; height:28px; background-color:#ffffff; line-height:28px; vertical-align:middle; margin-top:5px; margin-right:10px; margin-left:15px; text-align:center; border:1px solid #15bccf; border-radius:5px; float:right;}*/
|
||||||
.resourcesSelectSendButton {width:75px; height:28px; background-color:#ffffff; line-height:28px; vertical-align:middle; margin-top:5px; margin-right:10px; margin-left:15px; text-align:center; border:1px solid #15bccf; border-radius:5px; float:right;}
|
.resourcesSelectSendButton {width:75px; height:28px; background-color:#ffffff; line-height:28px; vertical-align:middle; margin-top:5px; margin-right:10px; margin-left:15px; text-align:center; border:1px solid #15bccf; border-radius:5px; float:right;}
|
||||||
|
a.sendButtonBlue {color:#15bccf;}
|
||||||
|
a.sendButtonBlue:hover {color:#ffffff;}
|
||||||
|
.resourcesSelectSendButton:hover {background-color:#15bccf;}
|
||||||
|
.db {display:block;}
|
||||||
|
|
||||||
.dropdown-menu {
|
.dropdown-menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 100%;
|
top: 100%;
|
||||||
|
|
Loading…
Reference in New Issue