@@ -18,9 +18,9 | |||||
18 | class MessagesController < ApplicationController |
|
18 | class MessagesController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 | menu_item :boards |
|
20 | menu_item :boards | |
21 | before_filter :find_board, :only => :new |
|
21 | before_filter :find_board, :only => [:new, :preview] | |
22 | before_filter :find_message, :except => :new |
|
22 | before_filter :find_message, :except => [:new, :preview] | |
23 | before_filter :authorize |
|
23 | before_filter :authorize, :except => :preview | |
24 |
|
24 | |||
25 | verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show } |
|
25 | verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show } | |
26 |
|
26 | |||
@@ -83,6 +83,13 class MessagesController < ApplicationController | |||||
83 | { :action => 'show', :id => @message.parent } |
|
83 | { :action => 'show', :id => @message.parent } | |
84 | end |
|
84 | end | |
85 |
|
85 | |||
|
86 | def preview | |||
|
87 | message = @board.messages.find_by_id(params[:id]) | |||
|
88 | @attachements = message.attachments if message | |||
|
89 | @text = (params[:message] || params[:reply])[:content] | |||
|
90 | render :partial => 'common/preview' | |||
|
91 | end | |||
|
92 | ||||
86 | private |
|
93 | private | |
87 | def find_message |
|
94 | def find_message | |
88 | find_board |
|
95 | find_board |
@@ -8,11 +8,19 | |||||
8 |
|
8 | |||
9 | <div id="add-message" style="display:none;"> |
|
9 | <div id="add-message" style="display:none;"> | |
10 | <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h2> |
|
10 | <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h2> | |
11 | <% form_for :message, @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true} do |f| %> |
|
11 | <% form_for :message, @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true, :id => 'message-form'} do |f| %> | |
12 | <%= render :partial => 'messages/form', :locals => {:f => f} %> |
|
12 | <%= render :partial => 'messages/form', :locals => {:f => f} %> | |
13 | <p><%= submit_tag l(:button_create) %> |
|
13 | <p><%= submit_tag l(:button_create) %> | |
|
14 | <%= link_to_remote l(:label_preview), | |||
|
15 | { :url => { :controller => 'messages', :action => 'preview', :board_id => @board }, | |||
|
16 | :method => 'post', | |||
|
17 | :update => 'preview', | |||
|
18 | :with => "Form.serialize('message-form')", | |||
|
19 | :complete => "Element.scrollTo('preview')" | |||
|
20 | }, :accesskey => accesskey(:preview) %> | | |||
14 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-message")' %></p> |
|
21 | <%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-message")' %></p> | |
15 | <% end %> |
|
22 | <% end %> | |
|
23 | <div id="preview" class="wiki"></div> | |||
16 | </div> |
|
24 | </div> | |
17 |
|
25 | |||
18 | <h2><%=h @board.name %></h2> |
|
26 | <h2><%=h @board.name %></h2> |
@@ -1,6 +1,14 | |||||
1 | <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%=h @message.subject %></h2> |
|
1 | <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%=h @message.subject %></h2> | |
2 |
|
2 | |||
3 | <% form_for :message, @message, :url => {:action => 'edit'}, :html => {:multipart => true} do |f| %> |
|
3 | <% form_for :message, @message, :url => {:action => 'edit'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> | |
4 | <%= render :partial => 'form', :locals => {:f => f, :replying => !@message.parent.nil?} %> |
|
4 | <%= render :partial => 'form', :locals => {:f => f, :replying => !@message.parent.nil?} %> | |
5 | <%= submit_tag l(:button_save) %> |
|
5 | <%= submit_tag l(:button_save) %> | |
|
6 | <%= link_to_remote l(:label_preview), | |||
|
7 | { :url => { :controller => 'messages', :action => 'preview', :board_id => @board }, | |||
|
8 | :method => 'post', | |||
|
9 | :update => 'preview', | |||
|
10 | :with => "Form.serialize('message-form')", | |||
|
11 | :complete => "Element.scrollTo('preview')" | |||
|
12 | }, :accesskey => accesskey(:preview) %> | |||
6 | <% end %> |
|
13 | <% end %> | |
|
14 | <div id="preview" class="wiki"></div> |
@@ -1,6 +1,15 | |||||
1 | <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h2> |
|
1 | <h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> » <%= l(:label_message_new) %></h2> | |
2 |
|
2 | |||
3 | <% form_for :message, @message, :url => {:action => 'new'}, :html => {:multipart => true} do |f| %> |
|
3 | <% form_for :message, @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> | |
4 | <%= render :partial => 'form', :locals => {:f => f} %> |
|
4 | <%= render :partial => 'form', :locals => {:f => f} %> | |
5 | <%= submit_tag l(:button_create) %> |
|
5 | <%= submit_tag l(:button_create) %> | |
|
6 | <%= link_to_remote l(:label_preview), | |||
|
7 | { :url => { :controller => 'messages', :action => 'preview', :board_id => @board }, | |||
|
8 | :method => 'post', | |||
|
9 | :update => 'preview', | |||
|
10 | :with => "Form.serialize('message-form')", | |||
|
11 | :complete => "Element.scrollTo('preview')" | |||
|
12 | }, :accesskey => accesskey(:preview) %> | |||
6 | <% end %> |
|
13 | <% end %> | |
|
14 | ||||
|
15 | <div id="preview" class="wiki"></div> |
@@ -31,9 +31,17 | |||||
31 | <% if !@topic.locked? && authorize_for('messages', 'reply') %> |
|
31 | <% if !@topic.locked? && authorize_for('messages', 'reply') %> | |
32 | <p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p> |
|
32 | <p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p> | |
33 | <div id="reply" style="display:none;"> |
|
33 | <div id="reply" style="display:none;"> | |
34 | <% form_for :reply, @reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true} do |f| %> |
|
34 | <% form_for :reply, @reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %> | |
35 |
|
|
35 | <%= render :partial => 'form', :locals => {:f => f, :replying => true} %> | |
36 |
|
|
36 | <%= submit_tag l(:button_submit) %> | |
|
37 | <%= link_to_remote l(:label_preview), | |||
|
38 | { :url => { :controller => 'messages', :action => 'preview', :board_id => @board }, | |||
|
39 | :method => 'post', | |||
|
40 | :update => 'preview', | |||
|
41 | :with => "Form.serialize('message-form')", | |||
|
42 | :complete => "Element.scrollTo('preview')" | |||
|
43 | }, :accesskey => accesskey(:preview) %> | |||
37 | <% end %> |
|
44 | <% end %> | |
|
45 | <div id="preview" class="wiki"></div> | |||
38 | </div> |
|
46 | </div> | |
39 | <% end %> |
|
47 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now