journals_helper.rb
46 lines
| 2.3 KiB
| text/x-ruby
|
RubyLexer
|
r8090 | # encoding: utf-8 | ||
# | ||||
|
r6718 | # Redmine - project management software | ||
|
r9453 | # Copyright (C) 2006-2012 Jean-Philippe Lang | ||
|
r1091 | # | ||
# This program is free software; you can redistribute it and/or | ||||
# modify it under the terms of the GNU General Public License | ||||
# as published by the Free Software Foundation; either version 2 | ||||
# of the License, or (at your option) any later version. | ||||
|
r6718 | # | ||
|
r1091 | # This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | ||||
|
r6718 | # | ||
|
r1091 | # You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
module JournalsHelper | ||||
|
r3480 | def render_notes(issue, journal, options={}) | ||
|
r1091 | content = '' | ||
|
r3480 | 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))) | ||
|
r1466 | links = [] | ||
if !journal.notes.blank? | ||||
|
r9855 | links << link_to(image_tag('comment.png'), | ||
{:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal}, | ||||
:remote => true, | ||||
:method => 'post', | ||||
:title => l(:button_quote)) if options[:reply_links] | ||||
|
r6718 | links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", | ||
|
r9885 | { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' }, | ||
|
r1466 | :title => l(:button_edit)) if editable | ||
|
r1091 | end | ||
|
r8331 | content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? | ||
|
r1091 | content << textilizable(journal, :notes) | ||
|
r2743 | css_classes = "wiki" | ||
css_classes << " editable" if editable | ||||
|
r8149 | content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) | ||
|
r1091 | end | ||
|
r6718 | |||
|
r1091 | def link_to_in_place_notes_editor(text, field_id, url, options={}) | ||
|
r9885 | onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;" | ||
|
r1091 | link_to text, '#', options.merge(:onclick => onclick) | ||
end | ||||
end | ||||