To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / helpers / journals_helper.rb @ 1298:4f746d8966dd
History | View | Annotate | Download (2.27 KB)
| 1 | 909:cbb26bc654de | Chris | # encoding: utf-8
|
|---|---|---|---|
| 2 | #
|
||
| 3 | # Redmine - project management software
|
||
| 4 | 1295:622f24f53b42 | Chris | # Copyright (C) 2006-2013 Jean-Philippe Lang
|
| 5 | 0:513646585e45 | Chris | #
|
| 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 | 909:cbb26bc654de | Chris | #
|
| 11 | 0:513646585e45 | Chris | # 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 | 909:cbb26bc654de | Chris | #
|
| 16 | 0:513646585e45 | Chris | # 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 | |||
| 20 | module JournalsHelper |
||
| 21 | def render_notes(issue, journal, options={}) |
||
| 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))) |
||
| 24 | links = [] |
||
| 25 | if !journal.notes.blank?
|
||
| 26 | 1115:433d4f72a19b | Chris | links << link_to(image_tag('comment.png'),
|
| 27 | {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal},
|
||
| 28 | :remote => true, |
||
| 29 | :method => 'post', |
||
| 30 | :title => l(:button_quote)) if options[:reply_links] |
||
| 31 | 909:cbb26bc654de | Chris | links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", |
| 32 | 1115:433d4f72a19b | Chris | { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' },
|
| 33 | 0:513646585e45 | Chris | :title => l(:button_edit)) if editable |
| 34 | end
|
||
| 35 | 1115:433d4f72a19b | Chris | content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? |
| 36 | 0:513646585e45 | Chris | content << textilizable(journal, :notes)
|
| 37 | css_classes = "wiki"
|
||
| 38 | css_classes << " editable" if editable |
||
| 39 | 1115:433d4f72a19b | Chris | content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) |
| 40 | 0:513646585e45 | Chris | end
|
| 41 | 909:cbb26bc654de | Chris | |
| 42 | 0:513646585e45 | Chris | def link_to_in_place_notes_editor(text, field_id, url, options={}) |
| 43 | 1115:433d4f72a19b | Chris | onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
| 44 | 0:513646585e45 | Chris | link_to text, '#', options.merge(:onclick => onclick) |
| 45 | end
|
||
| 46 | end |