Class: Spree::PageSections::Header

Inherits:
Spree::PageSection show all
Defined in:
app/models/spree/page_sections/header.rb

Constant Summary collapse

TOP_PADDING_DEFAULT =
15
BOTTOM_PADDING_DEFAULT =
15
TOP_BORDER_WIDTH_DEFAULT =
0

Constants inherited from Spree::PageSection

Spree::PageSection::BACKGROUND_COLOR_DEFAULT, Spree::PageSection::BORDER_COLOR_DEFAULT, Spree::PageSection::BOTTOM_BORDER_WIDTH_DEFAULT, Spree::PageSection::TEXT_COLOR_DEFAULT

Instance Attribute Summary

Attributes inherited from Spree::PageSection

#default_blocks

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Spree::PageSection

#can_be_deleted?, #can_be_sorted?, #copy_rich_text_fields_from, #deep_clone, #deep_clone_links, #display_name, #dup, #lazy?, #lazy_path, #restore_design_settings_to_defaults, #rich_text_fields, #role, #theme, #to_partial_path

Class Method Details

.roleObject



13
14
15
# File 'app/models/spree/page_sections/header.rb', line 13

def self.role
  'header'
end

Instance Method Details

#available_blocks_to_addObject



25
26
27
# File 'app/models/spree/page_sections/header.rb', line 25

def available_blocks_to_add
  [Spree::PageBlocks::MegaNavWithSubcategories, Spree::PageBlocks::MegaNav, Spree::PageBlocks::Link]
end

#blocks_available?Boolean



21
22
23
# File 'app/models/spree/page_sections/header.rb', line 21

def blocks_available?
  true
end

#can_sort_blocks?Boolean



17
18
19
# File 'app/models/spree/page_sections/header.rb', line 17

def can_sort_blocks?
  true
end


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/models/spree/page_sections/header.rb', line 37

def default_links
  links = [
    Spree::PageLink.new(linkable: pages.find_by(type: 'Spree::Pages::ShopAll'))
  ]

  collections_taxonomy = store.taxonomies.find_by(name: Spree.t(:taxonomy_collections_name))

  if collections_taxonomy.present?
    on_sale_collection = collections_taxonomy.taxons.automatic.find_by(name: Spree.t('automatic_taxon_names.on_sale'))
    new_arrivals_collection = collections_taxonomy.taxons.automatic.find_by(name: Spree.t('automatic_taxon_names.new_arrivals'))

    links << Spree::PageLink.new(linkable: on_sale_collection) if on_sale_collection.present?
    links << Spree::PageLink.new(linkable: new_arrivals_collection) if new_arrivals_collection.present?
  end

  links << Spree::PageLink.new(linkable: pages.find_by(type: 'Spree::Pages::PostList'))

  links
end

#icon_nameObject



29
30
31
# File 'app/models/spree/page_sections/header.rb', line 29

def icon_name
  'layout-navbar'
end


33
34
35
# File 'app/models/spree/page_sections/header.rb', line 33

def links_available?
  true
end

#pagesObject



57
58
59
# File 'app/models/spree/page_sections/header.rb', line 57

def pages
  @pages ||= theme.pages
end