@@ -1,57 +1,63 | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | # |
|
2 | # | |
3 | # Redmine - project management software |
|
3 | # Redmine - project management software | |
4 | # Copyright (C) 2006-2015 Jean-Philippe Lang |
|
4 | # Copyright (C) 2006-2015 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. | |
10 | # |
|
10 | # | |
11 | # This program is distributed in the hope that it will be useful, |
|
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. |
|
14 | # GNU General Public License for more details. | |
15 | # |
|
15 | # | |
16 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 |
|
19 | |||
20 | module JournalsHelper |
|
20 | module JournalsHelper | |
21 |
|
21 | |||
22 | # Returns the attachments of a journal that are displayed as thumbnails |
|
22 | # Returns the attachments of a journal that are displayed as thumbnails | |
23 | def journal_thumbnail_attachments(journal) |
|
23 | def journal_thumbnail_attachments(journal) | |
24 | ids = journal.details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key) |
|
24 | ids = journal.details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key) | |
25 | ids.any? ? Attachment.where(:id => ids).select(&:thumbnailable?) : [] |
|
25 | ids.any? ? Attachment.where(:id => ids).select(&:thumbnailable?) : [] | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def render_notes(issue, journal, options={}) |
|
28 | def render_notes(issue, journal, options={}) | |
29 | content = '' |
|
29 | content = '' | |
30 | 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))) |
|
30 | 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))) | |
31 | links = [] |
|
31 | links = [] | |
32 | if !journal.notes.blank? |
|
32 | if !journal.notes.blank? | |
33 | links << link_to('', |
|
33 | links << link_to('', | |
34 | {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal}, |
|
34 | {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal}, | |
35 | :remote => true, |
|
35 | :remote => true, | |
36 | :method => 'post', |
|
36 | :method => 'post', | |
37 | :title => l(:button_quote), |
|
37 | :title => l(:button_quote), | |
38 | :class => 'icon-only icon-comment' |
|
38 | :class => 'icon-only icon-comment' | |
39 | ) if options[:reply_links] |
|
39 | ) if options[:reply_links] | |
40 | links << link_to_in_place_notes_editor('', "journal-#{journal.id}-notes", |
|
40 | links << link_to_in_place_notes_editor('', "journal-#{journal.id}-notes", | |
41 | { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' }, |
|
41 | { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' }, | |
42 | :title => l(:button_edit), |
|
42 | :title => l(:button_edit), | |
43 | :class => 'icon-only icon-edit' |
|
43 | :class => 'icon-only icon-edit' | |
44 | ) if editable |
|
44 | ) if editable | |
|
45 | links << link_to('', | |||
|
46 | {:controller => 'journals', :action => 'edit', :id => journal, :notes => ""}, | |||
|
47 | :remote => true, | |||
|
48 | :method => :post, :data => {:confirm => l(:text_are_you_sure)}, | |||
|
49 | :title => l(:button_delete), | |||
|
50 | :class => 'icon-only icon-del') if editable | |||
45 | end |
|
51 | end | |
46 | content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? |
|
52 | content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? | |
47 | content << textilizable(journal, :notes) |
|
53 | content << textilizable(journal, :notes) | |
48 | css_classes = "wiki" |
|
54 | css_classes = "wiki" | |
49 | css_classes << " editable" if editable |
|
55 | css_classes << " editable" if editable | |
50 | content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) |
|
56 | content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) | |
51 | end |
|
57 | end | |
52 |
|
58 | |||
53 | def link_to_in_place_notes_editor(text, field_id, url, options={}) |
|
59 | def link_to_in_place_notes_editor(text, field_id, url, options={}) | |
54 | onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;" |
|
60 | onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;" | |
55 | link_to text, '#', options.merge(:onclick => onclick) |
|
61 | link_to text, '#', options.merge(:onclick => onclick) | |
56 | end |
|
62 | end | |
57 | end |
|
63 | end |
General Comments 0
You need to be logged in to leave comments.
Login now