Module: ModalStack::Helpers::ModalBackLinkHelper
- Defined in:
- lib/modal_stack/helpers/modal_back_link_helper.rb
Overview
Renders a button (or link) that steps back through the top layer’s path. Wired to the ‘modal-stack-back-link` Stimulus controller, which delegates to `orchestrator.pathBack`.
<%= modal_back_link "Back" %>
<%= modal_back_link "Back to step 1", steps: 2 %>
<%= modal_back_link class: "btn btn-link" do %>
<span aria-hidden="true">←</span> Back
<% end %>
Constant Summary collapse
- LINK_CONTROLLER =
"modal-stack-back-link"- LINK_CLICK_ACTION =
"click->modal-stack-back-link#trigger"
Instance Method Summary collapse
-
#modal_back_link(name = nil, options = {}, &block) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
Instance Method Details
#modal_back_link(name = nil, options = {}, &block) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/modal_stack/helpers/modal_back_link_helper.rb', line 18 def modal_back_link(name = nil, = {}, &block) # rubocop:disable Metrics/CyclomaticComplexity if block = name.is_a?(Hash) ? name : {} name = capture(&block) end = .dup steps = Integer(.delete(:steps) || 1) raise ArgumentError, "steps must be a positive integer, got #{steps.inspect}" if steps < 1 [:data] = back_link_data(.delete(:data) || {}, steps) [:type] ||= "button" (name || I18n.t("modal_stack.back", default: "Back"), **) end |