mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This fixes #569
This commit is contained in:
parent
47aa996b6b
commit
cf2cd9680b
@ -439,8 +439,9 @@ class CsvSetup implements SetupInterface
|
|||||||
Log::debug('Now in getDataForColumnRoles()');
|
Log::debug('Now in getDataForColumnRoles()');
|
||||||
$config = $this->job->configuration;
|
$config = $this->job->configuration;
|
||||||
$data = [
|
$data = [
|
||||||
'columns' => [],
|
'columns' => [],
|
||||||
'columnCount' => 0,
|
'columnCount' => 0,
|
||||||
|
'columnHeaders' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
// show user column role configuration.
|
// show user column role configuration.
|
||||||
@ -449,8 +450,13 @@ class CsvSetup implements SetupInterface
|
|||||||
// create CSV reader.
|
// create CSV reader.
|
||||||
$reader = Reader::createFromString($content);
|
$reader = Reader::createFromString($content);
|
||||||
$reader->setDelimiter($config['delimiter']);
|
$reader->setDelimiter($config['delimiter']);
|
||||||
$start = $config['has-headers'] ? 1 : 0;
|
$start = $config['has-headers'] ? 1 : 0;
|
||||||
$end = $start + config('csv.example_rows');
|
$end = $start + config('csv.example_rows');
|
||||||
|
$header = [];
|
||||||
|
if ($config['has-headers']) {
|
||||||
|
$header = $reader->fetchOne(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// collect example data in $data['columns']
|
// collect example data in $data['columns']
|
||||||
Log::debug(sprintf('While %s is smaller than %d', $start, $end));
|
Log::debug(sprintf('While %s is smaller than %d', $start, $end));
|
||||||
@ -468,7 +474,8 @@ class CsvSetup implements SetupInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($row as $index => $value) {
|
foreach ($row as $index => $value) {
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
$data['columnHeaders'][$index] = $header[$index] ?? '';
|
||||||
if (strlen($value) > 0) {
|
if (strlen($value) > 0) {
|
||||||
$data['columns'][$index][] = $value;
|
$data['columns'][$index][] = $value;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,13 @@
|
|||||||
{% for i in 0..(data.columnCount-1) %}
|
{% for i in 0..(data.columnCount-1) %}
|
||||||
|
|
||||||
<tr>
|
<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>
|
<td>
|
||||||
{% if data.columns[i]|length == 0 %}
|
{% if data.columns[i]|length == 0 %}
|
||||||
<em>{{ trans('csv.no_example_data') }}</em>
|
<em>{{ trans('csv.no_example_data') }}</em>
|
||||||
|
Loading…
Reference in New Issue
Block a user