Module: Pageflow::Admin::MembershipsHelper

Defined in:
app/helpers/pageflow/admin/memberships_helper.rb

Overview

Since:

  • 12.2

Instance Method Summary collapse

Instance Method Details

#membership_entity_select(f, parent, entity_type) ⇒ Object

Since:

  • 12.2



15
16
17
18
19
20
21
# File 'app/helpers/pageflow/admin/memberships_helper.rb', line 15

def membership_entity_select(f, parent, entity_type)
  if entity_type == 'Pageflow::Entry'
    membership_entry_select(f, parent)
  else
    (f, parent)
  end
end

#membership_roles_collection(entity_type) ⇒ Object

Since:

  • 12.2



23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/pageflow/admin/memberships_helper.rb', line 23

def membership_roles_collection(entity_type)
  default_options = [[I18n.t('pageflow.admin.users.roles.previewer'), :previewer],
                     [I18n.t('pageflow.admin.users.roles.editor'), :editor],
                     [I18n.t('pageflow.admin.users.roles.publisher'), :publisher],
                     [I18n.t('pageflow.admin.users.roles.manager'), :manager]]

  if entity_type == 'Pageflow::Account'
    [[I18n.t('pageflow.admin.users.roles.member'), :member]] + default_options
  else
    default_options
  end
end

#membership_user_select(f, parent) ⇒ Object

Since:

  • 12.2



4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/pageflow/admin/memberships_helper.rb', line 4

def membership_user_select(f, parent)
  if f.object.persisted?
    membership_disabled_select(f, :user, f.object.user, :formal_name)
  elsif parent.is_a?(User)
    membership_disabled_select(f, :user, parent, :formal_name)
  else
    parent_type = parent.class.model_name.singular_route_key
    membership_select(f, :user, parent, :"potential_users_for_#{parent_type}")
  end
end