Skip to content

Firefly III: a personal finances manager

Fix some things in import routine.

James Cole6b59b6de6e82
diff --git a/app/Import/Configuration/FileConfigurator.php b/app/Import/Configuration/FileConfigurator.php
index 3876c802e3..43d2b63666 100644
--- a/app/Import/Configuration/FileConfigurator.php
+++ b/app/Import/Configuration/FileConfigurator.php
@@ -170,6 +170,7 @@ class FileConfigurator implements ConfiguratorInterface
'column-roles-complete' => false, // not yet configured roles for columns
'column-mapping-config' => [], // no mapping made yet.
'column-mapping-complete' => false, // so mapping is not complete.
+ 'has-config-file' => true,
'apply-rules' => true,
'match-bills' => false,
'auto-start' => false,
diff --git a/app/Support/Import/Configuration/File/Map.php b/app/Support/Import/Configuration/File/Map.php
index 6da53f669a..37cc0da306 100644
--- a/app/Support/Import/Configuration/File/Map.php
+++ b/app/Support/Import/Configuration/File/Map.php
@@ -106,6 +106,10 @@ class Map implements ConfigurationInterface
foreach ($setIndexes as $index) {
$this->data[$index]['values'] = array_unique($this->data[$index]['values']);
asort($this->data[$index]['values']);
+ // if the count of this array is zero, there is nothing to map.
+ if(count($this->data[$index]['values']) === 0) {
+ unset($this->data[$index]);
+ }
}
unset($setIndexes);
diff --git a/resources/lang/en_US/import.php b/resources/lang/en_US/import.php
index 16cdd4ed86..ef0316f7af 100644
--- a/resources/lang/en_US/import.php
+++ b/resources/lang/en_US/import.php
@@ -103,6 +103,7 @@ return [
'file_map_field_mapped_to' => 'Mapped to',
'map_do_not_map' => '(do not map)',
'file_map_submit' => 'Start the import',
+ 'file_nothing_to_map' => 'There is no data present in your file that you can map to existing values. Please press "Start the import" to continue.',
// map things.
'column__ignore' => '(ignore this column)',
diff --git a/resources/views/import/file/map.twig b/resources/views/import/file/map.twig
index 3a347f8905..5ae646b42c 100644
--- a/resources/views/import/file/map.twig
+++ b/resources/views/import/file/map.twig
@@ -17,6 +17,11 @@
<p>
{{ trans('import.file_map_text') }}
</p>
+ {% if data|length == 0 %}
+ <p class="text-danger">
+ {{ trans('import.file_nothing_to_map') }}
+ </p>
+ {% endif %}
</div>
</div>
@@ -25,6 +30,8 @@
<form action="{{ route('import.configure.post', job.key) }}" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
+
+
{% for field in data %}
<div class="row">
<div class="col-lg-12">