2019-03-16 10:37:35 +01:00
|
|
|
# frozen_string_literal: true
|
2019-03-15 02:32:57 +01:00
|
|
|
|
2011-08-31 07:04:17 +02:00
|
|
|
# Redmine - project management software
|
2022-01-02 06:29:10 +01:00
|
|
|
# Copyright (C) 2006-2022 Jean-Philippe Lang
|
2008-02-02 11:50:31 +01:00
|
|
|
#
|
|
|
|
# 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.
|
2011-08-31 07:04:17 +02:00
|
|
|
#
|
2008-02-02 11:50:31 +01:00
|
|
|
# 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.
|
2011-08-31 07:04:17 +02:00
|
|
|
#
|
2008-02-02 11:50:31 +01:00
|
|
|
# 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 JournalsHelper
|
2015-10-24 07:51:14 +02:00
|
|
|
|
|
|
|
# Returns the attachments of a journal that are displayed as thumbnails
|
|
|
|
def journal_thumbnail_attachments(journal)
|
|
|
|
ids = journal.details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
|
2021-03-09 15:21:55 +01:00
|
|
|
ids.any? ? Attachment.where(:id => ids).select(&:thumbnailable?).sort_by{|a| ids.index(a.id.to_s)} : []
|
2015-10-24 07:51:14 +02:00
|
|
|
end
|
|
|
|
|
2017-07-27 19:14:47 +02:00
|
|
|
# Returns the action links for an issue journal
|
|
|
|
def render_journal_actions(issue, journal, options={})
|
2008-05-30 19:42:25 +02:00
|
|
|
links = []
|
2021-03-07 07:46:41 +01:00
|
|
|
dropbown_links = []
|
2021-03-18 04:58:29 +01:00
|
|
|
indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
|
|
|
|
|
|
|
|
dropbown_links << copy_object_url_link(issue_url(issue, anchor: "note-#{indice}", only_path: false))
|
2021-11-22 09:42:44 +01:00
|
|
|
if journal.attachments.size > 1
|
|
|
|
dropbown_links << link_to(l(:label_download_all_attachments),
|
|
|
|
container_attachments_download_path(journal),
|
|
|
|
:title => l(:label_download_all_attachments),
|
|
|
|
:class => 'icon icon-download'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2016-07-10 13:03:41 +02:00
|
|
|
if journal.notes.present?
|
2017-07-27 19:14:47 +02:00
|
|
|
if options[:reply_links]
|
|
|
|
links << link_to(l(:button_quote),
|
2019-06-21 09:23:16 +02:00
|
|
|
quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice),
|
2017-07-27 19:14:47 +02:00
|
|
|
:remote => true,
|
|
|
|
:method => 'post',
|
|
|
|
:title => l(:button_quote),
|
|
|
|
:class => 'icon-only icon-comment'
|
|
|
|
)
|
|
|
|
end
|
2016-07-10 13:03:41 +02:00
|
|
|
if journal.editable_by?(User.current)
|
|
|
|
links << link_to(l(:button_edit),
|
|
|
|
edit_journal_path(journal),
|
|
|
|
:remote => true,
|
|
|
|
:method => 'get',
|
|
|
|
:title => l(:button_edit),
|
|
|
|
:class => 'icon-only icon-edit'
|
|
|
|
)
|
2021-03-07 07:46:41 +01:00
|
|
|
dropbown_links << link_to(l(:button_delete),
|
|
|
|
journal_path(journal, :journal => {:notes => ""}),
|
|
|
|
:remote => true,
|
2021-12-10 06:53:38 +01:00
|
|
|
:method => 'put',
|
|
|
|
:data => {:confirm => l(:text_are_you_sure)},
|
2021-03-07 07:46:41 +01:00
|
|
|
:class => 'icon icon-del'
|
|
|
|
)
|
2016-07-10 13:03:41 +02:00
|
|
|
end
|
2008-02-02 11:50:31 +01:00
|
|
|
end
|
2021-03-07 07:46:41 +01:00
|
|
|
safe_join(links, ' ') + actions_dropdown {safe_join(dropbown_links, ' ')}
|
2017-07-27 19:14:47 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def render_notes(issue, journal, options={})
|
|
|
|
content_tag('div', textilizable(journal, :notes), :id => "journal-#{journal.id}-notes", :class => "wiki")
|
2008-02-02 11:50:31 +01:00
|
|
|
end
|
2016-07-10 12:33:48 +02:00
|
|
|
|
2016-07-10 13:04:59 +02:00
|
|
|
def render_private_notes_indicator(journal)
|
2016-07-10 12:33:48 +02:00
|
|
|
content = journal.private_notes? ? l(:field_is_private) : ''
|
2019-04-09 16:45:52 +02:00
|
|
|
css_classes = journal.private_notes? ? 'badge badge-private private' : ''
|
2016-07-10 12:33:48 +02:00
|
|
|
content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
|
|
|
|
end
|
2008-02-02 11:50:31 +01:00
|
|
|
end
|