Class: NfgUi::Components::Elements::Step

Inherits:
NavItem show all
Includes:
Bootstrap::Utilities::Activatable, Traits::Active, Traits::Step, Utilities::Iconable
Defined in:
lib/nfg_ui/components/elements/step.rb

Overview

Step doc coming soon

Constant Summary

Constants included from Traits::Step

Traits::Step::TRAITS

Constants included from Traits::Active

Traits::Active::TRAITS

Constants included from Traits::Remote

Traits::Remote::TRAITS

Constants included from Traits::NavItem

Traits::NavItem::TRAITS

Constants included from Traits::Disable

Traits::Disable::TRAITS

Constants included from Traits

Traits::REGISTERED_TRAITS, Traits::TRAIT_MODULES

Instance Attribute Summary

Attributes included from Bootstrap::Utilities::Disableable

#as

Attributes included from Bootstrap::Utilities::Wrappable

#as

Attributes inherited from Bootstrap::Components::Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Traits::Step

#visited_trait

Methods included from Traits::Active

#active_trait

Methods included from Utilities::Iconable

#icon

Methods included from Traits::Remote

#remote_trait

Methods included from Traits::NavItem

#dropdown_trait

Methods included from Traits::Disable

#disabled_trait

Methods included from Utilities::Traitable

#traits, #utility_initialize

Methods included from Utilities::Renderable

#render_if, #render_unless

Methods included from Utilities::Describable

#data, #describe

Methods included from Bootstrap::Utilities::Tooltipable

#data, #disabled_component_tooltip_wrapper_html_options, #html_options, #tooltip

Methods inherited from Bootstrap::Components::NavItem

#button, #dropdown, #html_options, #include_nav_link?, #remote, #tab

Methods included from Bootstrap::Utilities::Wrappable

#utility_initialize

Methods inherited from Bootstrap::Components::Base

#data, #href, #html_options, #id, #initialize, #style

Constructor Details

This class inherits a constructor from NfgUi::Bootstrap::Components::Base

Instance Method Details

#activeObject

Override #active from Activatable



16
17
18
19
20
21
22
23
# File 'lib/nfg_ui/components/elements/step.rb', line 16

def active
  # Active is a transitory state for steps
  # So when a step is active, it is automatically visited.
  # This sets visited to true.
  # This is also accounted for in the #active_trait for steps.
  options[:visited] = true if options[:active]
  super
end

#component_familyObject



25
26
27
# File 'lib/nfg_ui/components/elements/step.rb', line 25

def component_family
  :steps
end

#disabledObject

NOTE: DISABLED TOOLTIPS DO NOT YET WORK ON STEPS NAVITEM DOES NOT INCLUDE DISABLEABLE MODULE JR: 06-21-2019



32
33
34
# File 'lib/nfg_ui/components/elements/step.rb', line 32

def disabled
  options[:disabled] || (!visited && !active)
end

#renderObject



36
37
38
39
40
# File 'lib/nfg_ui/components/elements/step.rb', line 36

def render
  (as, html_options) do
    NfgUi::Components::Elements::StepIndicator.new({ step: step.to_s, body: (block_given? ? yield : body), icon: icon, href: href, disabled: disabled }, view_context).render
  end
end

#stepObject



42
43
44
# File 'lib/nfg_ui/components/elements/step.rb', line 42

def step
  options.fetch(:step, nil)
end

#visitedObject



46
47
48
# File 'lib/nfg_ui/components/elements/step.rb', line 46

def visited
  options.fetch(:visited, false)
end