You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

journals_helper.rb 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2021 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. module JournalsHelper
  19. # Returns the attachments of a journal that are displayed as thumbnails
  20. def journal_thumbnail_attachments(journal)
  21. ids = journal.details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
  22. ids.any? ? Attachment.where(:id => ids).select(&:thumbnailable?).sort_by{|a| ids.index(a.id.to_s)} : []
  23. end
  24. # Returns the action links for an issue journal
  25. def render_journal_actions(issue, journal, options={})
  26. links = []
  27. dropbown_links = []
  28. indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
  29. dropbown_links << copy_object_url_link(issue_url(issue, anchor: "note-#{indice}", only_path: false))
  30. if journal.notes.present?
  31. if options[:reply_links]
  32. links << link_to(l(:button_quote),
  33. quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice),
  34. :remote => true,
  35. :method => 'post',
  36. :title => l(:button_quote),
  37. :class => 'icon-only icon-comment'
  38. )
  39. end
  40. if journal.editable_by?(User.current)
  41. links << link_to(l(:button_edit),
  42. edit_journal_path(journal),
  43. :remote => true,
  44. :method => 'get',
  45. :title => l(:button_edit),
  46. :class => 'icon-only icon-edit'
  47. )
  48. dropbown_links << link_to(l(:button_delete),
  49. journal_path(journal, :journal => {:notes => ""}),
  50. :remote => true,
  51. :method => 'put', :data => {:confirm => l(:text_are_you_sure)},
  52. :class => 'icon icon-del'
  53. )
  54. end
  55. end
  56. safe_join(links, ' ') + actions_dropdown {safe_join(dropbown_links, ' ')}
  57. end
  58. def render_notes(issue, journal, options={})
  59. content_tag('div', textilizable(journal, :notes), :id => "journal-#{journal.id}-notes", :class => "wiki")
  60. end
  61. def render_private_notes_indicator(journal)
  62. content = journal.private_notes? ? l(:field_is_private) : ''
  63. css_classes = journal.private_notes? ? 'badge badge-private private' : ''
  64. content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
  65. end
  66. end