Implement filter settings headers for issues. #16359

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@1145 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
t.felgentreff 15 years ago
parent b5b51a6fc5
commit 1e238ddd21
  1. 13
      app/views/issues/printable.rhtml
  2. 1
      config/locales/de.yml
  3. 1
      config/locales/en.yml
  4. 23
      lib/xls_report/issues_controller_patch.rb
  5. 6
      lib/xls_report/spreadsheet_builder.rb

@ -3,6 +3,19 @@
<%= error_messages_for 'query' %>
<% if @query.valid? %>
<table>
<tr>
<td><strong><%= l(:label_filter_plural) %>:</strong></td>
<td><%= FilterSettingsHelper.filter_settings(@query).join(", ") %></td>
</tr>
<% if group_by_settings = FilterSettingsHelper.group_by_setting(@query) %>
<tr>
<td><strong><%= l(:field_group_by) %>:</strong></td>
<td><%= group_by_settings %></td>
</tr>
<% end %>
</table>
<% if @issues.empty? %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>

@ -1,3 +1,4 @@
de:
print_with_description: "Drucken mit Beschreibung"
export_to_excel: "Exportieren als Excel Spreadsheet"
sentence_separator_or: "oder"

@ -1,3 +1,4 @@
en:
export_to_excel: "Export as Excel spreadsheet"
print_with_description: "Print with description"
sentence_separator_or: "or"

@ -1,6 +1,7 @@
require_dependency 'issues_controller'
require_dependency 'xls_report/spreadsheet_builder'
require_dependency 'additional_formats/filter_settings_helper'
module XlsReport
module IssuesControllerPatch
def self.included(base) # :nodoc:
@ -33,12 +34,24 @@ module XlsReport
end
# Convert an issues query with associated issues to xls using the queries columns as headers
def build_spreadsheet(project, issues, columns)
def build_spreadsheet(project, issues, query)
columns = query.columns
sb = SpreadsheetBuilder.new
project_name = (project.name if project) || "All Projects"
sb.add_title("#{project_name} >> #{l(:label_issue_plural)} (#{format_date(Date.today)})")
headers = (columns.collect(&:caption) << l(:field_description)).unshift("#")
sb.add_headers(headers)
filters = FilterSettingsHelper.filter_settings(query)
sb.add_headers l(:label_filter_plural)
sb.add_row(filters)
group_by_settings = FilterSettingsHelper.group_by_setting(query)
if group_by_settings
sb.add_headers l(:field_group_by)
sb.add_row group_by_settings
end
sb.add_empty_row
headers = (columns.collect(&:caption) << l(:field_description)).unshift("#")
sb.add_headers headers
issues.each do |issue|
sb.add_row((columns.collect do |column|
@ -61,7 +74,7 @@ module XlsReport
# Return an xls file from a spreadsheet builder
def issues_to_xls
build_spreadsheet(@project, @issues, @query.columns).xls
build_spreadsheet(@project, @issues, @query).xls
end
end
end

@ -82,11 +82,11 @@ class SpreadsheetBuilder
# Add headers. This is usually used for adding a table header to the
# second row in the document, but the row can be set using the second
# optional parameter. The format is automatically set to bold font
def add_headers(arr, idx = 1)
def add_headers(arr, idx = nil)
header_format = Spreadsheet::Format.new(:weight => :bold)
(arr.size + 1).times { |i| @sheet.row(idx).set_format(i, header_format) }
idx = [idx, 1].max
add_row(arr, idx)
idx ||= @sheet.last_row_index
(arr.size + 1).times { |i| @sheet.row(idx).set_format(i, header_format) }
end
# Add a simple row. This will default to the next row in the sequence.

Loading…
Cancel
Save