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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2019 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?) : []
  23. end
  24. # Returns the action links for an issue journal
  25. def render_journal_actions(issue, journal, options={})
  26. links = []
  27. if journal.notes.present?
  28. if options[:reply_links]
  29. links << link_to(l(:button_quote),
  30. quoted_issue_path(issue, :journal_id => journal),
  31. :remote => true,
  32. :method => 'post',
  33. :title => l(:button_quote),
  34. :class => 'icon-only icon-comment'
  35. )
  36. end
  37. if journal.editable_by?(User.current)
  38. links << link_to(l(:button_edit),
  39. edit_journal_path(journal),
  40. :remote => true,
  41. :method => 'get',
  42. :title => l(:button_edit),
  43. :class => 'icon-only icon-edit'
  44. )
  45. links << link_to(l(:button_delete),
  46. journal_path(journal, :journal => {:notes => ""}),
  47. :remote => true,
  48. :method => 'put', :data => {:confirm => l(:text_are_you_sure)},
  49. :title => l(:button_delete),
  50. :class => 'icon-only icon-del'
  51. )
  52. end
  53. end
  54. safe_join(links, ' ')
  55. end
  56. def render_notes(issue, journal, options={})
  57. content_tag('div', textilizable(journal, :notes), :id => "journal-#{journal.id}-notes", :class => "wiki")
  58. end
  59. def render_private_notes_indicator(journal)
  60. content = journal.private_notes? ? l(:field_is_private) : ''
  61. css_classes = journal.private_notes? ? 'badge badge-private private' : ''
  62. content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
  63. end
  64. end