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

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