meta_reports 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -33
  3. data/app/helpers/meta_reports/reports_helper.rb +37 -20
  4. data/app/models/meta_reports/base.rb +9 -1
  5. data/config/routes.rb +3 -1
  6. data/lib/generators/meta_reports/templates/models/report.rb +5 -17
  7. data/lib/generators/meta_reports/templates/models/report_non_activerecord.rb +5 -17
  8. data/lib/generators/meta_reports/templates/views/_form.html.erb +9 -0
  9. data/lib/generators/meta_reports/templates/views/templates/_default_header.pdf.prawn +0 -1
  10. data/lib/generators/meta_reports/templates/views/templates/_default_header.xlsx.axlsx +5 -11
  11. data/lib/generators/meta_reports/templates/views/templates/_default_table.html.erb +14 -5
  12. data/lib/generators/meta_reports/templates/views/templates/_default_table.pdf.prawn +5 -1
  13. data/lib/generators/meta_reports/templates/views/templates/default.pdf.prawn +7 -5
  14. data/lib/meta_reports/version.rb +1 -1
  15. data/lib/tasks/meta_reports_tasks.rake +9 -8
  16. data/spec/dummy/app/assets/stylesheets/lib/metareports_color_variables.scss +7 -9
  17. data/spec/dummy/app/assets/stylesheets/lib/metareports_colors.scss +7 -9
  18. data/spec/dummy/app/models/meta_reports/report.rb +5 -17
  19. data/spec/dummy/app/views/meta_reports/reports/_form.html.erb +16 -0
  20. data/spec/dummy/app/views/meta_reports/reports/templates/_default_header.pdf.prawn +0 -1
  21. data/spec/dummy/app/views/meta_reports/reports/templates/_default_header.xlsx.axlsx +5 -11
  22. data/spec/dummy/app/views/meta_reports/reports/templates/_default_table.html.erb +14 -5
  23. data/spec/dummy/app/views/meta_reports/reports/templates/_default_table.pdf.prawn +5 -1
  24. data/spec/dummy/app/views/meta_reports/reports/templates/default.pdf.prawn +1 -1
  25. data/spec/dummy/db/development.sqlite3 +0 -0
  26. data/spec/dummy/log/development.log +806 -0
  27. data/spec/dummy/tmp/capybara/capybara-201310282335386823859116.html +268 -0
  28. data/spec/dummy/tmp/capybara/capybara-201310282336101820292402.html +268 -0
  29. data/spec/dummy/tmp/capybara/capybara-201310282338439674392250.html +60 -0
  30. data/spec/dummy/tmp/capybara/capybara-201310282350595445887206.html +60 -0
  31. data/spec/dummy/tmp/capybara/capybara-201310282351429822980920.html +60 -0
  32. data/spec/dummy/tmp/capybara/capybara-201310282354523302677005.html +60 -0
  33. data/spec/features/dummy_spec.rb +10 -0
  34. data/spec/support/utilities.rb +27 -0
  35. data/spec/tasks/meta_reports_rake_spec.rb +14 -18
  36. metadata +30 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 444a74c33cfc1decb3b4d7876b1238a1428169da
4
- data.tar.gz: 34dfb23512870e57cd31ff9f95adb9ea66527730
3
+ metadata.gz: 27a12febca4612c8f05d6e12f765657f2f6e49c5
4
+ data.tar.gz: 81d294309e4a203108ce5c29ce0933e05eddbc36
5
5
  SHA512:
6
- metadata.gz: 706f15ea4d6287cae130aa6a83e0c919622c452253ff82b6f4e11a3f37bff1ae9639c18f31b26ec6ffd0edaae3f52c20dd3e4f05b442dccb4fb4f265a6a50076
7
- data.tar.gz: 80318f873898149a3eb90f42ca6347fc71a4d2230691d93408555b7a99d156135656c83487c0122c3d0ca3410c916c8f9c5f7a3bf94683ccc8cf8bc41f25036a
6
+ metadata.gz: 200b4175aece9f9eef2fda927af223aacc38f0f3720e39a5b277e488aaea220c7bf2b5c2d41378edda7a17872d3a84c36bd13bb4887cea7707c1173942c4165a
7
+ data.tar.gz: 38f42bd8de5d7d93c7c6739338f941a135b5e656eac23ce42a90d495d3734c8871fb7d4941a5c2f5a46af3648201925f921585e41db071e05d07367d1f83b58a
data/README.md CHANGED
@@ -117,6 +117,7 @@ The key component of MetaReports is the metadata format. This allows you to writ
117
117
  - **options:** The options for the whole table. If you are using a plain array, this hash must be the last item in the table.
118
118
  - **column_widths:** Column widths hash, used only on Prawn PDF output.
119
119
  - **font_size:** Font size for content. Used on PDF and XLSX output.
120
+ - **group:** Group the header and table together on one page. This will throw an error if it cannot be fit on one page.
120
121
  - **row_classes:** A hash with keys specifying row number (0 first), and values being a string of classes.
121
122
  - **table_header:** Defaults to true. First row in the table is a header row. Causes the row to be repeated on Prawn PDF tables if it breaks to another page.
122
123
 
@@ -150,59 +151,82 @@ Here is a simple example. See the [example class](spec/dummy/app/models/meta_rep
150
151
 
151
152
  ###Colors
152
153
 
153
- There is currently an incomplete implementation of shared colors. You will define your colors by name in the MetaReports::Report class in the COLORS hash constant. If a table row contains a corresponding class name it will have that color in HTML, PDF, and XLSX format. Currently it is only applied in the PDF and HTML formats. It is also intended to implement a means of specifying cell background and text color.
154
+ There is currently an incomplete implementation of shared colors. You will define your colors by name in the MetaReports::Report class in the COLORS hash constant. If a table row or cell contains a corresponding class name it will have that color in HTML and PDF. XLSX support is planned. It is also intended to implement a means of specifying cell text color.
154
155
 
155
- An example COLORS hash is below:
156
+ #### Declaring Colors
157
+
158
+ Specify colors using the COLORS hash constnat in your MetaReports::Report class. An example COLORS hash is below:
156
159
 
157
160
  ```ruby
158
161
  COLORS = {
159
- _even: 'efefef',
160
- _odd: 'ffffff',
161
- _yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
162
- tr____highlight: '$_yellow_1 !important',
163
- 'a--hover' => ['ffcccc', 'ffc5c5']
162
+ even: 'efefef',
163
+ odd: 'ffffff',
164
+ yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
165
+ highlight: '$yellow_1 !important',
166
+ hover: ['ffcccc', 'ffc5c5']
164
167
  }
165
168
  ```
166
169
 
170
+ #### Specifying colors for rows or cells
171
+
172
+ To specify a color for a cell, use a hash and specify the color name in the class:
173
+
174
+ ```ruby
175
+ table << [{content: "Colored cell", class: 'yellow'}]
176
+ ```
177
+
178
+ To specify a color for a row, store the row's color in the table row_classes hash:
179
+
180
+ ```ruby
181
+ table.row_classes[row] = 'yellow'
182
+ ```
183
+
184
+ Note the row number begins with zero, and excludes the header if enabled.
185
+
186
+ #### Inline CSS
187
+
188
+ MetaReports defaults to inline styling for HTML. If you wish to turn this off (and use either your own styles or the export below) set the following:
189
+
190
+ ```ruby
191
+ MetaReports::Base.inline_css = false
192
+ ```
193
+
194
+ #### Export SCSS / CSS
195
+
167
196
  When you run `rake meta_reports:export_colors` task it exports two SCSS files, one including HTML styles, the other including SCSS variables (for your use in other files.) The export uses the following conventions:
168
197
 
169
198
  - The corresponding SASS variable will be named the same as the key (with $ prepended of course). If the value is an array, the variable names will be the class name plus a numerical suffix for each entry.
170
- - The corresponding CSS entry will use these conversions:
171
- - '___' will be converted to to a space
172
- - '__' will be converted to a hash (id indicator)
173
- - '_' will be converted to a period (class indicator)
174
- - '--' (double dash) will be converted to to a colon (pseudo class)
199
+ - The corresponding CSS entry will:
200
+ - be prefixed with 'tr.' to match table rows
175
201
  - arrays of values will be converted into nth-child rules to color consecutive rows
176
202
 
177
- This means '____' will be converted to a space and period (' .'), '_____' to ' #', and 'a--first-child' will become 'a:first-child'.
178
-
179
203
  Given the above example the generated `lib/metareports_color_variables.scss` SASS file will be:
180
204
 
181
205
  ```scss
182
- $_even: #efefef;
183
- $_odd: #ffffff;
184
- $_yellow_0: #ffffaa;
185
- $_yellow_1: #ffffcc;
186
- $_yellow_2: #f9f9a4;
187
- $_yellow_3: #f9f9c6;
188
- $tr____highlight: $_yellow_1;
189
- $a--hover_0: #ffcccc;
190
- $a--hover_1: #ffc5c5;
206
+ $even: #efefef;
207
+ $odd: #ffffff;
208
+ $yellow_0: #ffffaa;
209
+ $yellow_1: #ffffcc;
210
+ $yellow_2: #f9f9a4;
211
+ $yellow_3: #f9f9c6;
212
+ $highlight: $_yellow_1;
213
+ $hover_0: #ffcccc;
214
+ $hover_1: #ffc5c5;
191
215
  ```
192
216
 
193
217
  And the generated `assets/stylesheets/lib/metareports_colors.scss` SASS file would be:
194
218
 
195
219
  ```scss
196
220
  @import 'metareports_color_variables.scss';
197
- .even { background: $_even; }
198
- .odd { background: $_odd; }
199
- .yellow:nth-child(4n+0) { background: $_yellow_0; }
200
- .yellow:nth-child(4n+1) { background: $_yellow_1; }
201
- .yellow:nth-child(4n+2) { background: $_yellow_2; }
202
- .yellow:nth-child(4n+3) { background: $_yellow_3; }
203
- tr .highlight { background: $_yellow_1 !important; }
204
- a:hover:nth-child(2n+0) { background: $a--hover_0; }
205
- a:hover:nth-child(2n+1) { background: $a--hover_1; }
221
+ tr.even { background: $even; }
222
+ tr.odd { background: $odd; }
223
+ tr.yellow:nth-child(4n+0) { background: $yellow_0; }
224
+ tr.yellow:nth-child(4n+1) { background: $yellow_1; }
225
+ tr.yellow:nth-child(4n+2) { background: $yellow_2; }
226
+ tr.yellow:nth-child(4n+3) { background: $yellow_3; }
227
+ tr.highlight { background: $yellow_1 !important; }
228
+ tr.hover:nth-child(2n+0) { background: $hover_0; }
229
+ tr.hover:nth-child(2n+1) { background: $hover_1; }
206
230
  ```
207
231
 
208
232
  Note that you can specify `!important` and it will be reproduced in the CSS style.
@@ -212,7 +236,7 @@ To export only the colors file, use the `meta_reports:export_colors_only` Rake t
212
236
 
213
237
  ##TODO
214
238
 
215
- - Common colors: This needs a common color mechanism, where all outputs that support color can have the same row / cell / text color. Any input on this is appreciated.
239
+ - Expand common colors to spreadsheets, and enable coloring of text / individual cells
216
240
  - Charts based on table data
217
241
  - More formats (e.g. csv, json, text)
218
242
  - Direct to email / print (using IPP) / fax
@@ -220,6 +244,7 @@ To export only the colors file, use the `meta_reports:export_colors_only` Rake t
220
244
 
221
245
  ##Changelog
222
246
 
247
+ - **0.0.5:** (11/16/13) Simplify color handling, color individual cells
223
248
  - **0.0.4:** (10/7/13) Colors rake task
224
249
  - **0.0.3:** (10/7/13) Template/model/helper generator
225
250
  - **0.0.2:** (9/29/13) Relax rails requirement, better testing
@@ -1,22 +1,22 @@
1
1
  module MetaReports
2
2
  module ReportsHelper
3
3
  def meta_report_color(klass, row = 0)
4
- color = MetaReports::Report::COLORS[klass.to_sym]
5
- return nil unless color
6
- if color.is_a? Array
7
- # the trailing split first is to drop any !important directive
8
- # color = color[row%color.length].to_s.split.first
9
- # the trailing gsub is to drop any !important directive
10
- color = color[row%color.length].to_s.gsub(/\s.*$/,'')
11
- end
12
- if color.gsub!(/^\$/, '') # we have a variable
13
- color = COLORS[color.to_sym]
4
+ @meta_reports_colors ||= {}
5
+ @meta_reports_colors[klass.to_sym] ||= begin
6
+ Rails.logger.info "getting color"
7
+ color = MetaReports::Report::COLORS[klass.to_sym]
8
+ return nil unless color
14
9
  if color.is_a? Array
15
- choice = color.gsub!(/Odd/,'') ? 1 : 0
16
- color = color[choice]
10
+ # the trailing split first is to drop any !important directive
11
+ color = color[row%color.length].to_s.split.first
12
+ end
13
+ if color.gsub!(/^\$/, '') # we have a variable
14
+ index = 0
15
+ index = $1 if color.gsub!(/_(\d+)$/,'')
16
+ color = meta_report_color(color, index)
17
17
  end
18
+ color
18
19
  end
19
- color
20
20
  end
21
21
 
22
22
  def convert_margins_to_xlsx(margins)
@@ -37,6 +37,15 @@ module MetaReports
37
37
  if cell.is_a? Hash
38
38
  tags = cell.reject {|k,v| k == :content || k == :html}
39
39
  tags[:class] ||= 'textcenter'
40
+ if MetaReports::Base.inline_css
41
+ color = nil
42
+ tags[:class].split(/\s+/).each do |token|
43
+ if color = meta_report_color(token)
44
+ break
45
+ end
46
+ end
47
+ tags[:style] = "background-color: ##{color}"
48
+ end
40
49
  content_tag tag, (cell[:html] || cell[:content]).to_s.html_safe, tags
41
50
  elsif cell.is_a? Array
42
51
  else
@@ -66,11 +75,19 @@ module MetaReports
66
75
  if data[i][j].is_a? Hash
67
76
  [:html, :title, :id].each {|sym| data[i][j].delete(sym)}
68
77
  _class = data[i][j].delete(:class)
69
- [:right, :left, :center].each do |sym|
70
- set_style(styling, sym, i, j) if _class =~ /\b#{sym}\b|[^a-z]#{sym}/i
71
- end
72
- if _class =~ /\bbold\b|\bstrong\b/
73
- set_style(styling, :bold, i, j)
78
+ unless _class.blank?
79
+ [:right, :left, :center].each do |sym|
80
+ set_style(styling, sym, i, j) if _class =~ /\b#{sym}\b|[^a-z]#{sym}/i
81
+ end
82
+ if _class =~ /\bbold\b|\bstrong\b/
83
+ set_style(styling, :bold, i, j)
84
+ end
85
+ _class.to_s.split(/\s+/).each do |token|
86
+ if color = meta_report_color(token)
87
+ set_style(styling, :cell_bg_colors, i, j, color)
88
+ break
89
+ end
90
+ end
74
91
  end
75
92
  unless data[i][j][:image] || data[i][j][:content].is_a?(String)
76
93
  data[i][j][:content] = data[i][j][:content].to_s
@@ -143,9 +160,9 @@ module MetaReports
143
160
  links.join(' ').html_safe
144
161
  end
145
162
 
146
- def set_style(styling, style, row, col)
163
+ def set_style(styling, style, row, col, val = nil)
147
164
  styling[style] ||= []
148
- styling[style] << [row,col]
165
+ styling[style] << (val ? [row,col,val] : [row,col])
149
166
  end
150
167
 
151
168
  def to_xls_col(column)
@@ -1,6 +1,9 @@
1
1
  class MetaReports::Base < ActiveRecord::Base
2
- attr_accessible :description, :direct, :group, :name, :target, :title, :views, :formats_mask
2
+ attr_accessible :description, :direct, :group, :name, :target, :title, :views, :formats_mask, :formats
3
3
  validates_presence_of :name, :title, :group
4
+
5
+ cattr_accessor :inline_css
6
+ @@inline_css = true
4
7
 
5
8
  self.table_name = "meta_reports_reports"
6
9
 
@@ -68,4 +71,9 @@ class MetaReports::Base < ActiveRecord::Base
68
71
  even: 'efefef',
69
72
  odd: 'ffffff',
70
73
  }
74
+
75
+ # Sorry, God doesn't help self.helpers, which is why you need it
76
+ def self.helpers
77
+ ApplicationController.helpers
78
+ end
71
79
  end
@@ -2,8 +2,10 @@ MetaReports::Engine.routes.draw do
2
2
  root to: "reports#index"
3
3
 
4
4
  get 'reports/file/:dir' => 'reports#file', as: 'file'
5
- resources :reports
5
+ get 'new' => 'reports#new', as: 'short_new'
6
+ post 'reports' => 'reports#create', as: 'normal_create'
6
7
  match ':id(.:format)' => 'reports#show', as: 'short_show', via: [:get, :post]
7
8
  get ':id/edit' => 'reports#edit', as: 'short_edit'
8
9
  get ':id/form' => 'reports#form', as: 'short_form'
10
+ resources :reports
9
11
  end
@@ -3,26 +3,14 @@ class MetaReports::Report < MetaReports::Base
3
3
  #
4
4
  # Shared colors. The key is the class name, value is RGB in hex format
5
5
  #
6
- # When you run the meta_reports:export_colors Rake task, the key changes as follows:
7
- # * In the SASS CSS file:
8
- # - '___' will be changed to ' '
9
- # - '__' will be changed to '#'
10
- # - '_' will be changed to '.'
11
- # - '--' will be changed to ':'
12
- # - an array of values will be changed to nth-child rules for consecutive rows
13
- # * In the SASS variables file:
14
- # - the variable name will be the same as the key
15
- # - an array of values will be changed into variables whose name is the class name plus a numerical suffix for each entry
16
- #
17
- # Example: 'tr____highlight' is 'tr .highlight {}' in CSS, and $tr____highlight as a SASS variable.
6
+ # Example: "highlight: 'ffcccc'" is 'tr.highlight {background: #ffcccc}' in CSS, and "$highlight: #ffcccc;"" as a SASS variable.
18
7
  #
19
8
 
20
9
  COLORS = {
21
- _even: 'efefef',
22
- _odd: 'ffffff',
23
- _yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
24
- tr____highlight: '$_yellow_1 !important',
25
- 'a--hover' => ['ffcccc', 'ffc5c5']
10
+ even: 'efefef',
11
+ odd: 'ffffff',
12
+ yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
13
+ highlight: '$yellow_1 !important',
26
14
  }
27
15
 
28
16
 
@@ -3,26 +3,14 @@ class MetaReports::Report
3
3
  #
4
4
  # Shared colors. The key is the class name, value is RGB in hex format
5
5
  #
6
- # When you run the meta_reports:export_colors Rake task, the key changes as follows:
7
- # * In the SASS CSS file:
8
- # - '___' will be changed to ' '
9
- # - '__' will be changed to '#'
10
- # - '_' will be changed to '.'
11
- # - '--' will be changed to ':'
12
- # - an array of values will be changed to nth-child rules for consecutive rows
13
- # * In the SASS variables file:
14
- # - the variable name will be the same as the key
15
- # - an array of values will be changed into variables whose name is the class name plus a numerical suffix for each entry
16
- #
17
- # Example: 'tr____highlight' is 'tr .highlight {}' in CSS, and $tr____highlight as a SASS variable.
6
+ # Example: "highlight: 'ffcccc'" is 'tr.highlight {background: #ffcccc}' in CSS, and "$highlight: #ffcccc;"" as a SASS variable.
18
7
  #
19
8
 
20
9
  COLORS = {
21
- _even: 'efefef',
22
- _odd: 'ffffff',
23
- _yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
24
- tr____highlight: '$_yellow_1 !important',
25
- 'a--hover' => ['ffcccc', 'ffc5c5']
10
+ even: 'efefef',
11
+ odd: 'ffffff',
12
+ yellow: ['ffffaa', 'ffffcc', 'f9f9a4', 'f9f9c6'],
13
+ highlight: '$yellow_1 !important',
26
14
  }
27
15
 
28
16
 
@@ -39,6 +39,15 @@
39
39
  <%= f.label :target %><br />
40
40
  <%= f.text_field :target %>
41
41
  </div>
42
+ <div class="field">
43
+ <% formats = @report.formats %>
44
+ <% for format in MetaReports::Base::FORMATS.sort %>
45
+ <%= check_box_tag "report[formats][]", format, formats.include?(format) %>
46
+ <span class='bold'><%= format.humanize %></span>
47
+ <br />
48
+ <% end %>
49
+ <%= hidden_field_tag "report[formats][]", "" %>
50
+ </div>
42
51
  <div class="actions">
43
52
  <%= f.submit %>
44
53
  </div>
@@ -7,7 +7,6 @@ pdf.text '(123) 456-7890', :size => 8
7
7
 
8
8
  pdf.move_up 35
9
9
  pdf.pad_bottom(10) do
10
- logger.info "title: #{title.inspect}"
11
10
  pdf.text title, :size => 18, :align => :center if title
12
11
  pdf.text subtitle, :size => 12, :align => :center if subtitle
13
12
  end
@@ -1,17 +1,11 @@
1
1
  wb = sheet.workbook
2
2
  styles = {} unless defined?(styles)
3
- unless styles[:bold]
4
- styles[:bold] = wb.styles.add_style :b => true
5
- end
6
- unless styles[:title]
7
- styles[:title] = wb.styles.add_style :sz => 14, :alignment => { :horizontal => :center}, :b => true
8
- end
9
- unless styles[:subtitle]
10
- styles[:subtitle] = wb.styles.add_style :sz => 12, :alignment => { :horizontal => :center}, :b => true
11
- end
3
+ styles[:bold] ||= wb.styles.add_style :b => true
4
+ styles[:title] ||= wb.styles.add_style :sz => 14, :alignment => { :horizontal => :center}, :b => true
5
+ styles[:subtitle] ||= wb.styles.add_style :sz => 12, :alignment => { :horizontal => :center}, :b => true
6
+ columns ||= 8
7
+ subtitle ||= ''
12
8
 
13
- columns = columns || 8
14
- subtitle = subtitle || ''
15
9
  sheet.add_row ["Company Name, Address"] + ['']*(columns-3) + [Date.today().to_s, Time.now().strftime("%I:%M")], :style => styles[:bold]
16
10
  sheet.add_row [' '] * columns
17
11
  sheet.add_row [title], :style => styles[:title]
@@ -4,16 +4,25 @@ table_class = table.options[:table_class].to_s if !defined?(table_class) || tabl
4
4
  %>
5
5
  <%= content_tag(:h4, table_name) %>
6
6
  <div class='list_container'>
7
- <%= content_tag(:table, :class => "table #{table_class}") do %>
7
+ <%= content_tag(:table, :class => "table table-condensed #{table_class}") do %>
8
8
  <% unless @report[:table_header] == false %>
9
9
  <%= content_tag(:thead, content_tag(:tr, table.to_a.shift.map { |h| html_cell(h, :th)}.join.html_safe ) ) %>
10
10
  <% end %>
11
11
  <tbody>
12
- <% table.to_a.each_with_index do |row, i| %>
13
- <%
14
- row_class = "#{cycle('odd','even')} #{row_classes[i]}".strip
12
+ <% table.to_a.each_with_index do |row, i|
13
+ style = nil
14
+ if MetaReports::Base.inline_css && row_classes[i]
15
+ color = nil
16
+ row_classes[i].split(/\s+/).each do |token|
17
+ if color = meta_report_color(token)
18
+ break
19
+ end
20
+ end
21
+ style = "background-color: ##{color}"
22
+ #TODO: handle bold, alignment
23
+ end
15
24
  %>
16
- <%= content_tag(:tr, :class => row_class) do
25
+ <%= content_tag(:tr, class: row_classes[i], style: style) do
17
26
  row.each do |cell|
18
27
  %><%= html_cell(cell) %><%
19
28
  end
@@ -5,6 +5,7 @@ styling = {}
5
5
  column_widths = {} if !defined?(column_widths) || column_widths.blank?
6
6
  font_size = table[:font_size] || 8
7
7
  table_header = table[:table_header] != false
8
+ row_offset = table_header ? 1 : 0
8
9
  pdf.table prep_pdf_table(table, styling), :header => table_header, :row_colors => ["EEEEEE", "FFFFFF"], :width => pdf.bounds.width, :cell_style => {:padding => 2, :size => font_size, :align => :center} do |t|
9
10
  t.cells.borders = []
10
11
  t.style t.row(0), :borders => [:bottom], :background_color => "DDDDDD", :font_style => :bold
@@ -17,7 +18,10 @@ pdf.table prep_pdf_table(table, styling), :header => table_header, :row_colors =
17
18
  t.style t.row(cell[0]).column(cell[1]), :font_style => :bold
18
19
  end
19
20
  styling[:row_colors].each do |row, color|
20
- t.style t.row(row), :background_color => color
21
+ t.style t.row(row+row_offset), :background_color => color
22
+ end
23
+ styling[:cell_bg_colors].to_a.each do |cell|
24
+ t.style t.row(cell[0]).column(cell[1]), :background_color => cell[2]
21
25
  end
22
26
  if styling[:column_widths]
23
27
  t.column_widths = styling[:column_widths]
@@ -1,5 +1,5 @@
1
1
  margin = @report[:page_margin] && [*@report[:page_margin]][0,4] || nil
2
- prawn_document(page_orientation: @report[:page_orientation] || :portrait, page_size: @report[:page_size] || 'LETTER', margin: margin) do |pdf|
2
+ prawn_document(page_layout: @report[:page_orientation] || :portrait, page_size: @report[:page_size] || 'LETTER', margin: margin) do |pdf|
3
3
 
4
4
  render :partial => "meta_reports/reports/templates/default_header", :locals => { :pdf => pdf, :title => @report[:title], :subtitle => @report[:subtitle] }
5
5
  pdf.font_size = @report[:font_size] || 8
@@ -13,11 +13,13 @@ table_names = @report[:table_order] || @report[:tables].keys.sort_by {|k| k.to_s
13
13
  table_names.each do |table_name|
14
14
  table = @report[:tables][table_name]
15
15
  pdf.pad_bottom(25) do
16
- # TODO: provide option to 'group' all or one table
17
- # this forces a table to stay together on one page. throws an error if a table is larger than a page.
18
- # pdf.group do
16
+ if table[:group]
17
+ pdf.group do #if the table is larger than a page this will throw an error
18
+ render :partial => 'meta_reports/reports/templates/default_table', :locals => {:pdf => pdf, :title => table_name, :table => table}
19
+ end
20
+ else
19
21
  render :partial => 'meta_reports/reports/templates/default_table', :locals => {:pdf => pdf, :title => table_name, :table => table}
20
- # end
22
+ end
21
23
  end
22
24
  end
23
25