multiple file upload
git-svn-id: http://redmine.rubyforge.org/svn/trunk@40 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0778ac8c1b
commit
55dded8e5f
|
@ -101,12 +101,11 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_attachment
|
def add_attachment
|
||||||
# Save the attachment
|
# Save the attachments
|
||||||
if params[:attachment][:file].size > 0
|
params[:attachments].each { |a|
|
||||||
@attachment = @issue.attachments.build(params[:attachment])
|
@attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
|
||||||
@attachment.author_id = self.logged_in_user.id if self.logged_in_user
|
|
||||||
@attachment.save
|
@attachment.save
|
||||||
end
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
redirect_to :action => 'show', :id => @issue
|
redirect_to :action => 'show', :id => @issue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -187,11 +187,10 @@ class ProjectsController < ApplicationController
|
||||||
else
|
else
|
||||||
@issue.attributes = params[:issue]
|
@issue.attributes = params[:issue]
|
||||||
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
@issue.author_id = self.logged_in_user.id if self.logged_in_user
|
||||||
# Create the document if a file was sent
|
# Multiple file upload
|
||||||
if params[:attachment][:file].size > 0
|
params[:attachments].each { |a|
|
||||||
@attachment = @issue.attachments.build(params[:attachment])
|
@attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
|
||||||
@attachment.author_id = self.logged_in_user.id if self.logged_in_user
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
end
|
|
||||||
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
@custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
|
||||||
@issue.custom_values = @custom_values
|
@issue.custom_values = @custom_values
|
||||||
if @issue.save
|
if @issue.save
|
||||||
|
|
|
@ -77,18 +77,6 @@ end %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if authorize_for('issues', 'add_note') %>
|
|
||||||
<div class="box">
|
|
||||||
<h3><%= l(:label_add_note) %></h3>
|
|
||||||
<%= start_form_tag ({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) %>
|
|
||||||
<p><label for="history_notes"><%=l(:field_notes)%></label>
|
|
||||||
<%= text_area 'history', 'notes', :cols => 60, :rows => 10 %></p>
|
|
||||||
<%= submit_tag l(:button_add) %>
|
|
||||||
<%= end_form_tag %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="splitcontentleft">
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h3><%=l(:label_history)%></h3>
|
<h3><%=l(:label_history)%></h3>
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
|
@ -104,9 +92,7 @@ end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="splitcontentright">
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h3><%=l(:label_attachment_plural)%></h3>
|
<h3><%=l(:label_attachment_plural)%></h3>
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
|
@ -127,11 +113,22 @@ end %>
|
||||||
</table>
|
</table>
|
||||||
<br />
|
<br />
|
||||||
<% if authorize_for('issues', 'add_attachment') %>
|
<% if authorize_for('issues', 'add_attachment') %>
|
||||||
<%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true) %>
|
<%= start_form_tag ({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular") %>
|
||||||
<%=l(:label_attachment_new)%>: <%= file_field 'attachment', 'file' %>
|
<p id="attachments_p"><label><%=l(:label_attachment_new)%>
|
||||||
|
<%= link_to_function image_tag('add', :align => "top"), "addFileField()" %></label>
|
||||||
|
<%= file_field_tag 'attachments[]', :size => 30 %></p>
|
||||||
<%= submit_tag l(:button_add) %>
|
<%= submit_tag l(:button_add) %>
|
||||||
<%= end_form_tag %>
|
<%= end_form_tag %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<% if authorize_for('issues', 'add_note') %>
|
||||||
|
<div class="box">
|
||||||
|
<h3><%= l(:label_add_note) %></h3>
|
||||||
|
<%= start_form_tag ({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) %>
|
||||||
|
<p><label for="history_notes"><%=l(:field_notes)%></label>
|
||||||
|
<%= text_area 'history', 'notes', :cols => 60, :rows => 10 %></p>
|
||||||
|
<%= submit_tag l(:button_add) %>
|
||||||
|
<%= end_form_tag %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
<p><%= custom_field_tag_with_label @custom_value %></p>
|
<p><%= custom_field_tag_with_label @custom_value %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p><label for="attachment_file"><%=l(:label_attachment)%></label>
|
<p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
|
||||||
<%= file_field 'attachment', 'file' %></p>
|
<%= link_to_function image_tag('add', :align => "top"), "addFileField()" %></label>
|
||||||
|
<%= file_field_tag 'attachments[]', :size => 30 %></p>
|
||||||
<!--[eoform:issue]-->
|
<!--[eoform:issue]-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,15 @@ function checkAll (id, checked) {
|
||||||
el.elements[i].checked = checked;
|
el.elements[i].checked = checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFileField() {
|
||||||
|
var f = document.createElement("input");
|
||||||
|
f.type = "file";
|
||||||
|
f.name = "attachments[]";
|
||||||
|
f.size = 30;
|
||||||
|
|
||||||
|
p = document.getElementById("attachments_p");
|
||||||
|
p.appendChild(document.createElement("br"));
|
||||||
|
p.appendChild(f);
|
||||||
}
|
}
|
|
@ -198,6 +198,7 @@ textarea {
|
||||||
|
|
||||||
input {
|
input {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.button-small
|
input.button-small
|
||||||
|
|
Loading…
Reference in New Issue