Module: AppyantraAdmin::ApplicationHelper

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

Instance Method Summary collapse

Instance Method Details

#asset_display_field(asset_class_name) ⇒ Object

displays the name of the first field of a model



28
29
30
31
# File 'app/helpers/appyantra_admin/application_helper.rb', line 28

def asset_display_field(asset_class_name)
  asset_class = eval asset_class_name
  asset_class.column_names[1].capitalize
end

#asset_display_name(asset) ⇒ Object

displays the value of the first field of a model object (asset)



34
35
36
37
# File 'app/helpers/appyantra_admin/application_helper.rb', line 34

def asset_display_name(asset)
  field_name = asset.class.column_names[1]
  asset[field_name]
end


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

def breadcrumb
  breadcrumb_html = ''
  if @breadcrumbs
    while !@breadcrumbs.empty? do
      curr_breadcrumb = @breadcrumbs.pop
      breadcrumb_html << "<a href='#{curr_breadcrumb[1]}'>#{curr_breadcrumb[0]}</a><div class='breadcrumb_divider'></div>"          
    end
    breadcrumb_html << "<a class='current'>#{@current_breadcrumb}</a>"
  end
  breadcrumb_html
end

#display_date(date) ⇒ Object



2
3
4
# File 'app/helpers/appyantra_admin/application_helper.rb', line 2

def display_date(date)
  date.strftime("%m-%d-%Y %H:%M")
end

#fetch_activity_feedsObject



70
71
72
# File 'app/helpers/appyantra_admin/application_helper.rb', line 70

def fetch_activity_feeds
  ActivityFeed.latest
end

#google_analytics_scriptObject



61
62
63
64
65
66
67
68
# File 'app/helpers/appyantra_admin/application_helper.rb', line 61

def google_analytics_script
  analytics_settings = AdminSetting.group_settings('Google Analytics')
  if analytics_settings.has_key?(:tracking_code) && analytics_settings.has_key?(:domain)
    tracking_code = analytics_settings[:tracking_code]
    domain = analytics_settings[:domain]
    render partial: '/pages/google_analytics', locals: { analytics_tracking_code: tracking_code, analytics_domain: domain }
  end
end

#include_rich_text_editorObject



55
56
57
58
59
# File 'app/helpers/appyantra_admin/application_helper.rb', line 55

def include_rich_text_editor
  if AdminSetting.value_of('rich_text_editor') == 'ckeditor'
    javascript_include_tag "ckeditor/ckeditor.js"
  end
end

#page_titleObject



39
40
41
42
43
44
45
# File 'app/helpers/appyantra_admin/application_helper.rb', line 39

def page_title
  if @page
    @page.title
  elsif @page_title
    @page_title
  end
end

#path_for(slug) ⇒ Object



47
48
49
50
51
52
53
# File 'app/helpers/appyantra_admin/application_helper.rb', line 47

def path_for slug
  if Page.where(slug: slug).exists?
    main_app.display_page_path(slug)
  else
    '#'
  end
end

#setting_value(entity_name, default = 'Not Set') ⇒ Object



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

def setting_value(entity_name, default='Not Set')
  setting = AdminSetting.find_by_name(entity_name)
  if setting && setting.entity
    render partial: "/appyantra_admin/shared/types/#{setting.entity.class.name.underscore}", locals: { entity: setting.entity}
  else
    default  
  end  
end