Module: Admin::ReferencesHelper

Included in:
PagesHelper
Defined in:
app/helpers/admin/references_helper.rb

Instance Method Summary collapse

Instance Method Details

#_display_nameObject



27
28
29
30
31
32
33
34
# File 'app/helpers/admin/references_helper.rb', line 27

def _display_name
  case params[:type]
  when 'filters'
    filter ? filter.filter_name : t('select.none')
  when 'tags'
    class_of_page.display_name
  end
end

#class_of_pageObject



42
43
44
# File 'app/helpers/admin/references_helper.rb', line 42

def class_of_page
  @page_class ||= (params[:class_name].blank? ? 'Page' : params[:class_name]).constantize
end

#filterObject



36
37
38
39
40
# File 'app/helpers/admin/references_helper.rb', line 36

def filter
  @filter ||= begin
                TextFilter.find_descendant(params[:filter_name])
              end
end

#filter_referenceObject



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

def filter_reference
  if filter.blank?
    'There is no filter on the current page part.'
  else
    if filter.description.blank?
      'There is no documentation on this filter.'
    else
      filter.description
    end
  end
end

#tag_referenceObject



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

def tag_reference
  String.new.tap do |output|
    class_of_page.tag_descriptions.sort.each do |tag_name, description|
      value = t("desc.#{tag_name.gsub(':', '-')}").match('desc') ? description : t("desc.#{tag_name.gsub(':', '-')}")
      output << render(partial: 'admin/references/tag_reference',
                       locals: { tag_name: tag_name,
                                 description: RedCloth.new(TrustyCms::Taggable::Util.strip_leading_whitespace(value)).to_html })
    end
  end
end