This commit is contained in:
James Cole 2017-02-15 15:18:52 +01:00
parent 47aa996b6b
commit cf2cd9680b
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 19 additions and 6 deletions

View File

@ -439,8 +439,9 @@ class CsvSetup implements SetupInterface
Log::debug('Now in getDataForColumnRoles()');
$config = $this->job->configuration;
$data = [
'columns' => [],
'columnCount' => 0,
'columns' => [],
'columnCount' => 0,
'columnHeaders' => [],
];
// show user column role configuration.
@ -449,8 +450,13 @@ class CsvSetup implements SetupInterface
// create CSV reader.
$reader = Reader::createFromString($content);
$reader->setDelimiter($config['delimiter']);
$start = $config['has-headers'] ? 1 : 0;
$end = $start + config('csv.example_rows');
$start = $config['has-headers'] ? 1 : 0;
$end = $start + config('csv.example_rows');
$header = [];
if ($config['has-headers']) {
$header = $reader->fetchOne(0);
}
// collect example data in $data['columns']
Log::debug(sprintf('While %s is smaller than %d', $start, $end));
@ -468,7 +474,8 @@ class CsvSetup implements SetupInterface
}
foreach ($row as $index => $value) {
$value = trim($value);
$value = trim($value);
$data['columnHeaders'][$index] = $header[$index] ?? '';
if (strlen($value) > 0) {
$data['columns'][$index][] = $value;
}

View File

@ -45,7 +45,13 @@
{% for i in 0..(data.columnCount-1) %}
<tr>
<td>{{ trans('csv.column') }} #{{ loop.index }}</td>
<td>
{% if data.columnHeaders[i] == '' %}
{{ trans('csv.column') }} #{{ loop.index }}
{% else %}
{{ data.columnHeaders[i] }}
{% endif %}
</td>
<td>
{% if data.columns[i]|length == 0 %}
<em>{{ trans('csv.no_example_data') }}</em>