Class: SharedCell

Inherits:
Cell::Rails
  • Object
show all
Defined in:
app/cells/shared_cell.rb

Instance Method Summary collapse

Instance Method Details

#check_auth(args = {}) ⇒ Object



110
111
112
113
114
115
116
117
118
119
# File 'app/cells/shared_cell.rb', line 110

def check_auth(args = {})
  @account = args[:account]
  @will_cached = args[:will_cached]
  @initialize_hash = if @will_cached
                       { ng_init: 'load_account()' }
                     else
                       { ng_init: "preload_account(#{@account.public_params.to_json if @account})" }
                     end
  render
end


64
65
66
67
# File 'app/cells/shared_cell.rb', line 64

def footer_info(_args = {})
  @structures = Structure.with_position(PositionType.bottom).visible.sorted
  render unless @structures.empty?
end


74
75
76
77
# File 'app/cells/shared_cell.rb', line 74

def footer_links(_args = {})
  @structures = Structure.with_position(PositionType.footer).visible.sorted
  render unless @structures.empty?
end

cache :footer_links, :expires_in => 4.hours cache :features, :expires_in => 1.day



43
44
45
46
# File 'app/cells/shared_cell.rb', line 43

def footer_menu(_args = {})
  @structures = Structure.with_position(PositionType.menu).visible.sorted
  render
end


79
80
81
82
83
# File 'app/cells/shared_cell.rb', line 79

def footer_services(_args = {})
  servises_root = Structure.with_type(StructureType.services).visible.first
  @structures = servises_root.children.preload(:children)
  render unless @structures.empty?
end

#locale_menu(_args = {}) ⇒ Object



69
70
71
72
# File 'app/cells/shared_cell.rb', line 69

def locale_menu(_args = {})
  @locales = I18n.available_locales
  render unless I18n.available_locales.size <= 1
end


53
54
55
56
57
58
59
60
61
62
# File 'app/cells/shared_cell.rb', line 53

def menu(args = {})
  @structures = Structure.with_position(PositionType.menu).visible.sorted
  @max_size = args[:max_size] || 5
  if @max_size.present? && @structures.size > @max_size
    @others_title = args[:others_title] || I18n.t(:more, scope: [:menu])
    @others = @structures.offset(@max_size - 1)
    @structures = @structures.limit(@max_size - 1)
  end
  render unless @structures.empty?
end

#phones(args = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/cells/shared_cell.rb', line 85

def phones(args = {})
  @phones = CountryPhone.localized_first
  @phone = @phones.first

  @phone_class = (args[:phone_class] || 'phone')

  if @phone
    if args[:type] && lookup_context.exists?("shared/phones_#{args[:type]}")
      render view: "phones_#{args[:type]}"
    else
      render
    end
  end
end

#promo(_args = {}) ⇒ Object



100
101
102
103
104
105
106
107
108
# File 'app/cells/shared_cell.rb', line 100

def promo(_args = {})
  # @structure = Structure.find_by(slug: 'additional-promo-text')
  @default = ContentStorageType.promo_text_default.storage
  # return unless @structure && show_promo?
  @title = @default.title
  @first = @default.content!
  @second = ContentStorageType.promo_text_expanded.content!
  render unless @first.blank? || @second.blank?
end


48
49
50
51
# File 'app/cells/shared_cell.rb', line 48

def submenu(_args = {})
  @structures = Structure.with_position(PositionType.bottom).visible.sorted
  render unless @structures.empty?
end