@@ -86,6 +86,15 class IssuesController < ApplicationController | |||||
86 | journal = @issue.init_journal(self.logged_in_user, params[:notes]) |
|
86 | journal = @issue.init_journal(self.logged_in_user, params[:notes]) | |
87 | @issue.status = @new_status |
|
87 | @issue.status = @new_status | |
88 | if @issue.update_attributes(params[:issue]) |
|
88 | if @issue.update_attributes(params[:issue]) | |
|
89 | # Save attachments | |||
|
90 | params[:attachments].each { |file| | |||
|
91 | next unless file.size > 0 | |||
|
92 | a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user) | |||
|
93 | journal.details << JournalDetail.new(:property => 'attachment', | |||
|
94 | :prop_key => a.id, | |||
|
95 | :value => a.filename) unless a.new_record? | |||
|
96 | } if params[:attachments] and params[:attachments].is_a? Array | |||
|
97 | ||||
89 | flash[:notice] = l(:notice_successful_update) |
|
98 | flash[:notice] = l(:notice_successful_update) | |
90 | Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
99 | Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? | |
91 | redirect_to :action => 'show', :id => @issue |
|
100 | redirect_to :action => 'show', :id => @issue | |
@@ -106,17 +115,28 class IssuesController < ApplicationController | |||||
106 | def add_attachment |
|
115 | def add_attachment | |
107 | # Save the attachments |
|
116 | # Save the attachments | |
108 | @attachments = [] |
|
117 | @attachments = [] | |
|
118 | journal = @issue.init_journal(self.logged_in_user) | |||
109 | params[:attachments].each { |file| |
|
119 | params[:attachments].each { |file| | |
110 | next unless file.size > 0 |
|
120 | next unless file.size > 0 | |
111 | a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user) |
|
121 | a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user) | |
112 | @attachments << a unless a.new_record? |
|
122 | @attachments << a unless a.new_record? | |
|
123 | journal.details << JournalDetail.new(:property => 'attachment', | |||
|
124 | :prop_key => a.id, | |||
|
125 | :value => a.filename) unless a.new_record? | |||
113 | } if params[:attachments] and params[:attachments].is_a? Array |
|
126 | } if params[:attachments] and params[:attachments].is_a? Array | |
|
127 | journal.save if journal.details.any? | |||
114 | Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
128 | Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? | |
115 | redirect_to :action => 'show', :id => @issue |
|
129 | redirect_to :action => 'show', :id => @issue | |
116 | end |
|
130 | end | |
117 |
|
131 | |||
118 | def destroy_attachment |
|
132 | def destroy_attachment | |
119 |
@issue.attachments.find(params[:attachment_id]) |
|
133 | a = @issue.attachments.find(params[:attachment_id]) | |
|
134 | a.destroy | |||
|
135 | journal = @issue.init_journal(self.logged_in_user) | |||
|
136 | journal.details << JournalDetail.new(:property => 'attachment', | |||
|
137 | :prop_key => a.id, | |||
|
138 | :old_value => a.filename) | |||
|
139 | journal.save | |||
120 | redirect_to :action => 'show', :id => @issue |
|
140 | redirect_to :action => 'show', :id => @issue | |
121 | end |
|
141 | end | |
122 |
|
142 |
@@ -48,6 +48,8 module IssuesHelper | |||||
48 | value = format_value(detail.value, custom_field.field_format) if detail.value |
|
48 | value = format_value(detail.value, custom_field.field_format) if detail.value | |
49 | old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value |
|
49 | old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value | |
50 | end |
|
50 | end | |
|
51 | when 'attachment' | |||
|
52 | label = l(:label_attachment) | |||
51 | end |
|
53 | end | |
52 |
|
54 | |||
53 | label ||= detail.prop_key |
|
55 | label ||= detail.prop_key | |
@@ -62,13 +64,23 module IssuesHelper | |||||
62 | end |
|
64 | end | |
63 |
|
65 | |||
64 | if detail.value and !detail.value.to_s.empty? |
|
66 | if detail.value and !detail.value.to_s.empty? | |
65 | if old_value |
|
67 | case detail.property | |
66 | label + " " + l(:text_journal_changed, old_value, value) |
|
68 | when 'attr', 'cf' | |
67 | else |
|
69 | if old_value | |
68 |
label + " " + l(:text_journal_ |
|
70 | label + " " + l(:text_journal_changed, old_value, value) | |
|
71 | else | |||
|
72 | label + " " + l(:text_journal_set_to, value) | |||
|
73 | end | |||
|
74 | when 'attachment' | |||
|
75 | "#{label} #{value} #{l(:label_added)}" | |||
69 | end |
|
76 | end | |
70 | else |
|
77 | else | |
71 | label + " " + l(:text_journal_deleted) + " (#{old_value})" |
|
78 | case detail.property | |
|
79 | when 'attr', 'cf' | |||
|
80 | label + " " + l(:text_journal_deleted) + " (#{old_value})" | |||
|
81 | when 'attachment' | |||
|
82 | "#{label} #{old_value} #{l(:label_deleted)}" | |||
|
83 | end | |||
72 | end |
|
84 | end | |
73 | end |
|
85 | end | |
74 | end |
|
86 | end |
@@ -1,7 +1,7 | |||||
1 | <h2><%=l(:label_issue)%> #<%= @issue.id %>: <%=h @issue.subject %></h2> |
|
1 | <h2><%=l(:label_issue)%> #<%= @issue.id %>: <%=h @issue.subject %></h2> | |
2 |
|
2 | |||
3 | <%= error_messages_for 'issue' %> |
|
3 | <%= error_messages_for 'issue' %> | |
4 | <% form_tag({:action => 'change_status', :id => @issue}, :class => "tabular") do %> |
|
4 | <% form_tag({:action => 'change_status', :id => @issue}, :multipart => true, :class => "tabular") do %> | |
5 |
|
5 | |||
6 | <%= hidden_field_tag 'confirm', 1 %> |
|
6 | <%= hidden_field_tag 'confirm', 1 %> | |
7 | <%= hidden_field_tag 'new_status_id', @new_status.id %> |
|
7 | <%= hidden_field_tag 'new_status_id', @new_status.id %> | |
@@ -30,6 +30,12 | |||||
30 | <p><label for="notes"><%= l(:field_notes) %></label> |
|
30 | <p><label for="notes"><%= l(:field_notes) %></label> | |
31 | <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %></p> |
|
31 | <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %></p> | |
32 |
|
32 | |||
|
33 | <% if authorize_for('issues', 'add_attachment') %> | |||
|
34 | <p id="attachments_p"><label><%=l(:label_attachment_new)%> | |||
|
35 | <%= image_to_function "add.png", "addFileField();return false" %></label> | |||
|
36 | <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p> | |||
|
37 | <% end %> | |||
|
38 | ||||
33 | </div> |
|
39 | </div> | |
34 |
|
40 | |||
35 | <%= hidden_field 'issue', 'lock_version' %> |
|
41 | <%= hidden_field 'issue', 'lock_version' %> |
General Comments 0
You need to be logged in to leave comments.
Login now