comparison app/helpers/journals_helper.rb @ 1338:25603efa57b5

Merge from live branch
author Chris Cannam
date Thu, 20 Jun 2013 13:14:14 +0100
parents 433d4f72a19b
children 622f24f53b42
comparison
equal deleted inserted replaced
1209:1b1138f6f55e 1338:25603efa57b5
1 # encoding: utf-8 1 # encoding: utf-8
2 # 2 #
3 # Redmine - project management software 3 # Redmine - project management software
4 # Copyright (C) 2006-2011 Jean-Philippe Lang 4 # Copyright (C) 2006-2012 Jean-Philippe Lang
5 # 5 #
6 # This program is free software; you can redistribute it and/or 6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License 7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2 8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version. 9 # of the License, or (at your option) any later version.
21 def render_notes(issue, journal, options={}) 21 def render_notes(issue, journal, options={})
22 content = '' 22 content = ''
23 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 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)))
24 links = [] 24 links = []
25 if !journal.notes.blank? 25 if !journal.notes.blank?
26 links << link_to_remote(image_tag('comment.png'), 26 links << link_to(image_tag('comment.png'),
27 { :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} }, 27 {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal},
28 :title => l(:button_quote)) if options[:reply_links] 28 :remote => true,
29 :method => 'post',
30 :title => l(:button_quote)) if options[:reply_links]
29 links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", 31 links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
30 { :controller => 'journals', :action => 'edit', :id => journal }, 32 { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' },
31 :title => l(:button_edit)) if editable 33 :title => l(:button_edit)) if editable
32 end 34 end
33 content << content_tag('div', links.join(' '), :class => 'contextual') unless links.empty? 35 content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
34 content << textilizable(journal, :notes) 36 content << textilizable(journal, :notes)
35 css_classes = "wiki" 37 css_classes = "wiki"
36 css_classes << " editable" if editable 38 css_classes << " editable" if editable
37 content_tag('div', content, :id => "journal-#{journal.id}-notes", :class => css_classes) 39 content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
38 end 40 end
39 41
40 def link_to_in_place_notes_editor(text, field_id, url, options={}) 42 def link_to_in_place_notes_editor(text, field_id, url, options={})
41 onclick = "new Ajax.Request('#{url_for(url)}', {asynchronous:true, evalScripts:true, method:'get'}); return false;" 43 onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
42 link_to text, '#', options.merge(:onclick => onclick) 44 link_to text, '#', options.merge(:onclick => onclick)
43 end 45 end
44 end 46 end