diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-10 20:09:41 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-12-10 20:09:41 +0000 |
commit | ef25210aca9278e51f81bd15e85a3143c667ff17 (patch) | |
tree | 312d20360571770a231f4fd307c12d0c535d60f2 /app/views | |
parent | 2304f5d42c2bb1829b1cf9055c2848db116742d3 (diff) | |
download | redmine-ef25210aca9278e51f81bd15e85a3143c667ff17.tar.gz redmine-ef25210aca9278e51f81bd15e85a3143c667ff17.zip |
Merged ajax_upload branch (#3957).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10977 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/attachments/_form.html.erb | 34 | ||||
-rw-r--r-- | app/views/attachments/destroy.js.erb | 1 | ||||
-rw-r--r-- | app/views/attachments/upload.js.erb | 9 | ||||
-rw-r--r-- | app/views/common/_preview.html.erb | 2 | ||||
-rw-r--r-- | app/views/previews/issue.html.erb | 4 |
5 files changed, 35 insertions, 15 deletions
diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index e47c288a9..092f68244 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -1,18 +1,28 @@ +<span id="attachments_fields"> <% if defined?(container) && container && container.saved_attachments %> <% container.saved_attachments.each_with_index do |attachment, i| %> - <span class="icon icon-attachment" style="display:block; line-height:1.5em;"> - <%= h(attachment.filename) %> (<%= number_to_human_size(attachment.filesize) %>) - <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.id}.#{attachment.digest}" %> + <span id="attachments_p<%= i %>"> + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename') + + text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description') + + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> </span> <% end %> <% end %> -<span id="attachments_fields"> - <span> - <%= file_field_tag 'attachments[1][file]', :id => nil, :class => 'file', - :onchange => "checkFileSize(this, #{Setting.attachment_max_size.to_i.kilobytes}, '#{escape_javascript(l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)))}');" -%> - <%= text_field_tag 'attachments[1][description]', '', :id => nil, :class => 'description', :maxlength => 255, :placeholder => l(:label_optional_description) %> - <%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %> - </span> </span> -<span class="add_attachment"><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;', :class => 'add_attachment' %> -(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</span> +<span class="add_attachment"> +<%= file_field_tag 'attachments_files', + :id => nil, + :multiple => true, + :onchange => 'addInputFiles(this);', + :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'), + :description_placeholder => l(:label_optional_description) + } %> +(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) +</span> + +<%= javascript_include_tag 'attachments' %> diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb new file mode 100644 index 000000000..3cfb5845f --- /dev/null +++ b/app/views/attachments/destroy.js.erb @@ -0,0 +1 @@ +$('#attachments_<%= j params[:attachment_id] %>').remove(); diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb new file mode 100644 index 000000000..04e30b569 --- /dev/null +++ b/app/views/attachments/upload.js.erb @@ -0,0 +1,9 @@ +var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); +$('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); +fileSpan.find('a.remove-upload') + .attr({ + "data-remote": true, + "data-method": 'delete', + href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' + }) + .off('click'); diff --git a/app/views/common/_preview.html.erb b/app/views/common/_preview.html.erb index fd95f1188..90d83ce8c 100644 --- a/app/views/common/_preview.html.erb +++ b/app/views/common/_preview.html.erb @@ -1,3 +1,3 @@ <fieldset class="preview"><legend><%= l(:label_preview) %></legend> -<%= textilizable @text, :attachments => @attachements, :object => @previewed %> +<%= textilizable @text, :attachments => @attachments, :object => @previewed %> </fieldset> diff --git a/app/views/previews/issue.html.erb b/app/views/previews/issue.html.erb index 60ad2a0ad..a88bec6fc 100644 --- a/app/views/previews/issue.html.erb +++ b/app/views/previews/issue.html.erb @@ -1,11 +1,11 @@ <% if @notes %> <fieldset class="preview"><legend><%= l(:field_notes) %></legend> - <%= textilizable @notes, :attachments => @attachements, :object => @issue %> + <%= textilizable @notes, :attachments => @attachments, :object => @issue %> </fieldset> <% end %> <% if @description %> <fieldset class="preview"><legend><%= l(:field_description) %></legend> - <%= textilizable @description, :attachments => @attachements, :object => @issue %> + <%= textilizable @description, :attachments => @attachments, :object => @issue %> </fieldset> <% end %> |