资源库
This commit is contained in:
parent
929da7512d
commit
76c2c47adf
|
@ -43,7 +43,8 @@ class UsersController < ApplicationController
|
|||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,
|
||||
:user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,:resource_preview,:resource_search]
|
||||
:user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,
|
||||
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
|
@ -878,6 +879,20 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 根据id或者名称搜索当前用户所在的项目
|
||||
def search_user_project
|
||||
@user = User.current
|
||||
if !params[:search].nil?
|
||||
@projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like '%#{params[:search.to_s]}%'")
|
||||
else
|
||||
@projects = @user.projects
|
||||
end
|
||||
@send_id = params[:send_id]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 将资源发送到对应的课程
|
||||
def add_exist_file_to_course
|
||||
send_id = params[:send_id]
|
||||
|
@ -903,6 +918,31 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 添加资源到对应的项目
|
||||
def add_exist_file_to_project
|
||||
send_id = params[: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
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 资源预览
|
||||
def resource_preview
|
||||
preview_id = params[:resource_id]
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
|
||||
<div class="resourceSharePopup">
|
||||
<div>
|
||||
<div class="sendText fl">将资源发送至</div>
|
||||
<div class="resourcesSendTo">
|
||||
<select class="resourcesSendType" onclick="chooseSendType();">
|
||||
<option value="1">课程</option>
|
||||
<option value="2" selected>项目</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>
|
||||
<div class="fl">
|
||||
<%= form_tag search_user_project_user_path(user),:method => 'get',
|
||||
:remote=>true,:id=>'search_user_project_form',:class=>'resourcesSearchBox' do %>
|
||||
<%= hidden_field_tag(:send_id, @send_id) %>
|
||||
<input type="text" name="search" placeholder="输入项目ID或者名称搜索" class="searchResourcePopup" />
|
||||
<!--<a href="javascript:void(0);" class="searchIconPopup"></a>-->
|
||||
<%= submit_tag '',:class=>'searchIconPopup',:onfocus=>"this.blur();",:style=>'border-style:none' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= form_tag add_exist_file_to_project_user_path(user),:remote=>true,:id=>'projects_list_form' %>
|
||||
<div>
|
||||
|
||||
<%= hidden_field_tag(:send_id, @send_id) %>
|
||||
<% if !projects.empty? %>
|
||||
<% projects.each do |project| %>
|
||||
<ul class="courseSend fl">
|
||||
<li class="fl">
|
||||
<input name="projects_ids[]" type="checkbox" value="<%= project.id %>" class="courseSendCheckbox"/>
|
||||
</li>
|
||||
<li class="sendCourseName fl"><%= truncate( project.name,:length=>18)%></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<div class="courseSendSubmit">
|
||||
<!--<a href="javascript:void(0);" class="sendSourceText">确定</a>-->
|
||||
<%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();' %>
|
||||
</div>
|
||||
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="closeModal();">取消</a></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
<div>
|
||||
<div class="sendText fl">将资源发送至</div>
|
||||
<div class="resourcesSendTo">
|
||||
<select class="resourcesSendType">
|
||||
<option value="课程">课程</option>
|
||||
<option value="项目">项目</option>
|
||||
<select class="resourcesSendType" onclick="chooseSendType();">
|
||||
<option value="1">课程</option>
|
||||
<option value="2">项目</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<li class="fl">
|
||||
<input name="course_ids[]" type="checkbox" value="<%= course.id %>" class="courseSendCheckbox"/>
|
||||
</li>
|
||||
<li class="sendCourseName fl"><%= course.name%></li>
|
||||
<li class="sendCourseName fl"><%= truncate(course.name,:length=>18)%></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
alert('发送成功')
|
||||
closeModal();
|
|
@ -0,0 +1,2 @@
|
|||
alert('发送成功');
|
||||
closeModal();
|
|
@ -0,0 +1,11 @@
|
|||
var screenWidth = $(window).width();
|
||||
var screenHeight = $(window).height(); //当前浏览器窗口的 宽高
|
||||
var scrolltop = $(document).scrollTop();//获取当前窗口距离页面顶部高度
|
||||
var objLeft = (screenWidth - 2)/2.5 ; //2 可以根据需要修改
|
||||
var objTop = (screenHeight - 100)/2 + scrolltop; //100可以根据需要修改
|
||||
var popupHeight = $(".resourceSharePopup").outerHeight(true);
|
||||
$(".resourceSharePopup").css("marginTop",-popupHeight/2);
|
||||
|
||||
$("#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").css('display','block');
|
|
@ -3,7 +3,11 @@
|
|||
<%= stylesheet_link_tag 'project' %>
|
||||
<%= stylesheet_link_tag 'leftside' %>
|
||||
<%= javascript_include_tag 'attachments'%>
|
||||
|
||||
<!--<script type="text/css">-->
|
||||
<!--html,body{ overflow-y:scroll;}-->
|
||||
<!--html,body{ overflow:scroll; min-height:101%;}-->
|
||||
<!--html{ overflow:-moz-scrollbars-vertical;}-->
|
||||
<!--</script>-->
|
||||
<script>
|
||||
function remote_get_resources(user_id,type){
|
||||
|
||||
|
@ -117,6 +121,8 @@
|
|||
//资源名称的链接
|
||||
var res_link;
|
||||
var id; //资源id
|
||||
var sendType; //发送到课程 1 发送到项目 2
|
||||
var lastSendType; //保存上次发送的发送类型
|
||||
$(".resourcesList").mousedown(function(e) {
|
||||
//如果是右键的话
|
||||
if (3 == e.which) {
|
||||
|
@ -178,10 +184,17 @@ $(".resourcesList").click(function(e) {
|
|||
document.oncontextmenu = function() {return true;}
|
||||
line.children().css("background-color",'white');
|
||||
id = line.children().last().html();
|
||||
$.ajax({
|
||||
type:'get',
|
||||
url:'<%= search_user_course_user_path(@user)%>'+'?send_id='+id
|
||||
});
|
||||
if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
|
||||
});
|
||||
}else{
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function preview(){
|
||||
|
@ -277,5 +290,25 @@ $(".resourcesList").click(function(e) {
|
|||
}
|
||||
}
|
||||
|
||||
function chooseSendType(){
|
||||
sendType = $(".resourcesSendType").val();
|
||||
if(sendType === lastSendType){
|
||||
return;
|
||||
}else if(lastSendType != null){ //不是第一次点击的时候
|
||||
if(sendType === '1'){
|
||||
$.ajax({
|
||||
type:'get',
|
||||
url:'<%= search_user_course_user_path(@user)%>'+'?send_id='+id
|
||||
});
|
||||
}else{
|
||||
$.ajax({
|
||||
type:'get',
|
||||
url:'<%= search_user_project_user_path(@user)%>'+'?send_id='+id
|
||||
});
|
||||
}
|
||||
}
|
||||
lastSendType = sendType;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
|
|
@ -350,8 +350,10 @@ RedmineApp::Application.routes.draw do
|
|||
post "user_resource_delete"
|
||||
get "search_user_course"
|
||||
post "add_exist_file_to_course"
|
||||
post "add_exist_file_to_project"
|
||||
get 'resource_preview'
|
||||
post 'rename_resource'
|
||||
get 'search_user_project'
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue