Module: AspectsHelper

Defined in:
app/helpers/aspects_helper.rb

Overview

Copyright © 2010-2011, 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

#add_to_aspect_button(aspect_id, person_id) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/aspects_helper.rb', line 6

def add_to_aspect_button(aspect_id, person_id)
  link_to (:div, nil, :class => 'icons-monotone_plus_add_round'),
    { :controller => 'aspect_memberships',
      :action => 'create',
      :format => :json,
      :aspect_id => aspect_id,
      :person_id => person_id
    },
    :method => 'post',
    :class => 'add btn',
    'data-aspect_id' => aspect_id,
    'data-person_id' => person_id
end

#aspect_membership_button(aspect, contact, person) ⇒ Object


33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/aspects_helper.rb', line 33

def aspect_membership_button(aspect, contact, person)
  return if person && person.closed_account?

  membership = contact.aspect_memberships.where(:aspect_id => aspect.id).first
  if contact.nil? || membership.nil?
    add_to_aspect_button(aspect.id, person.id)
  else
    remove_from_aspect_button(membership.id, aspect.id, person.id)
  end
end

44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/aspects_helper.rb', line 44

def aspect_visibility_link(aspect)
  if aspect.contacts_visible?
    icon = 'icons-padlock-open'
    title = t('aspects.edit.aspect_list_is_visible');
  else
    icon = 'icons-padlock-closed'
    title = t('aspects.edit.aspect_list_is_not_visible');
  end
  
  link_to aspect_toggle_contact_visibility_path(@aspect), class: 'contact_visibility_link btn', title: title, method: :put, remote: true do
    concat t('aspects.edit.set_visibility')
    concat (:span, nil, class: "contact_visibility_padlock " + icon)
  end
end

#remove_from_aspect_button(membership_id, aspect_id, person_id) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/aspects_helper.rb', line 20

def remove_from_aspect_button(membership_id, aspect_id, person_id)
  link_to (:div, nil, :class => 'icons-monotone_check_yes'),
    { :controller => "aspect_memberships",
      :action => 'destroy',
      :id => membership_id
    },
    :method => 'delete',
    :class => 'added btn',
    'data-membership_id' => membership_id,
    'data-aspect_id' => aspect_id,
    'data-person_id' => person_id
end