Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Commit

Permalink
Resolved conflict in lib/xls_export.rb.
Browse files Browse the repository at this point in the history
  • Loading branch information
two-pack committed Sep 7, 2011
2 parents be975a7 + 447170a commit 1b09921
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/views/settings/_xls_export_settings.html.erb
@@ -1,5 +1,5 @@
<% fields_all = [['relations','watchers','description', 'time','attachments' ], ['query_columns_only','group','generate_name'] ] %>
<% fields_all = [['relations','watchers','description', 'history', 'time','attachments' ], ['query_columns_only','group','generate_name'] ] %>
<% fields_all.each do |c|%>
<div class="box tabular">
<p><% c.each do |fnm| -%>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/bg.yml
Expand Up @@ -2,6 +2,7 @@ bg:
label_plugin_xlse_relations: "Експорт на връзките"
label_plugin_xlse_watchers: "Експорт на наблюдателите"
label_plugin_xlse_description: "Експорт на описанията"
label_plugin_xlse_history: "износ история"
label_plugin_xlse_time: "Експорт на употребеното време"
label_plugin_xlse_attachments: "Списък на прикачените файлове"
label_plugin_xlse_query_columns_only: "Експорт само на избраните колони"
Expand All @@ -22,3 +23,5 @@ bg:
label_plugin_xlse_export_format_quick_tooltip: "Експортиране с опции по подразбиране"
label_plugin_xlse_export_format_detailed: "Подробно"
label_plugin_xlse_export_format_detailed_tooltip: "Избор на опции преди експортиране"

field_history: "история"
3 changes: 3 additions & 0 deletions config/locales/cs.yml
Expand Up @@ -2,6 +2,7 @@ cs:
label_plugin_xlse_relations: "Exportovat vazby"
label_plugin_xlse_watchers: "Exportovat sledování"
label_plugin_xlse_description: "Exportovat popis"
label_plugin_xlse_history: "Exportovat historii"
label_plugin_xlse_time: "Exportovat strávený čas"
label_plugin_xlse_attachments: "Vypsat přílohy"
label_plugin_xlse_query_columns_only: "Exportovat pouze zvolené sloupce"
Expand All @@ -17,3 +18,5 @@ cs:

label_plugin_xlse_field_attachment: "Přílohy"

field_history: "Historie"

3 changes: 3 additions & 0 deletions config/locales/de.yml
Expand Up @@ -2,6 +2,7 @@ de:
label_plugin_xlse_relations: "Ticket-Beziehnungen exportieren"
label_plugin_xlse_watchers: "Beobachter exportieren"
label_plugin_xlse_description: "Beschreibungen exportieren"
label_plugin_xlse_history: "Historie exportieren"
label_plugin_xlse_time: "Aufgewendete Zeit exportieren"
label_plugin_xlse_attachments: "Anhänge auflisten"
label_plugin_xlse_query_columns_only: "Nur ausgewählte Spalten exportieren"
Expand All @@ -22,3 +23,5 @@ de:
label_plugin_xlse_export_format_quick_tooltip: "Exportiere mit Standard Einstellungen"
label_plugin_xlse_export_format_detailed: "Detailierter Export"
label_plugin_xlse_export_format_detailed_tooltip: "Wähle Export Optionen"

field_history: "Historie"
3 changes: 3 additions & 0 deletions config/locales/en.yml
Expand Up @@ -2,6 +2,7 @@ en:
label_plugin_xlse_relations: "Export relations"
label_plugin_xlse_watchers: "Export watchers"
label_plugin_xlse_description: "Export description"
label_plugin_xlse_history: "Export history"
label_plugin_xlse_time: "Export spent time"
label_plugin_xlse_attachments: "List attachments"
label_plugin_xlse_query_columns_only: "Export selected columns only"
Expand All @@ -22,4 +23,6 @@ en:
label_plugin_xlse_export_format_quick_tooltip: "Export using default settings"
label_plugin_xlse_export_format_detailed: "Detailed"
label_plugin_xlse_export_format_detailed_tooltip: "Choose options before export"

field_history: "History"

3 changes: 3 additions & 0 deletions config/locales/ja.yml
Expand Up @@ -2,6 +2,7 @@ ja:
label_plugin_xlse_relations: "関連を出力"
label_plugin_xlse_watchers: "ウォッチャーを出力"
label_plugin_xlse_description: "説明を出力"
label_plugin_xlse_history: "履歴を出力"
label_plugin_xlse_time: "作業時間を出力"
label_plugin_xlse_attachments: "添付ファイルのリストを出力"
label_plugin_xlse_query_columns_only: "選択した列だけを出力"
Expand All @@ -22,4 +23,6 @@ ja:
label_plugin_xlse_export_format_quick_tooltip: "標準の設定で出力する"
label_plugin_xlse_export_format_detailed: "オプション"
label_plugin_xlse_export_format_detailed_tooltip: "オプションを指定して出力する"

field_history: "履歴"

2 changes: 2 additions & 0 deletions config/locales/pl.yml
Expand Up @@ -4,6 +4,7 @@ pl:
label_plugin_xlse_relations: "Eksportuj powiązania"
label_plugin_xlse_watchers: "Eksportuj obserwatorów"
label_plugin_xlse_description: "Eksportuj opis"
label_plugin_xlse_history: "Eksportuj Historia"
label_plugin_xlse_time: "Eksportuj dziennik"
label_plugin_xlse_attachments: "Ekportuj listę załączników"
label_plugin_xlse_query_columns_only: "Eksportuj tylko zaznaczone kolumny"
Expand All @@ -25,3 +26,4 @@ pl:
label_plugin_xlse_export_format_detailed: "Szczegółowy"
label_plugin_xlse_export_format_detailed_tooltip: "Ustaw opcje przed eksportem"

field_history: "Historia"
3 changes: 3 additions & 0 deletions config/locales/pt-BR.yml
Expand Up @@ -2,6 +2,7 @@ pt-BR:
label_plugin_xlse_relations: "Exportar tarefas relacionadas"
label_plugin_xlse_watchers: "Exportar observadores"
label_plugin_xlse_description: "Exportar descrição"
label_plugin_xlse_history: "Exportar história"
label_plugin_xlse_time: "Exportar tempo de trabalho"
label_plugin_xlse_attachments: "Listar anexos"
label_plugin_xlse_query_columns_only: "Exportar apenas as colunas selecionadas"
Expand All @@ -22,3 +23,5 @@ pt-BR:
label_plugin_xlse_export_format_quick_tooltip: "Exportar usando as configurações padrão"
label_plugin_xlse_export_format_detailed: "Detalhado"
label_plugin_xlse_export_format_detailed_tooltip: "Escolher as opções antes da exportação"

field_history: "história"
3 changes: 3 additions & 0 deletions config/locales/ru.yml
Expand Up @@ -2,6 +2,7 @@ ru:
label_plugin_xlse_relations: "Экспортировать отношения"
label_plugin_xlse_watchers: "Экспортировать наблюдатeлей"
label_plugin_xlse_description: "Экспортировать описания"
label_plugin_xlse_history: "Экспортировать История"
label_plugin_xlse_time: "Экспортировать затраченное время"
label_plugin_xlse_attachments: "Список вложений"
label_plugin_xlse_query_columns_only: "Экспортировать только выделенные поля"
Expand All @@ -22,3 +23,5 @@ ru:
label_plugin_xlse_export_format_quick_tooltip: "Сохранить в XLSб используя значения по умолчанию"
label_plugin_xlse_export_format_detailed: "Подробный"
label_plugin_xlse_export_format_detailed_tooltip: "Выбрать опции перед сохранением в XLS"

field_history: "История"
3 changes: 3 additions & 0 deletions config/locales/zh-TW.yml
Expand Up @@ -2,6 +2,7 @@ zh-TW:
label_plugin_xlse_relations: "導出關係"
label_plugin_xlse_watchers: "導出跟蹤者"
label_plugin_xlse_description: "導出描述"
label_plugin_xlse_history: "導出歷史"
label_plugin_xlse_time: "導出耗時"
label_plugin_xlse_attachments: "列出附件"
label_plugin_xlse_query_columns_only: "僅導出選中"
Expand All @@ -21,3 +22,5 @@ zh-TW:
label_plugin_xlse_export_format_quick_tooltip: "使用預設設置導出"
label_plugin_xlse_export_format_detailed: "詳情"
label_plugin_xlse_export_format_detailed_tooltip: "導出之前選擇配置"

field_history: "歷史"
3 changes: 3 additions & 0 deletions config/locales/zh.yml
Expand Up @@ -2,6 +2,7 @@ zh:
label_plugin_xlse_relations: "导出关系"
label_plugin_xlse_watchers: "导出跟踪者"
label_plugin_xlse_description: "导出描述"
label_plugin_xlse_history: "导出历史记录"
label_plugin_xlse_time: "导出耗时"
label_plugin_xlse_attachments: "列出附件"
label_plugin_xlse_query_columns_only: "仅导出选中"
Expand All @@ -21,3 +22,5 @@ zh:
label_plugin_xlse_export_format_quick_tooltip: "使用默认设置导出"
label_plugin_xlse_export_format_detailed: "详情"
label_plugin_xlse_export_format_detailed_tooltip: "导出之前选择配置"

field_history: "历史记录"
1 change: 1 addition & 0 deletions init.rb
Expand Up @@ -28,6 +28,7 @@
'relations' => '1',
'watchers' => '1',
'description' => '1',
'history' => '0',
'time' => '0',
'attachments' => '0',
'query_columns_only' => '0',
Expand Down
95 changes: 59 additions & 36 deletions lib/xls_export.rb
Expand Up @@ -34,23 +34,24 @@ module Redmine
module Export
module XLS
unloadable

def issue_list(issues, &block)
ancestors = []
issues.each do |issue|
while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
ancestors.pop
end
yield issue, ancestors.size
ancestors << issue unless issue.leaf?
end
end

def issue_list(issues, &block)
ancestors = []
issues.each do |issue|
while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
ancestors.pop
end
yield issue, ancestors.size
ancestors << issue unless issue.leaf?
end
end

# options are
# :relations - export relations
# :watchers - export watchers
# :time - export time spent
# :description - export descriptions
# :history - export history
# :attachments - export attachments info
# :query_columns_only - export only columns from actual query
# :group - group by query grouping
Expand All @@ -63,6 +64,7 @@ def issues_to_xls2(issues, project, query, options = {})
show_watchers = options[:watchers]
show_time = options[:time]
show_descr = options[:description]
show_hist = options[:history]
query_columns_only = options[:query_columns_only]
show_attachment = options[:attachments]
group_by_query = query.grouped? ? options[:group] : false
Expand Down Expand Up @@ -92,7 +94,11 @@ def issues_to_xls2(issues, project, query, options = {})

if show_descr == '1'
issue_columns << QueryColumn.new(:description)
end
end

if show_hist == '1'
issue_columns << QueryColumn.new(:history)
end

sheet1 = nil
group = false
Expand All @@ -119,41 +125,41 @@ def issues_to_xls2(issues, project, query, options = {})

row = sheet1.row(idx+1)

row.replace [issue.id]

row.replace [issue.id]


lf_pos = get_value_width(issue.id)
columns_width[0] = lf_pos unless columns_width[0] >= lf_pos

last_prj = project

if level > 0
s = s.to_s.rjust(level*3)
issue.subject = s + issue.subject
last_prj = project

if level > 0
s = s.to_s.rjust(level*3)
issue.subject = s + issue.subject
end

boldfmt = Spreadsheet::Format.new :weight => :bold
row.set_format(0, boldfmt) if issue.children?
issue_columns.each_with_index do |c, j|

boldfmt = Spreadsheet::Format.new :weight => :bold
row.set_format(0, boldfmt) if issue.children?
issue_columns.each_with_index do |c, j|
fmt = Spreadsheet::Format.new :weight => :bold
v = if c.is_a?(QueryCustomFieldColumn)
case c.custom_field.field_format
when "int"
begin
begin
fmt.number_format = "0"
Integer(issue.custom_value_for(c.custom_field).to_s)
rescue
show_value(issue.custom_value_for(c.custom_field))
end
when "float"
begin
begin
fmt.number_format = "0.00"
Float(issue.custom_value_for(c.custom_field).to_s)
rescue
show_value(issue.custom_value_for(c.custom_field))
end
when "date"
begin
begin
fmt.number_format = "dd.mm.yyyy"
Date.parse(issue.custom_value_for(c.custom_field).to_s)
rescue
Expand All @@ -164,7 +170,7 @@ def issues_to_xls2(issues, project, query, options = {})
end
else
case c.name
when :done_ratio
when :done_ratio
fmt.number_format = "0%"
(Float(issue.send(c.name)))/100
when :description
Expand All @@ -175,6 +181,25 @@ def issues_to_xls2(issues, project, query, options = {})
end
end
descr_str
when :history
hist_str = ''
issue_updates = issue.journals.find(
:all, :include => [:user, :details],
:order => "#{Journal.table_name}.created_on ASC")
for journal in issue_updates
hist_str << format_time(journal.created_on) + " - " + journal.user.name
hist_str << "\n"
for detail in journal.details
hist_str << " - " + show_detail(detail, true)
hist_str << "\n" unless detail == journal.details.last
end
if journal.notes?
hist_str << "\n" unless journal.details.empty?
hist_str << journal.notes.to_s
end
hist_str << "\n" unless journal == issue_updates.last
end
hist_str
when :formatted_relations
rel_str = ''
relations = issue.relations.select {|r| r.other_issue(issue).visible?}
Expand All @@ -194,7 +219,7 @@ def issues_to_xls2(issues, project, query, options = {})
end
end
rel_str
when :spent_time
when :spent_time
if User.current.allowed_to?(:view_time_entries, last_prj)
c.value(issue)
else
Expand All @@ -204,19 +229,17 @@ def issues_to_xls2(issues, project, query, options = {})
c.value(issue)
when :project
last_prj = issue.send(c.name)
last_prj
when :start_date, :due_date
fmt.number_format = "dd.mm.yyyy"
last_prj
when :start_date, :due_date
fmt.number_format = "dd.mm.yyyy"
c.value(issue)
else
else
issue.respond_to?(c.name) ? issue.send(c.name) : c.value(issue)
end
end

value = ['Time', 'Date', 'Fixnum', 'Float', 'Integer', 'String'].include?(v.class.name) ? v : v.to_s

row.set_format(j+1, fmt) if issue.children?

value = ['Time', 'Date', 'Fixnum', 'Float', 'Integer', 'String', 'String'].include?(v.class.name) ? v : v.to_s
row.set_format(j+1, fmt) if issue.children?
lf_pos = get_value_width(value)
columns_width[j+1] = lf_pos unless columns_width[j+1] >= lf_pos
row << value
Expand Down

0 comments on commit 1b09921

Please sign in to comment.