10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/active_admin/state_machine/view_dsl.rb', line 10
def render_state(resource, name, read_only)
state = resource.send(name)
s = resource.class.state_machines[name.to_sym].states[state.to_sym]
ret = [
'<div class="status_tag state-' + state + '">' + s.human_name + '</div>',
'<div style="height: 10px;"></div>'
]
unless read_only
events = resource.class.state_machines[name.to_sym].events
resource.send("#{name}_events".to_sym).each do |event|
ret << link_to(
events[event].human_name,
send("#{event}_admin_#{resource.class.model_name.singular}_path", id: resource.id, attr: name),
method: :put,
class: "btn event-#{event}",
style: 'margin-bottom: 5px;'
)
end
end
('<div style="white-space: normal;">' + ret.join(' ') + '</div>').html_safe
end
|