redmine-note-edit.patch

changes for preview and editing notes - Carl Nygard, 2008-04-16 20:20

Download (8.13 KB)

View differences:

/var/www/html/redmine/app/controllers/issues_controller.rb 2008-04-16 13:31:58.000000000 -0400
17 17

  
18 18
class IssuesController < ApplicationController
19 19
  layout 'base'
20
  before_filter :find_project, :authorize, :except => [:index, :changes, :preview]
20
  before_filter :find_project, :authorize, :except => [:index, :changes, :preview, :note_preview, :journal_preview, :edit_note]
21 21
  before_filter :find_optional_project, :only => [:index, :changes]
22 22
  accept_key_auth :index, :changes
23 23
  
24
  cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
24
  cache_sweeper :issue_sweeper, :only => [ :edit, :edit_note, :change_status, :destroy ]
25 25

  
26 26
  helper :projects
27 27
  include ProjectsHelper   
......
113 113
      end
114 114
    end		
115 115
  end
116
  
116

  
117
  def edit_note
118
    logger.debug "edit note(#{params[:journal_id]}): [#{params[:journal][:notes]}]"
119
    if request.get?
120
      @journal = Journal.find_by_id(params[:journal_id])
121
      logger.debug "get note(#{params[:journal_id]}): [#{@journal.notes}]"
122
    else
123
      begin
124
        @journal = Journal.find_by_id(params[:journal_id])
125
        logger.debug "existing note(#{params[:journal_id]}): [#{@journal.notes}]"
126
        @journal.notes = params[:journal][:notes]
127
        if @journal.save
128
          logger.debug "save note(#{params[:journal_id]}): [#{@journal.notes}]"
129
          flash[:notice] = l(:notice_successful_update)
130
          logger.debug "redirecting to [#{@issue}]"
131
          redirect_to :action => 'show', :id => params[:id]
132
#          redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
133
        end
134
      rescue ActiveRecord::StaleObjectError
135
        # Optimistic locking exception
136
        flash[:error] = l(:notice_locking_conflict)
137
      end
138
    end
139
  end
140

  
117 141
  def add_note
118 142
    journal = @issue.init_journal(User.current, params[:notes])
119 143
    attachments = attach_files(@issue, params[:attachments])
......
194 218
    @text = params[:issue][:description]
195 219
    render :partial => 'common/preview'
196 220
  end
221

  
222
  def note_preview
223
    @text = params[:notes]
224
    logger.debug "note preview [#{@text}]"
225
    render :partial => 'common/preview'
226
  end
227
  
228
  def journal_preview
229
    @text = params[:journal][:notes]
230
    logger.debug "journal note preview [#{@text}]"
231
    render :partial => 'common/preview'
232
  end
197 233
  
198 234
private
199 235
  def find_project
/var/www/html/redmine/app/views/issues/change_status.rhtml 2008-04-15 11:55:56.000000000 -0400
2 2

  
3 3
<%= error_messages_for 'issue' %>
4 4
<% labelled_tabular_form_for(:issue, @issue, :url => {:action => 'change_status', :id => @issue}, :html => {:multipart => true}) do |f| %>
5

  
5
<div id="change-status">
6 6
<%= hidden_field_tag 'confirm', 1 %>
7 7
<%= hidden_field_tag 'new_status_id', @new_status.id %>
8 8
<%= f.hidden_field :lock_version %>
......
33 33
<%= image_to_function "add.png", "addFileField();return false" %></label>
34 34
<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
35 35
</div>
36
</div>
36 37

  
37 38
<%= submit_tag l(:button_save) %>
39
<%= link_to_remote l(:label_preview), 
40
                     { :url => {:controller => 'issues', 
41
                                :action => 'preview', 
42
                                :id => @issue },
43
                       :method => 'post',
44
                       :update => 'preview',
45
                       :with => "Form.serialize('change-status')",
46
                       :complete => "location.href='#preview-top'"
47
                     }, :accesskey => accesskey(:preview) %>
38 48
<% end %>
49
  <a name="preview-top"></a>
50
  <div id="preview" class="wiki"></div>
/var/www/html/redmine/app/views/issues/_history.rhtml 2008-04-16 13:26:05.000000000 -0400
1 1
<% note_id = 1 %>
2 2
<% for journal in journals %>
3
	<h4><div style="float:right;"><%= link_to "##{note_id}", :anchor => "note-#{note_id}" %></div>
3
  <div class="journal">
4
	<h4><div style="float:right;">
5
    <% if authorize_for('issues', 'destroy') or User.current.id == journal.user.id %>
6
      <%= show_and_goto_link(l(:button_edit), "edit-note-#{note_id}", :class => 'icon icon-note') %>
7
    <% end %>
8
    <%= link_to "##{note_id}", :anchor => "note-#{note_id}" %>
4 9
	<%= content_tag('a', '', :name => "note-#{note_id}")%>
10
    </div>
5 11
	<%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
6 12
	<ul>
7 13
	<% for detail in journal.details %>
......
9 15
	<% end %>
10 16
	</ul>
11 17
  	<%= textilizable(journal.notes) unless journal.notes.blank? %>
12
  	<% note_id += 1 %>
18

  
19
    <% if authorize_for('issues', 'destroy') or User.current.id == journal.user.id %>
20
      <a name="edit-note-anchor"></a>
21
      <% labelled_tabular_form_for :journal, journal,
22
                         :url => {:controller => 'issues',
23
                                  :action => 'edit_note',
24
                                  :id => @issue,
25
                                  :journal_id => journal.id },
26
                         :html => {:id => "edit-note-#{note_id}",
27
                                   :style => "display:none;"} do |f| %>
28
        <%= render :partial => 'note_form', :locals => {:f => f } %>
29

  
30
        <%= submit_tag l(:button_save) %>
31
        <%= link_to_remote l(:label_preview), 
32
                         { :url => {:controller => 'issues', 
33
                                    :action => 'journal_preview', 
34
                                    :id => @issue },
35
                           :method => 'post',
36
                           :update => "preview-#{note_id}",
37
                           :with => "Form.serialize('edit-note-#{note_id}')",
38
                           :complete => "location.href='#preview-top-#{note_id}'"
39
                         }, :accesskey => accesskey(:preview) %>
40
        <%= toggle_link l(:button_cancel), "edit-note-#{note_id}" %>
41
      <% end %>  
42

  
43
      <%= content_tag('a', '', :name => "preview-top-#{note_id}") %>
44
      <%= content_tag('div', '', :id => "preview-#{note_id}", :class => "wiki") %>
45
    <% end %>
46

  
47
  </div>
48
  <% note_id += 1 %>
13 49
<% end %>
/var/www/html/redmine/app/views/issues/show.rhtml 2008-04-16 13:27:50.000000000 -0400
106 106
    <%= wikitoolbar_for 'notes' %>
107 107
    <%= render :partial => 'attachments/form' %>
108 108
  <%= submit_tag l(:button_add) %>
109
  <%= link_to_remote l(:label_preview), 
110
                     { :url => {:controller => 'issues', 
111
                                :action => 'note_preview', 
112
                                :id => @issue },
113
                       :method => 'post',
114
                       :update => 'preview',
115
                       :with => "Form.serialize('add-note')",
116
                       :complete => "location.href='#preview-top'"
117
                     }, :accesskey => accesskey(:preview) %>
109 118
  <%= toggle_link l(:button_cancel), 'add-note' %>
110 119
  <% end %>  
120
  <a name="preview-top"></a>
121
  <div id="preview" class="wiki"></div>
111 122
  </div>
112 123
<% end %>
113 124

  
/var/www/html/redmine/lang/en.yml 2008-04-15 15:04:58.000000000 -0400
212 212
label_issue_plural: Issues
213 213
label_issue_view_all: View all issues
214 214
label_issues_by: Issues by %s
215
label_note_edit: Edit Note
215 216
label_document: Document
216 217
label_document_new: New document
217 218
label_document_plural: Documents