Module: StateMachinesHelper

Defined in:
app/helpers/state_machines_helper.rb

Instance Method Summary collapse

Instance Method Details

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



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

def event_status(status, condition, possition, hide_when_not_present = false, description = nil)
  return if !condition and 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
                     (:i, nil, class: 'glyphicon glyphicon-ok', 'aria-hidden': 'true', style: (if condition
                                                                                                            nil
                                                                                                          else
                                                                                                            (possition ? 'display:none' : nil)
                                                                                                          end))
                   end,
    class: (if condition
              'currentstatus'
            else
              (possition ? 'aftercurrent' : 'beforecurrent')
            end), title: status, data: condition ? nil : { content: description, toggle: 'popover', trigger: 'hover', placement: 'top' })
end

#event_status_rooms(status, condition, hide_when_not_present = false) ⇒ Object



32
33
34
35
36
# File 'app/helpers/state_machines_helper.rb', line 32

def event_status_rooms(status, condition, hide_when_not_present = false)
  return if !condition and hide_when_not_present

  (:li, icon('') + ' ' + raw(status.html_safe), class: (condition ? 'fa fa-arrow-circle-right current-status' : 'fa fa-arrow-circle-right'))
end

#friendly_status(state) ⇒ Object



2
3
4
# File 'app/helpers/state_machines_helper.rb', line 2

def friendly_status(state)
  state.humanize.capitalize unless state.nil?
end

#possible_state_machine_names(klass) ⇒ Object



6
7
8
# File 'app/helpers/state_machines_helper.rb', line 6

def possible_state_machine_names(klass)
  klass.state_machines[:state].states.map { |s| s.name }.sort
end