Feature #41294 » 0002-Implement-and-use-JS-function-to-handle-quote-reply.patch
| app/assets/javascripts/application.js | ||
|---|---|---|
|
tribute.attach(element);
|
||
|
}
|
||
|
function quoteReply(path) {
|
||
|
$.ajax({
|
||
|
url: path,
|
||
|
type: 'post'
|
||
|
});
|
||
|
}
|
||
|
$(document).ready(setupAjaxIndicator);
|
||
|
$(document).ready(hideOnLoad);
|
||
| app/helpers/journals_helper.rb | ||
|---|---|---|
|
if journal.notes.present?
|
||
|
if options[:reply_links]
|
||
|
links << link_to(icon_with_label('comment', l(:button_quote)),
|
||
|
quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice),
|
||
|
:remote => true,
|
||
|
:method => 'post',
|
||
|
:title => l(:button_quote),
|
||
|
:class => 'icon-only icon-comment'
|
||
|
)
|
||
|
links << link_to_function(icon_with_label('comment', l(:button_quote)),
|
||
|
"quoteReply('#{j quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice)}')",
|
||
|
:title => l(:button_quote),
|
||
|
:class => 'icon-only icon-comment'
|
||
|
)
|
||
|
end
|
||
|
if journal.editable_by?(User.current)
|
||
|
links << link_to(icon_with_label('edit', l(:button_edit)),
|
||
| app/views/issues/show.html.erb | ||
|---|---|---|
|
<hr />
|
||
|
<div class="description">
|
||
|
<div class="contextual">
|
||
|
<%= link_to icon_with_label('comment', l(:button_quote)), quoted_issue_path(@issue), :remote => true, :method => 'post', :class => 'icon icon-comment ' if @issue.notes_addable? %>
|
||
|
<%= link_to_function icon_with_label('comment', l(:button_quote)), "quoteReply('#{j quoted_issue_path(@issue)}')",:class => 'icon icon-comment ' if @issue.notes_addable? %>
|
||
|
</div>
|
||
|
<p><strong><%=l(:field_description)%></strong></p>
|
||
| app/views/messages/show.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= watcher_link(@topic, User.current) %>
|
||
|
<%= link_to(
|
||
|
<%= link_to_function(
|
||
|
icon_with_label('comment', l(:button_quote)),
|
||
|
{:action => 'quote', :id => @topic},
|
||
|
:method => 'get',
|
||
|
:class => 'icon icon-comment',
|
||
|
:remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||
|
"quoteReply('#{j url_for(:action => 'quote', :id => @topic, :format => 'js')}')",
|
||
|
:class => 'icon icon-comment') if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||
|
<%= link_to(
|
||
|
icon_with_label('edit', l(:button_edit)),
|
||
|
{:action => 'edit', :id => @topic},
|
||
| ... | ... | |
|
<% @replies.each do |message| %>
|
||
|
<div class="message reply" id="<%= "message-#{message.id}" %>">
|
||
|
<div class="contextual">
|
||
|
<%= link_to(
|
||
|
<%= link_to_function(
|
||
|
icon_with_label('comment', l(:button_quote), icon_only: true),
|
||
|
{:action => 'quote', :id => message},
|
||
|
:remote => true,
|
||
|
:method => 'get',
|
||
|
"quoteReply('#{j url_for(:action => 'quote', :id => message, :format => 'js')}')",
|
||
|
:title => l(:button_quote),
|
||
|
:class => 'icon icon-comment'
|
||
|
) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||
| test/functional/journals_controller_test.rb | ||
|---|---|---|
|
def test_reply_to_issue
|
||
|
@request.session[:user_id] = 2
|
||
|
get(:new, :params => {:id => 6}, :xhr => true)
|
||
|
post(:new, :params => {:id => 6}, :xhr => true)
|
||
|
assert_response :success
|
||
|
assert_equal 'text/javascript', response.media_type
|
||
| ... | ... | |
|
def test_reply_to_issue_without_permission
|
||
|
@request.session[:user_id] = 7
|
||
|
get(:new, :params => {:id => 6}, :xhr => true)
|
||
|
post(:new, :params => {:id => 6}, :xhr => true)
|
||
|
assert_response :forbidden
|
||
|
end
|
||
|
def test_reply_to_note
|
||
|
@request.session[:user_id] = 2
|
||
|
get(
|
||
|
post(
|
||
|
:new,
|
||
|
:params => {
|
||
|
:id => 6,
|
||
| ... | ... | |
|
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true)
|
||
|
@request.session[:user_id] = 2
|
||
|
get(
|
||
|
post(
|
||
|
:new,
|
||
|
:params => {
|
||
|
:id => 2,
|
||
| ... | ... | |
|
assert_include '> Privates notes', response.body
|
||
|
Role.find(1).remove_permission! :view_private_notes
|
||
|
get(
|
||
|
post(
|
||
|
:new,
|
||
|
:params => {
|
||
|
:id => 2,
|
||
| test/functional/messages_controller_test.rb | ||
|---|---|---|
|
def test_quote_if_message_is_root
|
||
|
@request.session[:user_id] = 2
|
||
|
get(
|
||
|
post(
|
||
|
:quote,
|
||
|
:params => {
|
||
|
:board_id => 1,
|
||
| ... | ... | |
|
def test_quote_if_message_is_not_root
|
||
|
@request.session[:user_id] = 2
|
||
|
get(
|
||
|
post(
|
||
|
:quote,
|
||
|
:params => {
|
||
|
:board_id => 1,
|
||
| ... | ... | |
|
def test_quote_as_html_should_respond_with_404
|
||
|
@request.session[:user_id] = 2
|
||
|
get(
|
||
|
post(
|
||
|
:quote,
|
||
|
:params => {
|
||
|
:board_id => 1,
|
||