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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006- 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. journal.attachments.select(&:thumbnailable?)
  22. end
  23. # Returns the action links for an issue journal
  24. def render_journal_actions(issue, journal, options={})
  25. links = []
  26. dropbown_links = []
  27. indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
  28. dropbown_links << copy_object_url_link(issue_url(issue, anchor: "note-#{indice}", only_path: false))
  29. if journal.attachments.size > 1
  30. dropbown_links << link_to(l(:label_download_all_attachments),
  31. container_attachments_download_path(journal),
  32. :title => l(:label_download_all_attachments),
  33. :class => 'icon icon-download'
  34. )
  35. end
  36. if journal.notes.present?
  37. if options[:reply_links]
  38. links << link_to(l(:button_quote),
  39. quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice),
  40. :remote => true,
  41. :method => 'post',
  42. :title => l(:button_quote),
  43. :class => 'icon-only icon-comment'
  44. )
  45. end
  46. if journal.editable_by?(User.current)
  47. links << link_to(l(:button_edit),
  48. edit_journal_path(journal),
  49. :remote => true,
  50. :method => 'get',
  51. :title => l(:button_edit),
  52. :class => 'icon-only icon-edit'
  53. )
  54. dropbown_links << link_to(l(:button_delete),
  55. journal_path(journal, :journal => {:notes => ""}),
  56. :remote => true,
  57. :method => 'put',
  58. :data => {:confirm => l(:text_are_you_sure)},
  59. :class => 'icon icon-del'
  60. )
  61. end
  62. end
  63. safe_join(links, ' ') + actions_dropdown {safe_join(dropbown_links, ' ')}
  64. end
  65. def render_notes(issue, journal, options={})
  66. content_tag('div', textilizable(journal, :notes), :id => "journal-#{journal.id}-notes", :class => "wiki")
  67. end
  68. def render_private_notes_indicator(journal)
  69. content = journal.private_notes? ? l(:field_is_private) : ''
  70. css_classes = journal.private_notes? ? 'badge badge-private private' : ''
  71. content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
  72. end
  73. def render_journal_update_info(journal)
  74. return if journal.created_on == journal.updated_on
  75. content_tag('span', "· #{l(:label_edited)}", :title => l(:label_time_by_author, :time => format_time(journal.updated_on), :author => journal.updated_by), :class => 'update-info')
  76. end
  77. end