Feature #41294 » 0005-Separate-helpers-for-the-quote-reply-into-the-Redmine-QuoteReply.patch
| app/helpers/journals_helper.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module JournalsHelper
|
||
|
include Redmine::QuoteReply::Helper
|
||
|
# Returns the attachments of a journal that are displayed as thumbnails
|
||
|
def journal_thumbnail_attachments(journal)
|
||
|
journal.attachments.select(&:thumbnailable?)
|
||
| ... | ... | |
|
if journal.notes.present?
|
||
|
if options[:reply_links]
|
||
|
url = quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice)
|
||
|
links << link_to_function(icon_with_label('comment', l(:button_quote)),
|
||
|
"quoteReply('#{j url}', '#journal-#{j journal.id}-notes')",
|
||
|
:title => l(:button_quote),
|
||
|
:class => 'icon-only icon-comment'
|
||
|
)
|
||
|
links << quote_reply(url, "#journal-#{journal.id}-notes", icon_only: true)
|
||
|
end
|
||
|
if journal.editable_by?(User.current)
|
||
|
links << link_to(icon_with_label('edit', l(:button_edit)),
|
||
| app/helpers/messages_helper.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module MessagesHelper
|
||
|
include Redmine::QuoteReply::Helper
|
||
|
end
|
||
| app/views/issues/show.html.erb | ||
|---|---|---|
|
<% content_for :header_tags do %>
|
||
|
<%= javascript_include_tag 'quote_reply' %>
|
||
|
<%= javascript_for_quote_reply_include_tag %>
|
||
|
<% end %>
|
||
|
<%= render :partial => 'action_menu' %>
|
||
| ... | ... | |
|
<hr />
|
||
|
<div class="description">
|
||
|
<div class="contextual">
|
||
|
<%= link_to_function(icon_with_label('comment', l(:button_quote)),
|
||
|
"quoteReply('#{j quoted_issue_path(@issue)}', '#issue_description_wiki')",
|
||
|
:class => 'icon icon-comment '
|
||
|
) if @issue.notes_addable? %>
|
||
|
<%= quote_reply(quoted_issue_path(@issue), '#issue_description_wiki') if @issue.notes_addable? %>
|
||
|
</div>
|
||
|
<p><strong><%=l(:field_description)%></strong></p>
|
||
| app/views/messages/show.html.erb | ||
|---|---|---|
|
<% content_for :header_tags do %>
|
||
|
<%= javascript_include_tag 'quote_reply' %>
|
||
|
<%= javascript_for_quote_reply_include_tag %>
|
||
|
<% end %>
|
||
|
<%= board_breadcrumb(@message) %>
|
||
|
<div class="contextual">
|
||
|
<%= watcher_link(@topic, User.current) %>
|
||
|
<%= link_to_function(
|
||
|
icon_with_label('comment', l(:button_quote)),
|
||
|
"quoteReply('#{j url_for(:action => 'quote', :id => @topic, :format => 'js')}', '#message_topic_wiki')",
|
||
|
:class => 'icon icon-comment') if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||
|
<%= quote_reply(
|
||
|
url_for(:action => 'quote', :id => @topic, :format => 'js'),
|
||
|
'#message_topic_wiki'
|
||
|
) 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_function(
|
||
|
icon_with_label('comment', l(:button_quote), icon_only: true),
|
||
|
"quoteReply('#{j url_for(:action => 'quote', :id => message, :format => 'js')}', '#message-#{j message.id} .wiki')",
|
||
|
:title => l(:button_quote),
|
||
|
:class => 'icon icon-comment'
|
||
|
<%= quote_reply(
|
||
|
url_for(:action => 'quote', :id => message, :format => 'js'),
|
||
|
"#message-#{message.id} .wiki",
|
||
|
icon_only: true
|
||
|
) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||
|
<%= link_to(
|
||
|
icon_with_label('edit', l(:button_edit), icon_only: true),
|
||
| lib/redmine/quote_reply.rb | ||
|---|---|---|
|
# frozen_string_literal: true
|
||
|
# Redmine - project management software
|
||
|
# Copyright (C) 2006- Jean-Philippe Lang
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module Redmine
|
||
|
module QuoteReply
|
||
|
module Helper
|
||
|
def javascript_for_quote_reply_include_tag
|
||
|
javascript_include_tag 'quote_reply'
|
||
|
end
|
||
|
def quote_reply(url, selector_for_content, icon_only: false)
|
||
|
quote_reply_function = "quoteReply('#{j url}', '#{j selector_for_content}')"
|
||
|
html_options = { class: 'icon icon-comment' }
|
||
|
html_options[:title] = l(:button_quote) if icon_only
|
||
|
link_to_function(
|
||
|
icon_with_label('comment', l(:button_quote), icon_only: icon_only),
|
||
|
quote_reply_function,
|
||
|
html_options
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| test/helpers/journals_helper_test.rb | ||
|---|---|---|
|
journals = issue.visible_journals_with_index # add indice
|
||
|
journal_actions = render_journal_actions(issue, journals.first, {reply_links: true})
|
||
|
assert_select_in journal_actions, 'a[title=?][class="icon-only icon-comment"]', 'Quote'
|
||
|
assert_select_in journal_actions, 'a[title=?][class="icon icon-comment"]', 'Quote'
|
||
|
assert_select_in journal_actions, 'a[title=?][class="icon-only icon-edit"]', 'Edit'
|
||
|
assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-del"]'
|
||
|
assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-copy-link"]'
|
||
| test/unit/lib/redmine/quote_reply_helper_test.rb | ||
|---|---|---|
|
# frozen_string_literal: true
|
||
|
# Redmine - project management software
|
||
|
# Copyright (C) 2006- Jean-Philippe Lang
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
require_relative '../../../test_helper'
|
||
|
class QuoteReplyHelperTest < ActionView::TestCase
|
||
|
include ERB::Util
|
||
|
include Redmine::QuoteReply::Helper
|
||
|
fixtures :issues
|
||
|
def test_quote_reply
|
||
|
url = quoted_issue_path(issues(:issues_001))
|
||
|
a_tag = quote_reply(url, '#issue_description_wiki')
|
||
|
assert_includes a_tag, %|onclick="#{h "quoteReply('/issues/1/quoted', '#issue_description_wiki'); return false;"}"|
|
||
|
assert_includes a_tag, %|class="icon icon-comment"|
|
||
|
assert_not_includes a_tag, 'title='
|
||
|
# When icon_only is true
|
||
|
a_tag = quote_reply(url, '#issue_description_wiki', icon_only: true)
|
||
|
assert_includes a_tag, %|title="Quote"|
|
||
|
end
|
||
|
end
|
||