Class: Card::Action::ActionRenderer
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.
[View source]
6
7
8
9
10
11
12
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 6
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
[View source]
15
16
17
18
19
20
21
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 15
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
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
[View source]
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 42
def action_panel
bs_panel do
if
heading do
div type_diff, class: "float-end"
div name_diff
end
end
body do
content_diff
end
end
end
|
#content_diff ⇒ Object
[View source]
81
82
83
84
85
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 81
def content_diff
return @action.raw_view if @action.action_type == :delete
@format.subformat(@action.card).render_action_summary action_id: @action.id
end
|
#name_changes ⇒ Object
[View source]
93
94
95
96
97
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 93
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
[View source]
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 60
def name_diff
return relative_name if @action.card.name.compound?
name_changes
end
|
[View source]
103
104
105
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 103
def new_name
title_in_context @action.value(:name)
end
|
[View source]
99
100
101
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 99
def old_name
(name = @action.previous_value :name) && title_in_context(name)
end
|
#relative_name ⇒ Object
[View source]
56
57
58
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 56
def relative_name
@action.card.name.from @format.card.name
end
|
[View source]
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 27
def render
classes = @format.classy("action-list")
bs_layout container: true, fluid: true do
row do
html <<-HTML
<ul class="#{classes} w-100">
<li class="#{action.action_type}">
#{action_panel}
</li>
</ul>
HTML
end
end
end
|
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
[View source]
23
24
25
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 23
def respond_to_missing? method_name, _include_private=false
@format.respond_to? method_name
end
|
#type_diff ⇒ Object
[View source]
87
88
89
90
91
|
# File 'mod/history/lib/card/action/action_renderer.rb', line 87
def type_diff
return "" unless @action.new_type?
@hide_diff ? @action.value(:cardtype) : @action.cardtype_diff
end
|