Class: Spina::Pages::LocationComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/spina/pages/location_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(f, page = nil) ⇒ LocationComponent

Returns a new instance of LocationComponent.



5
6
7
8
# File 'app/components/spina/pages/location_component.rb', line 5

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

Instance Attribute Details

#fObject

Returns the value of attribute f.



3
4
5
# File 'app/components/spina/pages/location_component.rb', line 3

def f
  @f
end

Instance Method Details

#default_parent_pages_pathObject



24
25
26
# File 'app/components/spina/pages/location_component.rb', line 24

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

#main_collection_optionObject



18
19
20
21
22
# File 'app/components/spina/pages/location_component.rb', line 18

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

#resourcesObject



10
11
12
13
14
15
16
# File 'app/components/spina/pages/location_component.rb', line 10

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