Sha256: 42b050d36925db4f5fb3dfb5d526ec22c5f04b709e5aa14e7be1845b30e2c95e

Contents?: true

Size: 795 Bytes

Versions: 18

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Feature pages
  class FeaturePage < Spotlight::Page
    extend FriendlyId
    friendly_id :title, use: [:slugged, :scoped, :finders, :history], scope: [:exhibit, :locale]

    has_many :child_pages, class_name: 'Spotlight::FeaturePage', inverse_of: :parent_page, foreign_key: 'parent_page_id'
    belongs_to :parent_page, class_name: 'Spotlight::FeaturePage', optional: true

    accepts_nested_attributes_for :child_pages

    belongs_to :thumbnail, class_name: 'Spotlight::FeaturedImage', dependent: :destroy, optional: true

    before_validation unless: :top_level_page? do
      self.exhibit = top_level_page_or_self.exhibit
    end

    def display_sidebar?
      child_pages.published.present? || display_sidebar
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 app/models/spotlight/feature_page.rb
blacklight-spotlight-3.0.0.alpha.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.13.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.12.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.12.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.11.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.10.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.9.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.8.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.7.2 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.7.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.7.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.6.1.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.6.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.6.0 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.5.2 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.5.1 app/models/spotlight/feature_page.rb
blacklight-spotlight-2.5.0 app/models/spotlight/feature_page.rb