Class: Pageflow::Admin::MembersTab

Inherits:
ViewComponent
  • Object
show all
Defined in:
app/views/components/pageflow/admin/members_tab.rb

Instance Method Summary collapse

Methods inherited from ViewComponent

builder_method

Instance Method Details

#build(entry) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/views/components/pageflow/admin/members_tab.rb', line 4

def build(entry)
  if entry.memberships.any?
    table_for entry.memberships, :class => 'memberships' do
      column t('activerecord.attributes.user.full_name') do |membership|
        if authorized? :manage, User
          link_to membership.user.full_name, admin_user_path(membership.user), :class => 'view_creator'
        else
          membership.user.full_name
        end
      end
      column do |membership|
        if authorized?(:destroy, membership)
          link_to(I18n.t('admin.entries.remove'), admin_entry_membership_path(membership.entry, membership), :method => :delete, :data => {:confirm => I18n.t('active_admin.delete_confirmation'), :rel => 'delete_membership'})
        end
      end
    end
  else
    div :class => "blank_slate_container" do
      span :class => "blank_slate" do
        I18n.t('admin.entries.no_members')
      end
    end
  end
  if authorized? :manage, Pageflow::Entry
    span do
      link_to I18n.t('admin.users.add'), new_admin_entry_membership_path(entry), :class => 'button', :data => {:rel => 'add_member'}
    end
  end
end