Module: StateMachinesHelper

Defined in:
app/helpers/state_machines_helper.rb

Overview

View helper: state machines.

Instance Method Summary collapse

Instance Method Details

#event_status(status, condition, possition, hide_when_not_present = false, description = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/state_machines_helper.rb', line 12

def event_status(status, condition, possition, hide_when_not_present = false, description = nil)
  return if !condition && hide_when_not_present

  (:li, if condition
                     raw(status.html_safe) + (
                         unless description.nil?
                           (:div, (:div, (:div, nil, class: 'popover-arrow') + (:div, (:p, description, class: nil), class: 'popover-content'), class: 'popover bottom'), class: 'statusdescription')
                         end)
                   else
                     fa_icon('check', family: :solid, aria: { hidden: true }, style: (possition ? 'display:none' : nil))
                   end,
    class: (if condition
              'currentstatus'
            else
              (possition ? 'aftercurrent' : 'beforecurrent')
            end), title: status, data: condition ? nil : { content: description, toggle: 'popover', trigger: 'hover', placement: 'top' })
end

#friendly_status(state) ⇒ Object



4
5
6
# File 'app/helpers/state_machines_helper.rb', line 4

def friendly_status(state)
  state&.humanize&.capitalize
end

#possible_state_machine_names(klass) ⇒ Object



8
9
10
# File 'app/helpers/state_machines_helper.rb', line 8

def possible_state_machine_names(klass)
  klass.state_machines[:state].states.map(&:name).sort
end