Class: Thinreports::BasicReport::Core::Shape::List::Manager
- Inherits:
-
Object
- Object
- Thinreports::BasicReport::Core::Shape::List::Manager
show all
- Includes:
- Utils
- Defined in:
- lib/thinreports/basic_report/core/shape/list/manager.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Utils
#blank_value?, #call_block_in, #deep_copy, included
Constructor Details
#initialize(page) ⇒ Manager
Returns a new instance of Manager.
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 30
def initialize(page)
switch_current!(page)
@finalized = false
@page_count = 0
@page_finalize_handler = nil
@page_footer_handler = nil
@footer_handler = nil
end
|
Instance Attribute Details
#current_page ⇒ Thinreports::BasicReport::Core::Shape:::List::Page
12
13
14
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 12
def current_page
@current_page
end
|
15
16
17
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 15
def current_page_state
@current_page_state
end
|
27
28
29
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 27
def footer_handler
@footer_handler
end
|
#page_count ⇒ Integer
18
19
20
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 18
def page_count
@page_count
end
|
#page_finalize_handler ⇒ Proc
21
22
23
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 21
def page_finalize_handler
@page_finalize_handler
end
|
#page_footer_handler ⇒ Proc
24
25
26
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 24
def page_footer_handler
@page_footer_handler
end
|
Instance Method Details
#add_detail(values = {}, &block) ⇒ Boolean
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 77
def add_detail(values = {}, &block)
return false if current_page_state.finalized?
successful = true
if overflow_with?(:detail)
if auto_page_break?
change_new_page do |new_list|
new_list.manager.insert_detail(values, &block)
end
else
finalize
successful = false
end
else
insert_detail(values, &block)
end
successful
end
|
#auto_page_break? ⇒ Boolean
156
157
158
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 156
def auto_page_break?
format.auto_page_break?
end
|
63
64
65
66
67
68
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 63
def (values = {}, &block)
raise Thinreports::BasicReport::Errors::DisabledListSection, 'header' unless format.
current_page_state. ||= init_section(:header)
build_section(, values, &block)
end
|
121
122
123
124
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 121
def build_section(section, values = {}, &block)
section.values(values)
call_block_in(section, &block)
end
|
#change_new_page {|new_list| ... } ⇒ Object
51
52
53
54
55
56
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 51
def change_new_page(&block)
finalize_page
new_page = report.internal.copy_page
block.call(new_page.list(current_page.id)) if block_given?
end
|
#finalize ⇒ Object
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 186
def finalize
return if finalized?
finalize_page
if format.
= init_section(:footer)
@footer_handler.call() if @footer_handler
if auto_page_break? && overflow_with?(:footer)
change_new_page do |new_list|
new_list.manager.insert_row()
new_list.manager.finalize_page(ignore_page_footer: true)
end
else
insert_row()
end
end
@finalized = true
end
|
#finalize_page(options = {}) ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 163
def finalize_page(options = {})
return if current_page_state.finalized?
if format.
unless options[:ignore_page_footer]
current_page_state.finalized!
@page_finalize_handler.call if @page_finalize_handler
@page_count += 1
current_page_state.no = @page_count
end
|
177
178
179
180
181
182
183
184
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 177
def
return unless format.
= init_section(:page_footer)
insert_row()
@page_footer_handler.call() if @page_footer_handler
end
|
#finalized? ⇒ Boolean
208
209
210
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 208
def finalized?
@finalized
end
|
223
224
225
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 223
def format
current_page_state.format
end
|
71
72
73
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 71
def
current_page_state.
end
|
128
129
130
131
132
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 128
def init_section(section_name)
List::SectionInterface.new(current_page,
format.sections[section_name],
section_name)
end
|
101
102
103
104
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 101
def insert_detail(values = {}, &block)
detail = build_section(init_section(:detail), values, &block)
insert_row(detail)
end
|
108
109
110
111
112
113
114
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 108
def insert_row(row)
row.internal.move_top_to(current_page_state.height)
current_page_state.rows << row
current_page_state.height += row.height
row
end
|
218
219
220
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 218
def layout
current_page_state.parent.layout
end
|
#overflow_with?(section_name = :detail) ⇒ Boolean
136
137
138
139
140
141
142
143
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 136
def overflow_with?(section_name = :detail)
max_height = page_max_height
max_height += format.section_height(:page_footer) if section_name == :footer && format.
height = format.section_height(section_name)
(current_page_state.height + height) > max_height
end
|
#page_max_height ⇒ Numeric
146
147
148
149
150
151
152
153
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 146
def page_max_height
@page_max_height ||= begin
h = format.height
h -= format.section_height(:page_footer)
h -= format.section_height(:footer) unless auto_page_break?
h
end
end
|
213
214
215
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 213
def report
current_page_state.parent.report
end
|
43
44
45
46
47
|
# File 'lib/thinreports/basic_report/core/shape/list/manager.rb', line 43
def switch_current!(page)
@current_page = page
@current_page_state = page.internal
self
end
|