Added preview for forum messages.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1205 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4458a7282b
commit
a4c6c62c8b
|
@ -18,9 +18,9 @@
|
|||
class MessagesController < ApplicationController
|
||||
layout 'base'
|
||||
menu_item :boards
|
||||
before_filter :find_board, :only => :new
|
||||
before_filter :find_message, :except => :new
|
||||
before_filter :authorize
|
||||
before_filter :find_board, :only => [:new, :preview]
|
||||
before_filter :find_message, :except => [:new, :preview]
|
||||
before_filter :authorize, :except => :preview
|
||||
|
||||
verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show }
|
||||
|
||||
|
@ -83,6 +83,13 @@ class MessagesController < ApplicationController
|
|||
{ :action => 'show', :id => @message.parent }
|
||||
end
|
||||
|
||||
def preview
|
||||
message = @board.messages.find_by_id(params[:id])
|
||||
@attachements = message.attachments if message
|
||||
@text = (params[:message] || params[:reply])[:content]
|
||||
render :partial => 'common/preview'
|
||||
end
|
||||
|
||||
private
|
||||
def find_message
|
||||
find_board
|
||||
|
|
|
@ -8,11 +8,19 @@
|
|||
|
||||
<div id="add-message" style="display:none;">
|
||||
<h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h2>
|
||||
<% form_for :message, @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true} do |f| %>
|
||||
<% form_for :message, @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
||||
<p><%= submit_tag l(:button_create) %>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
|
||||
:method => 'post',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('message-form')",
|
||||
:complete => "Element.scrollTo('preview')"
|
||||
}, :accesskey => accesskey(:preview) %> |
|
||||
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-message")' %></p>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
|
||||
<h2><%=h @board.name %></h2>
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%=h @message.subject %></h2>
|
||||
|
||||
<% form_for :message, @message, :url => {:action => 'edit'}, :html => {:multipart => true} do |f| %>
|
||||
<% form_for :message, @message, :url => {:action => 'edit'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f, :replying => !@message.parent.nil?} %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
|
||||
:method => 'post',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('message-form')",
|
||||
:complete => "Element.scrollTo('preview')"
|
||||
}, :accesskey => accesskey(:preview) %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
<h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h2>
|
||||
|
||||
<% form_for :message, @message, :url => {:action => 'new'}, :html => {:multipart => true} do |f| %>
|
||||
<% form_for :message, @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
|
||||
:method => 'post',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('message-form')",
|
||||
:complete => "Element.scrollTo('preview')"
|
||||
}, :accesskey => accesskey(:preview) %>
|
||||
<% end %>
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
|
|
@ -31,9 +31,17 @@
|
|||
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
|
||||
<div id="reply" style="display:none;">
|
||||
<% form_for :reply, @reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
<% form_for :reply, @reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
|
||||
<%= submit_tag l(:button_submit) %>
|
||||
<%= link_to_remote l(:label_preview),
|
||||
{ :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
|
||||
:method => 'post',
|
||||
:update => 'preview',
|
||||
:with => "Form.serialize('message-form')",
|
||||
:complete => "Element.scrollTo('preview')"
|
||||
}, :accesskey => accesskey(:preview) %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue