Project

General

Profile

Feature #1070 » redmine-note-edit.patch

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

View differences:

/var/www/html/redmine/app/controllers/issues_controller.rb 2008-04-16 13:31:58.000000000 -0400
class IssuesController < ApplicationController
layout 'base'
before_filter :find_project, :authorize, :except => [:index, :changes, :preview]
before_filter :find_project, :authorize, :except => [:index, :changes, :preview, :note_preview, :journal_preview, :edit_note]
before_filter :find_optional_project, :only => [:index, :changes]
accept_key_auth :index, :changes
cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
cache_sweeper :issue_sweeper, :only => [ :edit, :edit_note, :change_status, :destroy ]
helper :projects
include ProjectsHelper
......
end
end
end
def edit_note
logger.debug "edit note(#{params[:journal_id]}): [#{params[:journal][:notes]}]"
if request.get?
@journal = Journal.find_by_id(params[:journal_id])
logger.debug "get note(#{params[:journal_id]}): [#{@journal.notes}]"
else
begin
@journal = Journal.find_by_id(params[:journal_id])
logger.debug "existing note(#{params[:journal_id]}): [#{@journal.notes}]"
@journal.notes = params[:journal][:notes]
if @journal.save
logger.debug "save note(#{params[:journal_id]}): [#{@journal.notes}]"
flash[:notice] = l(:notice_successful_update)
logger.debug "redirecting to [#{@issue}]"
redirect_to :action => 'show', :id => params[:id]
# redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
end
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
flash[:error] = l(:notice_locking_conflict)
end
end
end
def add_note
journal = @issue.init_journal(User.current, params[:notes])
attachments = attach_files(@issue, params[:attachments])
......
@text = params[:issue][:description]
render :partial => 'common/preview'
end
def note_preview
@text = params[:notes]
logger.debug "note preview [#{@text}]"
render :partial => 'common/preview'
end
def journal_preview
@text = params[:journal][:notes]
logger.debug "journal note preview [#{@text}]"
render :partial => 'common/preview'
end
private
def find_project
/var/www/html/redmine/app/views/issues/change_status.rhtml 2008-04-15 11:55:56.000000000 -0400
<%= error_messages_for 'issue' %>
<% labelled_tabular_form_for(:issue, @issue, :url => {:action => 'change_status', :id => @issue}, :html => {:multipart => true}) do |f| %>
<div id="change-status">
<%= hidden_field_tag 'confirm', 1 %>
<%= hidden_field_tag 'new_status_id', @new_status.id %>
<%= f.hidden_field :lock_version %>
......
<%= image_to_function "add.png", "addFileField();return false" %></label>
<%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
</div>
</div>
<%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
{ :url => {:controller => 'issues',
:action => 'preview',
:id => @issue },
:method => 'post',
:update => 'preview',
:with => "Form.serialize('change-status')",
:complete => "location.href='#preview-top'"
}, :accesskey => accesskey(:preview) %>
<% end %>
<a name="preview-top"></a>
<div id="preview" class="wiki"></div>
/var/www/html/redmine/app/views/issues/_history.rhtml 2008-04-16 13:26:05.000000000 -0400
<% note_id = 1 %>
<% for journal in journals %>
<h4><div style="float:right;"><%= link_to "##{note_id}", :anchor => "note-#{note_id}" %></div>
<div class="journal">
<h4><div style="float:right;">
<% if authorize_for('issues', 'destroy') or User.current.id == journal.user.id %>
<%= show_and_goto_link(l(:button_edit), "edit-note-#{note_id}", :class => 'icon icon-note') %>
<% end %>
<%= link_to "##{note_id}", :anchor => "note-#{note_id}" %>
<%= content_tag('a', '', :name => "note-#{note_id}")%>
</div>
<%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
<ul>
<% for detail in journal.details %>
......
<% end %>
</ul>
<%= textilizable(journal.notes) unless journal.notes.blank? %>
<% note_id += 1 %>
<% if authorize_for('issues', 'destroy') or User.current.id == journal.user.id %>
<a name="edit-note-anchor"></a>
<% labelled_tabular_form_for :journal, journal,
:url => {:controller => 'issues',
:action => 'edit_note',
:id => @issue,
:journal_id => journal.id },
:html => {:id => "edit-note-#{note_id}",
:style => "display:none;"} do |f| %>
<%= render :partial => 'note_form', :locals => {:f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to_remote l(:label_preview),
{ :url => {:controller => 'issues',
:action => 'journal_preview',
:id => @issue },
:method => 'post',
:update => "preview-#{note_id}",
:with => "Form.serialize('edit-note-#{note_id}')",
:complete => "location.href='#preview-top-#{note_id}'"
}, :accesskey => accesskey(:preview) %>
<%= toggle_link l(:button_cancel), "edit-note-#{note_id}" %>
<% end %>
<%= content_tag('a', '', :name => "preview-top-#{note_id}") %>
<%= content_tag('div', '', :id => "preview-#{note_id}", :class => "wiki") %>
<% end %>
</div>
<% note_id += 1 %>
<% end %>
/var/www/html/redmine/app/views/issues/show.rhtml 2008-04-16 13:27:50.000000000 -0400
<%= wikitoolbar_for 'notes' %>
<%= render :partial => 'attachments/form' %>
<%= submit_tag l(:button_add) %>
<%= link_to_remote l(:label_preview),
{ :url => {:controller => 'issues',
:action => 'note_preview',
:id => @issue },
:method => 'post',
:update => 'preview',
:with => "Form.serialize('add-note')",
:complete => "location.href='#preview-top'"
}, :accesskey => accesskey(:preview) %>
<%= toggle_link l(:button_cancel), 'add-note' %>
<% end %>
<a name="preview-top"></a>
<div id="preview" class="wiki"></div>
</div>
<% end %>
/var/www/html/redmine/lang/en.yml 2008-04-15 15:04:58.000000000 -0400
label_issue_plural: Issues
label_issue_view_all: View all issues
label_issues_by: Issues by %s
label_note_edit: Edit Note
label_document: Document
label_document_new: New document
label_document_plural: Documents
(1-1/2)