Issue.load_relations(@issues) if include_in_api_response?('relations')
}
format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
- format.csv { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
+ format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') }
format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
end
else
end
end
- def issues_to_csv(issues, project = nil)
+ def issues_to_csv(issues, project, query, options={})
+ ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
decimal_separator = l(:general_csv_decimal_separator)
+ encoding = l(:general_csv_encoding)
+ columns = (options[:columns] == 'all' ? query.available_columns : query.columns)
+
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
# csv header fields
- headers = [ "#",
- l(:field_status),
- l(:field_project),
- l(:field_tracker),
- l(:field_priority),
- l(:field_subject),
- l(:field_assigned_to),
- l(:field_category),
- l(:field_fixed_version),
- l(:field_author),
- l(:field_start_date),
- l(:field_due_date),
- l(:field_done_ratio),
- l(:field_estimated_hours),
- l(:field_parent_issue),
- l(:field_created_on),
- l(:field_updated_on)
- ]
- # Export project custom fields if project is given
- # otherwise export custom fields marked as "For all projects"
- custom_fields = project.nil? ? IssueCustomField.for_all : project.all_issue_custom_fields
- custom_fields.each {|f| headers << f.name}
- # Description in the last column
- headers << l(:field_description)
- csv << headers.collect {|c| Redmine::CodesetUtil.from_utf8(
- c.to_s,
- l(:general_csv_encoding) ) }
+ csv << [ "#" ] + columns.collect {|c| Redmine::CodesetUtil.from_utf8(c.caption.to_s, encoding) } +
+ (options[:description] ? [Redmine::CodesetUtil.from_utf8(l(:field_description), encoding)] : [])
+
# csv lines
issues.each do |issue|
- fields = [issue.id,
- issue.status.name,
- issue.project.name,
- issue.tracker.name,
- issue.priority.name,
- issue.subject,
- issue.assigned_to,
- issue.category,
- issue.fixed_version,
- issue.author.name,
- format_date(issue.start_date),
- format_date(issue.due_date),
- issue.done_ratio,
- issue.estimated_hours.to_s.gsub('.', decimal_separator),
- issue.parent_id,
- format_time(issue.created_on),
- format_time(issue.updated_on)
- ]
- custom_fields.each {|f| fields << show_value(issue.custom_value_for(f)) }
- fields << issue.description
- csv << fields.collect {|c| Redmine::CodesetUtil.from_utf8(
- c.to_s,
- l(:general_csv_encoding) ) }
+ col_values = columns.collect do |column|
+ s = if column.is_a?(QueryCustomFieldColumn)
+ cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
+ show_value(cv)
+ else
+ value = issue.send(column.name)
+ if value.is_a?(Date)
+ format_date(value)
+ elsif value.is_a?(Time)
+ format_time(value)
+ elsif value.is_a?(Float)
+ value.to_s.gsub('.', decimal_separator)
+ else
+ value
+ end
+ end
+ s.to_s
+ end
+ csv << [ issue.id.to_s ] + col_values.collect {|c| Redmine::CodesetUtil.from_utf8(c.to_s, encoding) } +
+ (options[:description] ? [Redmine::CodesetUtil.from_utf8(issue.description, encoding)] : [])
end
end
export
<% other_formats_links do |f| %>
<%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %>
- <%= f.link_to 'CSV', :url => params %>
+ <%= f.link_to 'CSV', :url => params, :onclick => "showModal('csv-export-options', '330px'); return false;" %>
<%= f.link_to 'PDF', :url => params %>
<% end %>
+<div id="csv-export-options" style="display:none;">
+ <h3 class="title"><%= l(:label_export_options, :export_format => 'CSV') %></h3>
+ <% form_tag(params.merge({:format => 'csv',:page=>nil}), :method => :get, :id => 'csv-export-form') do %>
+ <p>
+ <label><%= radio_button_tag 'columns', '', true %> <%= l(:description_selected_columns) %></label><br />
+ <label><%= radio_button_tag 'columns', 'all' %> <%= l(:description_all_columns) %></label>
+ </p>
+ <p>
+ <label><%= check_box_tag 'description', '1' %> <%= l(:field_description) %></label>
+ </p>
+ <p style="text-align:right; margin-bottom:0">
+ <%= submit_tag l(:button_export), :name => nil, :onclick => "hideModal(this);" %>
+ <%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
+ </p>
+ <% end %>
+</div>
+
<% end %>
<%= call_hook(:view_issues_index_bottom, { :issues => @issues, :project => @project, :query => @query }) %>
description_date_from: Въведете начална дата
description_date_to: Въведете крайна дата
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
label_child_revision: Child
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
label_git_report_last_commit: Report last commit for files and directories
label_parent_revision: Parent
label_child_revision: Child
+ label_export_options: %{export_format} export options
button_login: Login
button_submit: Submit
button_duplicate: Duplicate
button_show: Show
button_edit_section: Edit this section
+ button_export: Export
status_active: active
status_registered: registered
description_user_mail_notification: Mail notification settings
description_available_columns: Available Columns
description_selected_columns: Selected Columns
+ description_all_columns: All Columns
description_issue_category_reassign: Choose issue category
description_wiki_subpages_reassign: Choose new parent page
description_date_range_list: Choose range from list
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
label_issues_visibility_all: Toutes les demandes
label_issues_visibility_public: Toutes les demandes non privées
label_issues_visibility_own: Demandes créées par ou assignées à l'utilisateur
+ label_export_options: Options d'exportation %{export_format}
button_login: Connexion
button_submit: Soumettre
button_duplicate: Dupliquer
button_show: Afficher
button_edit_section: Modifier cette section
+ button_export: Exporter
status_active: actif
status_registered: enregistré
description_user_mail_notification: Mail notification settings
description_date_from: Enter start date
description_message_content: Message content
- description_available_columns: Available Columns
+ description_available_columns: Colonnes disponibles
+ description_all_columns: Toutes les colonnes
description_date_range_interval: Choose range by selecting start and end date
description_issue_category_reassign: Choose issue category
description_search: Searchfield
description_date_to: Enter end date
description_query_sort_criteria_attribute: Sort attribute
description_wiki_subpages_reassign: Choose new parent page
- description_selected_columns: Selected Columns
+ description_selected_columns: Colonnes sélectionnées
label_parent_revision: Parent
label_child_revision: Child
error_scm_annotate_big_text_file: The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
error_scm_annotate_big_text_file: The entry cannot be annotated, as it exceeds the maximum text file size.
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: Use current date as start date for new issues
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
description_date_to: 輸入結束日期
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
setting_default_issue_start_date_to_creation_date: 使用当前日期作为新问题的开始日期
button_edit_section: Edit this section
setting_repositories_encodings: Attachments and repositories encodings
+ description_all_columns: All Columns
+ button_export: Export
+ label_export_options: "%{export_format} export options"
}
}
+function showModal(id, width) {
+ el = $(id);
+ if (el == undefined || el.visible()) {return;}
+ var h = $$('body')[0].getHeight();
+ var d = document.createElement("div");
+ d.id = 'modalbg';
+ $('main').appendChild(d);
+ $('modalbg').setStyle({ width: '100%', height: h + 'px' });
+ $('modalbg').show();
+
+ var pageWidth = document.viewport.getWidth();
+ el.setStyle({'width': width});
+ el.setStyle({'left': (((pageWidth - el.getWidth())/2 *100) / pageWidth) + '%'});
+ el.addClassName('modal');
+ el.show();
+
+ var submit = el.down("input[type=submit]");
+ if (submit) {
+ submit.focus();
+ }
+}
+
+function hideModal(el) {
+ var modal = Element.up(el, 'div.modal');
+ if (modal) {
+ modal.hide();
+ }
+ var bg = $('modalbg');
+ if (bg) {
+ bg.remove();
+ }
+}
+
function collapseScmEntry(id) {
var els = document.getElementsByClassName(id, 'browser');
for (var i = 0; i < els.length; i++) {
#login-form label {font-weight: bold;}
#login-form input#username, #login-form input#password { width: 300px; }
+#modalbg {position:absolute; top:0; left:0; width:100%; height:100%; background:#ccc; z-index:49; opacity:0.5;}
+html>body #modalbg {position:fixed;}
+div.modal { border-radius:5px; position:absolute; top:25%; background:#fff; border:2px solid #759FCF; z-index:50; padding:0px; padding:8px;}
+div.modal h3.title {background:#759FCF; color:#fff; border:0; padding-left:8px; margin:-8px; margin-bottom: 1em; border-top-left-radius:2px;border-top-right-radius:2px;}
+html>body div.modal {position:fixed;}
+
input#openid_url { background: url(../images/openid-bg.gif) no-repeat; background-color: #fff; background-position: 0 50%; padding-left: 18px; }
.clear:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; }
get :index, :sort => 'tracker'
end
- def test_index_csv_with_project
- Setting.default_language = 'en'
-
+ def test_index_csv
get :index, :format => 'csv'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
assert @response.body.starts_with?("#,")
+ lines = @response.body.chomp.split("\n")
+ assert_equal assigns(:query).columns.size + 1, lines[0].split(',').size
+ end
+ def test_index_csv_with_project
get :index, :project_id => 1, :format => 'csv'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
end
+ def test_index_csv_with_description
+ get :index, :format => 'csv', :description => '1'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert_equal 'text/csv', @response.content_type
+ assert @response.body.starts_with?("#,")
+ lines = @response.body.chomp.split("\n")
+ assert_equal assigns(:query).columns.size + 2, lines[0].split(',').size
+ end
+
+ def test_index_csv_with_all_columns
+ get :index, :format => 'csv', :columns => 'all'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert_equal 'text/csv', @response.content_type
+ assert @response.body.starts_with?("#,")
+ lines = @response.body.chomp.split("\n")
+ assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
+ end
+
def test_index_csv_big_5
with_settings :default_language => "zh-TW" do
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88"
:op => '=', :values => [str_utf8],
:format => 'csv'
assert_equal 'text/csv', @response.content_type
- lines = @response.body.chomp.split("\n")
+ lines = @response.body.chomp.split("\n")
s1 = "\xaa\xac\xbaA"
if str_utf8.respond_to?(:force_encoding)
s1.force_encoding('Big5')
get :index, :project_id => 1,
:f => ['subject'],
:op => '=', :values => [str_utf8],
- :format => 'csv'
+ :c => ['status', 'subject'],
+ :format => 'csv',
+ :set_filter => 1
assert_equal 'text/csv', @response.content_type
- lines = @response.body.chomp.split("\n")
- s1 = "\xaa\xac\xbaA"
+ lines = @response.body.chomp.split("\n")
+ s1 = "\xaa\xac\xbaA" # status
if str_utf8.respond_to?(:force_encoding)
s1.force_encoding('Big5')
end
assert lines[0].include?(s1)
- s2 = lines[1].split(",")[5]
+ s2 = lines[1].split(",")[2]
if s1.respond_to?(:force_encoding)
- s3 = "\xa5H?"
+ s3 = "\xa5H?" # subject
s3.force_encoding('Big5')
assert_equal s3, s2
elsif RUBY_PLATFORM == 'java'