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