Module: Cortex::ApplicationHelper

Defined in:
app/helpers/cortex/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#cortex_propsObject



43
44
45
46
47
48
# File 'app/helpers/cortex/application_helper.rb', line 43

def cortex_props
  user_session_props.merge({
                             wizard: wizard_props,
                             index: index_props
                           })
end

#environmentObject



58
59
60
# File 'app/helpers/cortex/application_helper.rb', line 58

def environment
  request.local? ? :local : Rails.env
end

#environment_abbreviatedObject



62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/helpers/cortex/application_helper.rb', line 62

def environment_abbreviated
  case environment
    when 'production'
      :prd
    when 'staging'
      :stg
    when 'development'
      :dev
    else
      :loc
  end
end

#extra_configObject



11
12
13
# File 'app/helpers/cortex/application_helper.rb', line 11

def extra_config
  Cortex.config[:extra]
end

#flag_enabled?(flag_name) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/helpers/cortex/application_helper.rb', line 54

def flag_enabled?(flag_name)
  Flipper.enabled?(flag_name, current_user, request)
end

#index_propsObject



39
40
41
# File 'app/helpers/cortex/application_helper.rb', line 39

def index_props
  @index || {}
end

#qualtrics_domainObject



50
51
52
# File 'app/helpers/cortex/application_helper.rb', line 50

def qualtrics_domain
  extra_config[:qualtrics_id].delete('_').downcase
end

#titleObject



5
6
7
8
9
# File 'app/helpers/cortex/application_helper.rb', line 5

def title
  title = 'Cortex Administration'
  title += " | #{render_breadcrumbs builder: TitleBuilder}" if render_breadcrumbs
  title
end

#user_session_propsObject



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

def user_session_props
  {
    environment: environment,
    active_tenant: current_user.active_tenant,
    current_user: current_user,
    tenants: current_user.tenants_with_children,
    csrf_token: form_authenticity_token,
    sidebarExpanded: (current_page? cortex.root_path),
    environment_abbreviated: environment_abbreviated
  }
end

#wizard_propsObject



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

def wizard_props
  if @wizard
    @wizard.data.merge({
                         content_type: @content_type,
                         content_item: @content_item,
                         fields: @content_type.fields
                       })
  else
    {}
  end
end