From bdf423bc81a4c1a854fdd1d3e02fbad87e247e19 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 8 Nov 2016 09:21:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91issue=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8A=E4=BC=A0=E7=9A=84=E9=99=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=9C=AA=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_form.html.erb | 64 +------------------ .../attachments/_form_attachments.html.erb | 58 +++++++++++++++++ app/views/attachments/destroy.js.erb | 6 +- 3 files changed, 66 insertions(+), 62 deletions(-) create mode 100644 app/views/attachments/_form_attachments.html.erb diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 62ad9d02a..f5b5692f3 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -2,64 +2,6 @@ input.is_public,input.is_public_checkbox{height:12px;} input.is_public_checkbox{margin-left:4px;margin-right:4px;} -
- -<% if defined?(container) && container && container.saved_attachments %> - <% container.attachments.each_with_index do |attachment, i| %> - - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly hidden', :readonly => 'readonly', :style=>'border:none; width:460px;') %> - - <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> - - <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> - <%= if attachment.id.nil? - #待补充代码 - else - link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') - end - %> - <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> - - <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - -
- <% end %> - -<% end %> -
- <% project = project %> -
- - <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> - - <%= button_tag "上传附件", :id => "upload_attachments", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> - <%= file_field_tag 'attachments[dummy][file]', - :id => '_file', - :class => 'file_selector', - :multiple => true, - :onchange => 'addInputFiles(this);', - :style => ie8? ? '' : 'display:none', - :data => { - :max_file_size => Setting.attachment_max_size.to_i.kilobytes, - :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), - :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, - :upload_path => uploads_path(:format => 'js', :project => project), - :description_placeholder => l(:label_optional_description), - :field_is_public => l(:field_is_public), - :are_you_sure => l(:text_are_you_sure), - :file_count => l(:label_file_count), - :lebel_file_uploding => l(:lebel_file_uploding), - :delete_all_files => l(:text_are_you_sure_all) - } %> - - <%= l(:label_no_file_uploaded) %> - - (<%= l(:label_max_size) %>: - <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) - - - <% content_for :header_tags do %> - <%= javascript_include_tag 'attachments' %> - <% end %> -
- +
+ <%= render :partial=>'attachments/form_attachments', :locals => { :container => container }%> +
\ No newline at end of file diff --git a/app/views/attachments/_form_attachments.html.erb b/app/views/attachments/_form_attachments.html.erb new file mode 100644 index 000000000..db4ba070c --- /dev/null +++ b/app/views/attachments/_form_attachments.html.erb @@ -0,0 +1,58 @@ + +<% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly hidden', :readonly => 'readonly', :style=>'border:none; width:460px;') %> + + <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> + + <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
+ <% end %> + +<% end %> +
+<% project = project %> +
+ + <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> + + <%= button_tag "上传附件", :id => "upload_attachments", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => ie8? ? '' : 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js', :project => project), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :lebel_file_uploding => l(:lebel_file_uploding), + :delete_all_files => l(:text_are_you_sure_all) + } %> + + <%= l(:label_no_file_uploaded) %> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + +<% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> +<% end %> \ No newline at end of file diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb index 97d3fd3ec..8bb2ab2cc 100644 --- a/app/views/attachments/destroy.js.erb +++ b/app/views/attachments/destroy.js.erb @@ -12,6 +12,10 @@ $("#attachment_history_popub").html('<%= escape_javascript( render :partial => ' $("#attachment_history_popub").html('<%= escape_javascript( render :partial => 'files/attachment_history_popub') %>'); <% end %> +<% if params[:attachment_id] %> +$("#issue_upload_attachments").html('<%= escape_javascript( render :partial => 'attachments/form_attachments', :locals => { :container => @attachment.container }) %>'); +<% end %> + <% if @is_destroy%> $("#attachment_<%= @attachment.id%>").remove(); if(document.getElementById("revise_attachment_div_<%= @attachment.id%>")) { @@ -49,4 +53,4 @@ $("#attachment_history_popub").html('<%= escape_javascript( render :partial => ' $("#choose_revise_attach").attr("onclick","_file.click();"); } //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end -<% end%> \ No newline at end of file +<% end%>