From db63a5514dfdc608940a78d8a025bb118c992dbc Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 14 Oct 2016 13:45:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90=E5=BA=93?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E5=8F=8A?= =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 32 +++++--- .../_show_attachment_history.html.erb | 75 +++---------------- .../_upload_attachment_new_version.html.erb | 8 +- .../attachments/attachment_versions.js.erb | 18 +++-- app/views/attachments/destroy.js.erb | 5 ++ .../files/_attachment_history_popub.html.erb | 57 ++++++++++++++ app/views/layouts/base_projects.html.erb | 2 +- public/stylesheets/css/moduel.css | 59 +++++++++++++++ public/stylesheets/css/project.css | 5 +- 9 files changed, 174 insertions(+), 87 deletions(-) create mode 100644 app/views/files/_attachment_history_popub.html.erb create mode 100644 public/stylesheets/css/moduel.css diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3986acc0a..752ff985f 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -329,20 +329,33 @@ class AttachmentsController < ApplicationController end end + # prams[:type] => history 历史版本 def destroy - if @attachment.container.respond_to?(:init_journal) - @attachment.container.init_journal(User.current) - end - if @attachment.container - if @attachment.container_type == "Issue" - @attachment.destroy - else - @attachment.container.attachments.delete(@attachment) + if params[:type] == "history" + begin + AttachmentHistory.find(params[:history_id]).destroy + @attachment = Attachment.find(params[:id]) + @is_history = true + @attachment_histories = @attachment.attachment_histories + rescue Exception => e + puts e end else - @attachment.destroy + if @attachment.container.respond_to?(:init_journal) + @attachment.container.init_journal(User.current) + end + if @attachment.container + if @attachment.container_type == "Issue" + @attachment.destroy + else + @attachment.container.attachments.delete(@attachment) + end + else + @attachment.destroy + end end + respond_to do |format| if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) && @@ -631,6 +644,7 @@ class AttachmentsController < ApplicationController #找到文件的所有的历史版本 def attachment_versions + @project = Project.find(params[:project_id]) @attachment = Attachment.find(params[:id]) @attachment_histories = @attachment.attachment_histories respond_to do |format| diff --git a/app/views/attachments/_show_attachment_history.html.erb b/app/views/attachments/_show_attachment_history.html.erb index db2cbdec6..9a1a278fc 100644 --- a/app/views/attachments/_show_attachment_history.html.erb +++ b/app/views/attachments/_show_attachment_history.html.erb @@ -1,66 +1,11 @@ - -更新资源版本 - -
-
-
当前版本 - - - -
- <% unless @attachment_histories.empty? %> - -
历史版本
-
- <% @attachment_histories.each do |history| %> - - <%= 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 f_14 f_b upload_filename fl" %> - 版本号:<%= history.version %> -
-
- - <% end %> -
- <% end %> - -
- <%= form_tag(upload_attachment_version_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %> - <%= hidden_field_tag :old_attachment_id,@attachment.id %> -
- - -
-
- - <%= render :partial => 'attachments/upload_attachment_new_version' %> -
- - -
-
- (未选择文件) - 您可以上传小于50MB的文件 -
-
-
-

描述:

-
- -
-
-
-
-
-
-
-
- - <%= submit_tag '确定',:onclick=>'upload_attachment_version(event);',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %> -
- -
- <% end %> +
+

更新资源版本

+
- \ No newline at end of file +
+
+ +
+ <%= render :partial => "files/attachment_history_popub" %> +
+
diff --git a/app/views/attachments/_upload_attachment_new_version.html.erb b/app/views/attachments/_upload_attachment_new_version.html.erb index cd35535c0..0e03bab47 100644 --- a/app/views/attachments/_upload_attachment_new_version.html.erb +++ b/app/views/attachments/_upload_attachment_new_version.html.erb @@ -1,8 +1,8 @@ +
+ 文件浏览 +

(未选择文件) 您可以上传小于50MB的文件

+
- - - - 选择文件 <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => ie8? ? '':'file_selector', diff --git a/app/views/attachments/attachment_versions.js.erb b/app/views/attachments/attachment_versions.js.erb index ff704a869..c924c542a 100644 --- a/app/views/attachments/attachment_versions.js.erb +++ b/app/views/attachments/attachment_versions.js.erb @@ -1,7 +1,11 @@ -$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/show_attachment_history' )%>'); -showModal('ajax-modal', '452px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); -$('#ajax-modal').parent().css("top","40%").css("left","50%").css("position","fixed"); -$('#ajax-modal').parent().addClass("resourceUploadPopup"); -$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); \ No newline at end of file +//$("#ajax-modal").html('<%#= escape_javascript( render :partial => 'attachments/show_attachment_history' )%>'); +//showModal('ajax-modal', '452px'); +//$('#ajax-modal').siblings().remove(); +//$('#ajax-modal').before(""); +//$('#ajax-modal').parent().css("top","40%").css("left","50%").css("position","fixed"); +//$('#ajax-modal').parent().addClass("resourceUploadPopup"); +//$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); + + +var htmlvalue = "<%= escape_javascript(render :partial => 'attachments/show_attachment_history') %>"; +pop_box_new(htmlvalue,820,360); \ No newline at end of file diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb index 02a613e6e..310ad74d5 100644 --- a/app/views/attachments/destroy.js.erb +++ b/app/views/attachments/destroy.js.erb @@ -1,3 +1,8 @@ +//历史版本删除局部刷新 +<% if @is_history %> +$("#attachment_history_popub").html('<%= escape_javascript( render :partial => 'files/attachment_history_popub') %>'); +<% end %> + <% if @is_destroy%> $("#attachment_<%= @attachment.id%>").remove(); if(document.getElementById("revise_attachment_div_<%= @attachment.id%>")) { diff --git a/app/views/files/_attachment_history_popub.html.erb b/app/views/files/_attachment_history_popub.html.erb new file mode 100644 index 000000000..871264f5a --- /dev/null +++ b/app/views/files/_attachment_history_popub.html.erb @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + <% @attachment_histories.each do |history| %> + + + + + + + + <% end %> + +
资源名称下载数引用数版本号
<%= @attachment.downloads %><%= @attachment.quotes %><%= format_time(@attachment.created_on) %>
+ <%= history.downloads %><%= history.try(:quotes).to_i %><%= format_time(history.created_on) %> + <%= link_to( '删除资源', attachment_path(history.attachment, :history_id => history, :type => "history"), + :remote => true, + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete,:class => "postOptionLink", + :class => "btn") if (is_project_manager?(User.current.id, @project.id) || User.current.id == history.author_id) %> +
+<%= form_tag(upload_attachment_version_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %> + <%= hidden_field_tag :old_attachment_id,@attachment.id %> +
+ + +
+
+ + <%= render :partial => 'attachments/upload_attachment_new_version' %> +
+ + +
+
+ +
+ <%= submit_tag '确定', :onclick => 'upload_attachment_version(event);', :onfocus => 'this.blur()', :id => 'upload_files_submit_btn', :class => 'btn btn-blue fr mr5' %> + 取消 +
+<% end %> \ No newline at end of file diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index fced40737..218ef3fcf 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -12,7 +12,7 @@ <%= favicon %> <%= javascript_heads %> <%= heads_for_theme %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/structure','scm','css/public', 'css/project','css/popup','prettify','repository','css/gantt', 'css/calendar' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/structure','scm','css/public', 'css/project','css/popup','prettify','repository','css/gantt', 'css/calendar', "css/moduel" %> <%= javascript_include_tag 'cookie','project',"avatars", 'header','prettify','select_list_move','attachments' %> <%= call_hook :view_layouts_base_html_head %> diff --git a/public/stylesheets/css/moduel.css b/public/stylesheets/css/moduel.css new file mode 100644 index 000000000..1e2250de8 --- /dev/null +++ b/public/stylesheets/css/moduel.css @@ -0,0 +1,59 @@ +/* 模板弹框 20161013byLB */ +#muban_popup_box{ background:#fff;padding-bottom:15px;-webkit-border-radius:5px;-moz-border-radius:5px;-o-border-radius:5px;border-radius:5px;box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5);} +.muban_popup_top{background:#3b94d6;height:40px;-webkit-border-radius: 5px 5px 0px 0px;-moz-border-radius: 5px 5px 0px 0px;-o-border-radius: 5px 5px 0px 0px;border-radius: 5px 5px 0px 0px;} +.muban_popup_top h3{ font-size:16px; color:#fff; font-weight:normal; line-height:40px; padding-left:10px; } +a.muban_icons_close{width:20px; height:20px;display:block;background: url(/images/sy/sy_icons_close.png) 0 0px no-repeat; margin:8px 10px 0 0;} +a:hover.muban_icons_close{background: url(/images/sy/sy_icons_close.png) -40px 0px no-repeat;} +/*模板表格 20161013byLB*/ +.muban_table{ width:100%; background:#fff; border:1px solid #e5e5e5; border-bottom: none; } +.muban_table thead tr{ height:40px; line-height:40px;} +.muban_table thead tr th{ border-bottom:1px solid #e5e5e5;} +.muban_table tbody tr:hover{ background:#f5f5f5;} +.muban_table tbody tr th{ height:40px; line-height:40px; border-bottom:1px solid #e5e5e5; font-weight:normal; color:#888;} +/*模板icons 20161013byLB*/ +.muban_icons_orange{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #ff4a1b;border: 1px solid #ff4a1b;} +.muban_icons_blue{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #3b94d6;border: 1px solid #3b94d6;} +/*模板buttons 20161013byLB*/ +.btn{display: inline-block;border:none; padding:0 10px;color: #333;background: #e1e1e1; text-align:center;font-size: 12px; height: 30px;line-height: 30px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; } +.btn:hover{background: #c3c3c3; color: #333;} +.btn-green{background: #60b25e; color: #fff;} +.btn-green:hover{background: #51a74f; color: #fff;} +.btn-blue{background: #3b94d6; color: #fff;} +.btn-blue:hover{background: #2788d0; color: #fff;} +.btn-orange{background:#ff7b33; color: #fff;} +.btn-orange:hover{background:#ee4a1f; color: #fff;} +.btn-line{display: inline-block;border:none; padding:0 10px;color: #333;background:#fff; border: 1px solid #d5d5d5; text-align:center;font-size: 12px; height: 30px;line-height: 30px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; } +.btn-line:hover{background:#eee; } +.btn-line-green{border: 1px solid #51a74f; color: #51a74f;} +.btn-line-green:hover{ background: #51a74f; color: #fff;} +.btn-line-blue{border: 1px solid #2788d0; color: #2788d0;} +.btn-line-blue:hover{ background: #2788d0; color: #fff;} +.btn-line-orange{border: 1px solid #ee4a1f; color: #ee4a1f;} +.btn-line-orange:hover{ background: #ee4a1f; color: #fff;} +.btn-small{ padding: 0px 10px; font-size: 12px;line-height: 20px; background-image: linear-gradient(#fcfcfc, #eee); border: 1px solid #d5d5d5;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; color: #333;} +.btn-small:hover{background-image:linear-gradient(#ededed, #dddddd);} +.sub_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #707070; color:#000; border-radius:3px; padding:1px 10px; background:#dbdbdb;} +.sub_btn:hover{ background:#b5e2fa; color:#000; border:1px solid #3c7fb1;} +/*模板a标签按钮 20161013byLB*/ +a.btn{display: inline-block;border:none; padding:0 10px;color: #333;background: #e1e1e1; text-align:center;font-size: 12px; height: 30px;line-height: 30px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; } +a:hover.btn{background: #c3c3c3; color: #333;} +a.btn-green{background: #60b25e; color: #fff;} +a:hover.btn-green{background: #51a74f; color: #fff;} +a.btn-blue{background: #3b94d6; color: #fff;} +a:hover.btn-blue{background: #2788d0; color: #fff;} +a.btn-orange{background:#ff7b33; color: #fff;} +a:hover.btn-orange:hover{background:#ee4a1f; color: #fff;} +a.btn-line{display: inline-block;border:none; padding:0 10px;color: #333;background:#fff; border: 1px solid #d5d5d5; text-align:center;font-size: 12px; height: 30px;line-height: 30px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; } +a:hover.btn-line{background:#eee; } +a.btn-line-green{border: 1px solid #51a74f; color: #51a74f;} +a:hover.btn-line-green{ background: #51a74f; color: #fff;} +a.btn-line-blue{border: 1px solid #2788d0; color: #2788d0;} +a:hover.btn-line-blue{ background: #2788d0; color: #fff;} +a.btn-line-orange{border: 1px solid #ee4a1f; color: #ee4a1f;} +a:hover.btn-line-orange{ background: #ee4a1f; color: #fff;} +a.btn-small{ padding: 0px 10px; font-size: 12px;line-height: 20px; background-image: linear-gradient(#fcfcfc, #eee); border: 1px solid #d5d5d5;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; color: #333;} +a:hover.btn-small{background-image:linear-gradient(#ededed, #dddddd);} +a.sub_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #707070; color:#000; border-radius:3px; padding:1px 10px; background:#dbdbdb;} +a:hover.sub_btn{ background:#b5e2fa; color:#000; border:1px solid #3c7fb1;} +/*模板form 20161013byLB*/ +textarea.muban_textarea{ width: 98.5%;border:1px solid #ddd; background:#fff; color:#666; padding:5px;} diff --git a/public/stylesheets/css/project.css b/public/stylesheets/css/project.css index 44b607b3b..e0fc22960 100644 --- a/public/stylesheets/css/project.css +++ b/public/stylesheets/css/project.css @@ -894,4 +894,7 @@ a.sy_btn_pink{ -o-border-radius:3px; border-radius:3px; } -a:hover.sy_btn_pink{ background: #e64c4c;} \ No newline at end of file +a:hover.sy_btn_pink{ background: #e64c4c;} + +/*项目历史版本删除功能*/ +.popup_ziyuan_title{ display: block; margin-left: 10px; text-align: left;width:360px; overflow:hidden;white-space: nowrap; text-overflow:ellipsis;}