Class: Katalyst::Navigation::Button

Inherits:
Item
  • Object
show all
Defined in:
app/models/katalyst/navigation/button.rb

Overview

Renders an HTML button using button_to.

Constant Summary collapse

HTTP_METHODS =
i[get post patch put delete].index_by(&:itself).freeze

Constants inherited from Item

Item::TARGETS

Instance Attribute Summary

Attributes inherited from Item

#children, #depth, #index, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Item

#item_options, #layout?

Class Method Details

.permitted_paramsObject



14
15
16
# File 'app/models/katalyst/navigation/button.rb', line 14

def self.permitted_params
  super + i[http_method]
end

Instance Method Details

#options_for_targetObject



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

def options_for_target
  options = super

  if target == "_blank" || target == "_top" || target == "self"
    options.deep_merge!({ data: { method: http_method } })
  else
    options.deep_merge!({ data: { turbo_method: http_method } })
  end
  options
end