socialforge/app/helpers/bids_helper.rb

32 lines
1.4 KiB
Ruby
Raw Normal View History

2013-08-01 10:33:49 +08:00
module BidsHelper
def render_notes(bid, journal, options={})
content = ''
removable = User.current == journal.user || User.current == bid.author
links = []
if !journal.notes.blank?
links << link_to(image_tag('comment.png'),
{:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal},
:remote => true,
:method => 'post',
:title => l(:button_quote)) if options[:reply_links]
if removable
url = {:controller => 'bids',
:action => 'destroy',
:object_id => journal,
:bid_id => bid}
links << ' '
links << link_to(image_tag('delete.png'), url,
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete))
end
end
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
content << textilizable(journal.notes)
css_classes = "wiki"
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
end
def link_to_in_place_notes_editor(text, field_id, url, options={})
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
link_to text, '#', options.merge(:onclick => onclick)
end
end