query_report 1.0.14 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  <tfoot>
3
3
  <tr>
4
4
  <% report.column_total_with_colspan.each do |total_with_colspan| %>
5
- <td colspan="<%= total_with_colspan[:colspan] %>"><%= total_with_colspan[:content] %></td>
5
+ <td colspan="<%= total_with_colspan[:colspan] %>" align="right"><%= total_with_colspan[:content] %></td>
6
6
  <% end %>
7
7
  </tr>
8
8
  </tfoot>
@@ -11,11 +11,14 @@
11
11
  <% records.each do |record| %>
12
12
  <tr>
13
13
  <% report.columns.each do |column| %>
14
- <% value = record[column.humanize] %>
14
+ <% value = record[column.humanize]
15
+ align = column.align
16
+ align_attr = align ? "align=#{align.to_s}" : ''
17
+ %>
15
18
  <% if value.kind_of?(Hash) %>
16
- <td rowspan="<%= value[:rowspan] %>"><%= value[:content] %></td>
19
+ <td rowspan="<%= value[:rowspan] %>" <%= align_attr %> ><%= value[:content] %></td>
17
20
  <% elsif record.has_key?(column.humanize) %>
18
- <td><%= value %></td>
21
+ <td <%= align_attr %>><%= value %></td>
19
22
  <% end %>
20
23
  <% end %>
21
24
  </tr>
@@ -85,6 +85,10 @@ module QueryReport
85
85
  @options[:show_total] == true
86
86
  end
87
87
 
88
+ def align
89
+ @options[:align] || (has_total? ? :right : :left)
90
+ end
91
+
88
92
  def total
89
93
  @total ||= has_total? ? report.records.inject(0) { |sum, r| sum + report.content_from_element(r[humanize]).to_f } : nil
90
94
  end
@@ -53,6 +53,12 @@ module QueryReport
53
53
  report_columns.collect { |h| fix_content h.humanize }
54
54
  end
55
55
 
56
+ def alignment_hash
57
+ #@alignment_hash ||= report.columns.inject({}, ) do |col|
58
+ # column(index).style :align => col.align if col.align
59
+ #end
60
+ end
61
+
56
62
  def table_content_for(report)
57
63
  table_items = report.all_records_with_rowspan
58
64
  items = table_items.map do |item|
@@ -1,3 +1,3 @@
1
1
  module QueryReport
2
- VERSION = "1.0.14"
2
+ VERSION = "1.0.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-31 00:00:00.000000000 Z
12
+ date: 2013-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails