Sha256: e608cede03eb10a6bd40514099c8928f906c35c09a36cad154f5eda206e5838d

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

module PageflowScrolled
  class Storyline < Pageflow::ApplicationRecord
    SECTIONS_ORDER = [
      'pageflow_scrolled_chapters.position ASC',
      'pageflow_scrolled_sections.position ASC'
    ].join(',')

    CONTENT_ELEMENTS_ORDER = [
      'pageflow_scrolled_chapters.position ASC',
      'pageflow_scrolled_sections.position ASC',
      'pageflow_scrolled_content_elements.position ASC'
    ].join(',')

    include Pageflow::RevisionComponent
    include Pageflow::SerializedConfiguration

    has_many :chapters,
             -> { order('pageflow_scrolled_chapters.position ASC') },
             class_name: 'PageflowScrolled::Chapter',
             dependent: :destroy,
             inverse_of: :storyline
    has_many :sections,
             -> { reorder(SECTIONS_ORDER) },
             through: :chapters
    has_many :content_elements,
             -> { reorder(CONTENT_ELEMENTS_ORDER) },
             through: :sections

    def copy_to(revision)
      storyline = dup
      storyline.revision = revision
      storyline.save!

      chapters.each do |chapter|
        chapter.copy_to(storyline)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pageflow-15.4.0 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.3.0 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.2.2 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.2.1 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.2.0 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.2 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.1 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.0 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.0.rc0 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.0.beta6 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.0.beta5 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.0.beta4 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb
pageflow-15.1.0.beta3 entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb