Module: Refinery::Admin::PagesHelper
- Defined in:
- app/helpers/refinery/admin/pages_helper.rb
Instance Method Summary collapse
- #default_layout_template(current_page) ⇒ Object
- #default_view_template(current_page) ⇒ Object
- #page_icon(number_of_children) ⇒ Object
-
#page_meta_information(page) ⇒ Object
In the admin area we use a slightly different title to inform the which pages are draft or hidden pages.
- #parent_id_nested_set_options(current_page) ⇒ Object
- #template_options(template_type, current_page) ⇒ Object
Instance Method Details
#default_layout_template(current_page) ⇒ Object
35 36 37 |
# File 'app/helpers/refinery/admin/pages_helper.rb', line 35 def default_layout_template(current_page) "application" end |
#default_view_template(current_page) ⇒ Object
31 32 33 |
# File 'app/helpers/refinery/admin/pages_helper.rb', line 31 def default_view_template(current_page) current_page.link_url == "/" ? "home" : "show" end |
#page_icon(number_of_children) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/helpers/refinery/admin/pages_helper.rb', line 62 def page_icon(number_of_children) # 1. has_children 'folder|folderopen', 'toggle' # 2. no_children 'page' # .toggle scss handles adding icons to pages with children classes = ['icon'] if number_of_children.zero? classes.push icon_class('page') title = ::I18n.t('edit', scope: 'refinery.admin.pages.page') else = Refinery::Pages. ? 'expanded' : '' classes.push 'toggle', title = ::I18n.t('expand_collapse', scope: 'refinery.admin.pages') end tag.span(class: classes.join(' '), title: title) end |
#page_meta_information(page) ⇒ Object
In the admin area we use a slightly different title to inform the which pages are draft or hidden pages
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/refinery/admin/pages_helper.rb', line 41 def (page) = ActiveSupport::SafeBuffer.new << content_tag(:span, :class => 'label') do ::I18n.t('hidden', :scope => 'refinery.admin.pages.page') end unless page. << content_tag(:span, :class => 'label') do ::I18n.t('skip_to_first_child', :scope => 'refinery.admin.pages.page') end if page.skip_to_first_child? << content_tag(:span, :class => 'label') do ::I18n.t('redirected', :scope => 'refinery.admin.pages.page') end if page.link_url? << content_tag(:span, :class => 'label notice') do ::I18n.t('draft', :scope => 'refinery.admin.pages.page') end if page.draft? tag.span , class: :meta end |
#parent_id_nested_set_options(current_page) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/refinery/admin/pages_helper.rb', line 4 def (current_page) pages = [] (::Refinery::Page, current_page) { |page| pages << page } # page.title needs the :translations association, doing something like # nested_set_options(::Refinery::Page.includes(:translations), page) doesn't work, yet. # See https://github.com/collectiveidea/awesome_nested_set/pull/123 if Rails::VERSION::MAJOR >= 7 ActiveRecord::Associations::Preloader.new(records: pages, associations: :translations).call else ActiveRecord::Associations::Preloader.new.preload(pages, :translations) end pages.map { |page| ["#{'-' * page.level} #{page.title}", page.id] } end |
#template_options(template_type, current_page) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/refinery/admin/pages_helper.rb', line 18 def (template_type, current_page) = { selected: send("default_#{template_type}", current_page) } if (template = current_page.send(template_type).presence) .update selected: template elsif current_page.parent_id? && !current_page.send(template_type).presence template = current_page.parent.send(template_type).presence .update selected: template if template end end |