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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # encoding: utf-8
  2. #
  3. # Redmine - project management software
  4. # Copyright (C) 2006-2013 Jean-Philippe Lang
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. module JournalsHelper
  20. def render_notes(issue, journal, options={})
  21. content = ''
  22. editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project)))
  23. links = []
  24. if !journal.notes.blank?
  25. links << link_to(image_tag('comment.png'),
  26. {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal},
  27. :remote => true,
  28. :method => 'post',
  29. :title => l(:button_quote)) if options[:reply_links]
  30. links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
  31. { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' },
  32. :title => l(:button_edit)) if editable
  33. end
  34. content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
  35. content << textilizable(journal, :notes)
  36. css_classes = "wiki"
  37. css_classes << " editable" if editable
  38. content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
  39. end
  40. def link_to_in_place_notes_editor(text, field_id, url, options={})
  41. onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
  42. link_to text, '#', options.merge(:onclick => onclick)
  43. end
  44. end