Removed empty first column of repository export file. [SCI-1383]

This commit is contained in:
Matej Zrimšek 2017-06-20 18:40:41 +02:00
parent 164d41c8c5
commit 47407ef40c
2 changed files with 16 additions and 12 deletions

View file

@ -230,15 +230,18 @@ $('form#form-export').submit(function() {
case 'checkbox':
val = -1;
break;
case 'row-name':
case 'assigned':
val = -2;
break;
case 'added-by':
case 'row-name':
val = -3;
break;
case 'added-on':
case 'added-by':
val = -4;
break;
case 'added-on':
val = -5;
break;
default:
val = th.attr('id');
}

View file

@ -245,18 +245,18 @@ class RepositoriesController < ApplicationController
def to_csv(rows, column_ids)
require 'csv'
byebug
# Parse column names
csv_header = []
column_ids.each do |c_id|
csv_header << case c_id.to_i
when -1
when -1, -2
next
when -2
I18n.t('repositories.table.row_name')
when -3
I18n.t('repositories.table.added_by')
I18n.t('repositories.table.row_name')
when -4
I18n.t('repositories.table.added_by')
when -5
I18n.t('repositories.table.added_on')
else
column = RepositoryColumn.find_by_id(c_id)
@ -265,18 +265,19 @@ class RepositoriesController < ApplicationController
end
CSV.generate do |csv|
byebug
csv << csv_header
rows.each do |row|
csv_row = []
column_ids.each do |c_id|
csv_row << case c_id.to_i
when -1
when -1, -2
next
when -2
row.name
when -3
row.created_by.full_name
row.name
when -4
row.created_by.full_name
when -5
I18n.l(row.created_at, format: :full)
else
cell = row.repository_cells