Project

General

Profile

Feature #41294 » 0002-Implement-and-use-JS-function-to-handle-quote-reply.patch

Katsuya HIDAKA, 2024-09-22 13:01

View differences:

app/assets/javascripts/application.js
1262 1262
    tribute.attach(element);
1263 1263
}
1264 1264

  
1265
function quoteReply(path) {
1266
  $.ajax({
1267
    url: path,
1268
    type: 'post'
1269
  });
1270
}
1265 1271

  
1266 1272
$(document).ready(setupAjaxIndicator);
1267 1273
$(document).ready(hideOnLoad);
app/helpers/journals_helper.rb
40 40

  
41 41
    if journal.notes.present?
42 42
      if options[:reply_links]
43
        links << link_to(icon_with_label('comment', l(:button_quote)),
44
                         quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice),
45
                         :remote => true,
46
                         :method => 'post',
47
                         :title => l(:button_quote),
48
                         :class => 'icon-only icon-comment'
49
                        )
43
        links << link_to_function(icon_with_label('comment', l(:button_quote)),
44
                                  "quoteReply('#{j quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice)}')",
45
                                  :title => l(:button_quote),
46
                                  :class => 'icon-only icon-comment'
47
                                 )
50 48
      end
51 49
      if journal.editable_by?(User.current)
52 50
        links << link_to(icon_with_label('edit', l(:button_edit)),
app/views/issues/show.html.erb
84 84
<hr />
85 85
<div class="description">
86 86
  <div class="contextual">
87
  <%= 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? %>
87
  <%= link_to_function icon_with_label('comment', l(:button_quote)), "quoteReply('#{j quoted_issue_path(@issue)}')",:class => 'icon icon-comment ' if @issue.notes_addable? %>
88 88
  </div>
89 89

  
90 90
  <p><strong><%=l(:field_description)%></strong></p>
app/views/messages/show.html.erb
2 2

  
3 3
<div class="contextual">
4 4
    <%= watcher_link(@topic, User.current) %>
5
    <%= link_to(
5
    <%= link_to_function(
6 6
          icon_with_label('comment', l(:button_quote)),
7
          {:action => 'quote', :id => @topic},
8
          :method => 'get',
9
          :class => 'icon icon-comment',
10
          :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
7
          "quoteReply('#{j url_for(:action => 'quote', :id => @topic, :format => 'js')}')",
8
          :class => 'icon icon-comment') if !@topic.locked? && authorize_for('messages', 'reply') %>
11 9
    <%= link_to(
12 10
          icon_with_label('edit', l(:button_edit)),
13 11
          {:action => 'edit', :id => @topic},
......
42 40
<% @replies.each do |message| %>
43 41
  <div class="message reply" id="<%= "message-#{message.id}" %>">
44 42
    <div class="contextual">
45
      <%= link_to(
43
      <%= link_to_function(
46 44
            icon_with_label('comment', l(:button_quote), icon_only: true),
47
            {:action => 'quote', :id => message},
48
            :remote => true,
49
            :method => 'get',
45
            "quoteReply('#{j url_for(:action => 'quote', :id => message, :format => 'js')}')",
50 46
            :title => l(:button_quote),
51 47
            :class => 'icon icon-comment'
52 48
          ) if !@topic.locked? && authorize_for('messages', 'reply') %>
test/functional/journals_controller_test.rb
168 168

  
169 169
  def test_reply_to_issue
170 170
    @request.session[:user_id] = 2
171
    get(:new, :params => {:id => 6}, :xhr => true)
171
    post(:new, :params => {:id => 6}, :xhr => true)
172 172
    assert_response :success
173 173

  
174 174
    assert_equal 'text/javascript', response.media_type
......
177 177

  
178 178
  def test_reply_to_issue_without_permission
179 179
    @request.session[:user_id] = 7
180
    get(:new, :params => {:id => 6}, :xhr => true)
180
    post(:new, :params => {:id => 6}, :xhr => true)
181 181
    assert_response :forbidden
182 182
  end
183 183

  
184 184
  def test_reply_to_note
185 185
    @request.session[:user_id] = 2
186
    get(
186
    post(
187 187
      :new,
188 188
      :params => {
189 189
        :id => 6,
......
202 202
    journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true)
203 203
    @request.session[:user_id] = 2
204 204

  
205
    get(
205
    post(
206 206
      :new,
207 207
      :params => {
208 208
        :id => 2,
......
215 215
    assert_include '> Privates notes', response.body
216 216

  
217 217
    Role.find(1).remove_permission! :view_private_notes
218
    get(
218
    post(
219 219
      :new,
220 220
      :params => {
221 221
        :id => 2,
test/functional/messages_controller_test.rb
288 288

  
289 289
  def test_quote_if_message_is_root
290 290
    @request.session[:user_id] = 2
291
    get(
291
    post(
292 292
      :quote,
293 293
      :params => {
294 294
        :board_id => 1,
......
306 306

  
307 307
  def test_quote_if_message_is_not_root
308 308
    @request.session[:user_id] = 2
309
    get(
309
    post(
310 310
      :quote,
311 311
      :params => {
312 312
        :board_id => 1,
......
324 324

  
325 325
  def test_quote_as_html_should_respond_with_404
326 326
    @request.session[:user_id] = 2
327
    get(
327
    post(
328 328
      :quote,
329 329
      :params => {
330 330
        :board_id => 1,
(8-8/17)