Sha256: 358fe30d6f0c8430dd081cdca8beda8f0718426fc5812f09325b092e24f20d60

Contents?: true

Size: 1.23 KB

Versions: 14

Compression:

Stored size: 1.23 KB

Contents

module Locomotive
  module PagesHelper

    def parent_pages_options
      [].tap do |list|
        build_page_tree.each do |(page, children)|
          next if page.not_found?

          add_children_to_options(page, children, list)
        end
      end
    end

    def add_children_to_options(page, children, list)
      return list if page.parent_ids.include?(@page.id) || page == @page

      offset = '- ' * (page.depth || 0) * 2

      list << ["#{offset}#{page.title}", page.id]

      if children
        children.each { |(_page, _children)| add_children_to_options(_page, _children, list) }
      end

      list
    end

    def display_page_layouts?
      ((@page.persisted? && @page.allow_layout?) || !@page.persisted?) &&
      !current_site.pages.layouts.empty?
    end

    def options_for_page_layouts
      layouts = current_site.pages.layouts.map do |_layout|
        [_layout.title, _layout._id]
      end
      @page.index? ? layouts : [[t(:no_layout, scope: 'locomotive.pages.form'), 'parent']] + layouts
    end

    def options_for_page_redirect_type
      [
        [t('redirect_type.permanent', scope: 'locomotive.pages.form'), 301],
        [t('redirect_type.temporary', scope: 'locomotive.pages.form'), 302]
      ]
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
locomotivecms-3.1.2 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.1.1 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.1.0 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.1.0.rc3 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.1.0.rc2 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.1.0.rc1 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.1 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.0 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.0.rc7 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.0.rc6 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.0.rc5 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.0.rc4 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.0.rc3 app/helpers/locomotive/pages_helper.rb
locomotivecms-3.0.0.rc2 app/helpers/locomotive/pages_helper.rb