Sha256: 8cf86093c19b7dbf15477851657af7ca2a20d48fb85add589b26231904ac091f

Contents?: true

Size: 785 Bytes

Versions: 8

Compression:

Stored size: 785 Bytes

Contents

module Spina::Pages
  class LocationComponent < Spina::ApplicationComponent
    attr_accessor :f

    def initialize(f, page = nil)
      @f = f
      @page = page
    end

    def resources
      [main_collection_option] + Spina::Resource.order(:label).map do |resource|
        [resource.label, resource.id, data: {
          parent_pages_url: helpers.spina.admin_parent_pages_path(resource_id: resource.id)
        }]
      end
    end

    def main_collection_option
      [t("spina.pages.main_collection"), nil, data: {
        parent_pages_url: helpers.spina.admin_parent_pages_path
      }]
    end

    def default_parent_pages_path
      helpers.spina.admin_parent_pages_path(resource_id: @page&.resource_id, parent_id: @page&.parent_id, page_id: @page&.id)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spina-2.18.0 app/components/spina/pages/location_component.rb
spina-2.17.0 app/components/spina/pages/location_component.rb
spina-2.16.0 app/components/spina/pages/location_component.rb
spina-2.15.1 app/components/spina/pages/location_component.rb
spina-2.15.0 app/components/spina/pages/location_component.rb
spina-2.14.0 app/components/spina/pages/location_component.rb
spina-2.13.1 app/components/spina/pages/location_component.rb
spina-2.13.0 app/components/spina/pages/location_component.rb