Class: Card::Action::ActionRenderer
- Inherits:
-
Object
- Object
- Card::Action::ActionRenderer
show all
- Includes:
- Bootstrapper
- Defined in:
- mod/history/lib/card/action/action_renderer.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#bootstrap, #bs
#components, #include_component, #load_components, #to_const
Constructor Details
#initialize(format, action, header = true, action_view = :summary, hide_diff = false) ⇒ ActionRenderer
Returns a new instance of ActionRenderer.
5
6
7
8
9
10
11
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 5
def initialize format, action, =true, action_view=:summary, hide_diff=false
@format = format
@action = action
@header =
@action_view = action_view
@hide_diff = hide_diff
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
14
15
16
17
18
19
20
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 14
def method_missing(method_name, *args, &block)
if block_given?
@format.send(method_name, *args, &block)
else
@format.send(method_name, *args)
end
end
|
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4
5
6
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 4
def action
@action
end
|
Returns the value of attribute header.
4
5
6
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 4
def
@header
end
|
Instance Method Details
#action_panel ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 40
def action_panel
bs_panel do
if
heading do
div type_diff, class: "pull-right"
div name_diff
end
end
body do
content_diff
end
end
end
|
#content_diff ⇒ Object
68
69
70
71
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 68
def content_diff
return @action.raw_view if @action.action_type == :delete
@format.subformat(@action.card)._render_action_summary action: @action
end
|
#name_changes ⇒ Object
78
79
80
81
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 78
def name_changes
return old_name unless @action.new_name?
@hide_diff ? new_name : Card::Content::Diff.complete(old_name, new_name)
end
|
#name_diff ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 54
def name_diff
if @action.card == @format.card
name_changes
else
link_to_view(
:related, name_changes,
path: { related: { view: "history", name: @action.card.name } },
remote: true,
class: "slotter",
)
end
end
|
#new_name ⇒ Object
87
88
89
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 87
def new_name
showname(@action.value(:name)).to_s
end
|
#old_name ⇒ Object
83
84
85
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 83
def old_name
(name = @action.previous_value :name) && showname(name).to_s
end
|
#render ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 26
def render
bs_layout container: true, fluid: true do
row do
html <<-HTML
<ul class="action-list">
<li class="glyphicon-bullet #{action.action_type}">
#{action_panel}
</li>
</ul>
HTML
end
end
end
|
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
22
23
24
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 22
def respond_to_missing? method_name, _include_private=false
@format.respond_to? method_name
end
|
#type_diff ⇒ Object
73
74
75
76
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 73
def type_diff
return "" unless @action.new_type?
@hide_diff ? @action.value(:cardtype) : @action.cardtype_diff
end
|