Module: AspectsHelper

Defined in:
app/helpers/aspects_helper.rb

Overview

Copyright © 2010, Diaspora Inc. This file is

  licensed under the Affero General Public License version 3 or later.  See
  the COPYRIGHT file.

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_to_aspect_button(aspect_id, person_id)



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/aspects_helper.rb', line 14

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

- (Object) aspect_membership_button(aspect, contact, person)



41
42
43
44
45
46
47
# File 'app/helpers/aspects_helper.rb', line 41

def aspect_membership_button(aspect, contact, person)
  if contact.nil? || !contact.aspect_memberships.detect{ |am| am.aspect_id == aspect.id}
    add_to_aspect_button(aspect.id, person.id)
  else
    remove_from_aspect_button(aspect.id, person.id)
  end
end

- (Object) remove_from_aspect_button(aspect_id, person_id)



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/aspects_helper.rb', line 27

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


6
7
8
9
10
11
12
# File 'app/helpers/aspects_helper.rb', line 6

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