Class: Katalyst::Navigation::Item

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/katalyst/navigation/item.rb

Overview

STI base class for menu items (headings, links and buttons)

Direct Known Subclasses

Button, Layout, Link

Constant Summary collapse

TARGETS =
%i[self _top _blank kpop].index_by(&:itself).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



11
12
13
# File 'app/models/katalyst/navigation/item.rb', line 11

def children
  @children
end

#depthObject

Returns the value of attribute depth.



11
12
13
# File 'app/models/katalyst/navigation/item.rb', line 11

def depth
  @depth
end

#indexObject

Returns the value of attribute index.



11
12
13
# File 'app/models/katalyst/navigation/item.rb', line 11

def index
  @index
end

#parentObject

Returns the value of attribute parent.



11
12
13
# File 'app/models/katalyst/navigation/item.rb', line 11

def parent
  @parent
end

Class Method Details

.permitted_paramsObject



17
18
19
20
21
22
23
24
25
# File 'app/models/katalyst/navigation/item.rb', line 17

def self.permitted_params
  %i[
    title
    url
    visible
    target
    type
  ]
end

Instance Method Details

#item_optionsObject

Entrypoint for combining additional options based on attribute rules



32
33
34
# File 'app/models/katalyst/navigation/item.rb', line 32

def item_options
  options_for_target
end

#layout?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/katalyst/navigation/item.rb', line 27

def layout?
  is_a? Layout
end

#options_for_targetObject



36
37
38
39
40
41
42
43
44
45
# File 'app/models/katalyst/navigation/item.rb', line 36

def options_for_target
  return {} if target == "self"

  options = { target: target }

  unless target == "_blank" || target == "_top"
    options = { data: { turbo: true, turbo_frame: target } }
  end
  options
end