diaspora/app/helpers/aspects_helper.rb
danielgrippi 60a60733df Merge branch 'master' into follow
Conflicts:
	app/controllers/aspects_controller.rb
	app/controllers/contacts_controller.rb
	app/controllers/people_controller.rb
	app/controllers/photos_controller.rb
	app/controllers/tags_controller.rb
	app/helpers/notifications_helper.rb
	app/models/notifications/new_request.rb
	app/models/user_preference.rb
	public/javascripts/view.js
	spec/controllers/aspects_controller_spec.rb
	spec/controllers/contacts_controller_spec.rb
	spec/controllers/home_controller_spec.rb
	spec/controllers/post_visibilities_controller_spec.rb
	spec/controllers/requests_controller_spec.rb
	spec/mailers/notifier_spec.rb
	spec/models/user_spec.rb
2011-05-12 15:49:51 -07:00

48 lines
1.5 KiB
Ruby

# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module AspectsHelper
def remove_link(aspect)
if aspect.contacts.size == 0
link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure')
else
"<span class='grey' title=#{I18n.t('aspects.helper.aspect_not_empty')}>#{I18n.t('aspects.helper.remove')}</span>"
end
end
def add_to_aspect_button(aspect_id, person_id)
link_to image_tag('icons/monotone_plus_add_round.png'),
{:controller => 'aspect_memberships',
:action => 'create',
:aspect_id => aspect_id,
:person_id => person_id},
:remote => true,
:method => 'post',
:class => 'add button',
'data-aspect_id' => aspect_id,
'data-person_id' => person_id
end
def remove_from_aspect_button(aspect_id, person_id)
link_to image_tag('icons/monotone_check_yes.png'),
{:controller => "aspect_memberships",
:action => 'destroy',
:id => 42,
:aspect_id => aspect_id,
:person_id => person_id},
:remote => true,
:method => 'delete',
:class => 'added button',
'data-aspect_id' => aspect_id,
'data-person_id' => person_id
end
def aspect_membership_button(aspect, contact, person)
if contact.nil? || !aspect.contacts.include?(contact)
add_to_aspect_button(aspect.id, person.id)
else
remove_from_aspect_button(aspect.id, person.id)
end
end
end