socialforge/app/helpers/no_uses_helper.rb

23 lines
917 B
Ruby
Raw Normal View History

module NoUsesHelper
def no_use_link(objects, user, options=[])
return '' unless user && user.logged?
objects = Array.wrap(objects)
clicked = objects.any? {|object| object.no_use_for?(user)}
# @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Bid)))
# css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
# ([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
text = clicked ? ("123") : ("231")
url = apply_project_master_path(
:object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
)
method = clicked ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method
#, :class => css
end
end