课程资源库提供历史版本下载
This commit is contained in:
parent
0a881f14e8
commit
7ff946e488
|
@ -572,6 +572,15 @@ class AttachmentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#找到文件的所有的历史版本及当前版本
|
||||
def attachment_history_download
|
||||
@attachment = Attachment.find(params[:id])
|
||||
@attachment_histories = @attachment.attachment_histories
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_project
|
||||
@attachment = Attachment.find(params[:id])
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".popupClose").click(function(){
|
||||
$(".popupWrap").css("display","none");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<span class="f16 fontBlue fb">选择版本 </span>
|
||||
<p class="c_red">注:该文件有历史版本,请选择您需要的文件,点击文件名下载。</p>
|
||||
<p class="fontGrey3 mb4 fb">版本及序号</p>
|
||||
|
||||
<div style="max-height:165px; overflow-y:auto; background-color: #e3e3e3; line-height:33px;" class="p10">
|
||||
<span class="attachment">
|
||||
<%= link_to truncate(@attachment.filename,length: 35, omission: '...'),
|
||||
download_named_attachment_path(@attachment.id, @attachment.filename),
|
||||
:title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
|
||||
</span>
|
||||
<span class="fr">版本号:当前</span>
|
||||
|
||||
<% @attachment_histories.each do |history| %>
|
||||
<span class="attachment">
|
||||
<%= link_to truncate(history.filename,length: 35, omission: '...'),
|
||||
download_history_attachment_path(history.id, history.filename),
|
||||
:title => history.filename+"\n"+history.description.to_s,
|
||||
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
|
||||
</span>
|
||||
|
||||
<span class="fr">版本号:<%= history.version %></span>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,7 @@
|
|||
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>');
|
||||
showModal('ajax-modal', '452px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
|
||||
$('#ajax-modal').parent().css("top","40%").css("left","50%");
|
||||
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
|
|
@ -6,9 +6,17 @@
|
|||
</div>
|
||||
<div class="homepagePostDes">
|
||||
<div class="homepagePostTitle break_word mt-4">
|
||||
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
||||
download_named_attachment_path(file.id, file.filename),
|
||||
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
|
||||
<%# 如果有历史版本则提供历史版本下载 %>
|
||||
<% if file.attachment_histories.count == 0 %>
|
||||
<%= link_to truncate(file.filename,length: 35, omission: '...'),
|
||||
download_named_attachment_path(file.id, file.filename),
|
||||
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
|
||||
<% else %>
|
||||
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
|
||||
:title => file.filename+"\n"+file.description.to_s,
|
||||
:class => "linkGrey3 f_14",
|
||||
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
|
||||
<% end %>
|
||||
<%= file_preview_eye(file, class: 'preview') %>
|
||||
<span id="image_private_<%= file.id%>">
|
||||
<% if file.is_public? == false%>
|
||||
|
@ -38,31 +46,28 @@
|
|||
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
||||
</div>
|
||||
<div class="homepagePostSetting">
|
||||
|
||||
<ul>
|
||||
<li class="homepagePostSettingIcon">
|
||||
<% if User.current.logged? %>
|
||||
|
||||
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
|
||||
<% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
|
||||
<ul class="homepagePostSettiongText">
|
||||
|
||||
<li><%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>
|
||||
<li><%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %></li>
|
||||
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
|
||||
<% if @course.is_public? %>
|
||||
<li>
|
||||
<span id="is_public_<%= file.id %>">
|
||||
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
|
||||
</span>
|
||||
<span id="is_public_<%= file.id %>">
|
||||
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
|
||||
</span>
|
||||
</li>
|
||||
<%end%>
|
||||
<li>
|
||||
<%= link_to( '删除资源', attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
|
||||
:data => {:confirm => l(:text_are_you_sure)},
|
||||
:method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<% end %>
|
||||
<%else%>
|
||||
<ul class="resourceSendO">
|
||||
|
|
|
@ -319,7 +319,7 @@
|
|||
}
|
||||
|
||||
})
|
||||
|
||||
//资源库上传附件
|
||||
function course_files_upload(){
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_course_files',:locals => {:course => @course,:course_attachment_type => 1}) %>');
|
||||
showModal('ajax-modal', '513px');
|
||||
|
|
|
@ -876,6 +876,7 @@ RedmineApp::Application.routes.draw do
|
|||
# additional routes for having the file name at the end of url
|
||||
get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
|
||||
get 'attachments/attachment_versions/:id',:to=>'attachments#attachment_versions',:as=>'attachments_versions'
|
||||
get 'attachments/attachment_history_download/:id',:to=>'attachments#attachment_history_download',:as=>'attachment_history_download'
|
||||
post 'attachments/upload_attachment_version',:to=>'attachments#upload_attachment_version',:as=>'upload_attachment_version'
|
||||
get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
|
||||
get 'attachments/download_history/:id/:filename', :to => 'attachments#download_history', :id => /\d+/, :filename => /.*/, :as => 'download_history_attachment'
|
||||
|
|
|
@ -1432,3 +1432,4 @@ function submit_course_feedback() {
|
|||
function show_more_tool(){
|
||||
$('#navContentCourse').css('display', 'block');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue