From 13b5fc65921f5c030a64a3c6f2faf4c822bc14a4 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 1 Mar 2011 14:33:14 +0100 Subject: [PATCH] Statusausgabe verbessert --- SL/Controller/CsvImport.pm | 3 ++- SL/Controller/CsvImport/CustomerVendor.pm | 6 +++--- locale/de/all | 7 ++++--- templates/webpages/csv_import/_data.html | 11 ----------- templates/webpages/csv_import/_preview.html | 2 -- templates/webpages/csv_import/_result.html | 6 +++++- templates/webpages/csv_import/form.html | 9 +++++++-- 7 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 templates/webpages/csv_import/_data.html diff --git a/SL/Controller/CsvImport.pm b/SL/Controller/CsvImport.pm index 37d801a7e..806429d7d 100644 --- a/SL/Controller/CsvImport.pm +++ b/SL/Controller/CsvImport.pm @@ -15,7 +15,7 @@ use parent qw(SL::Controller::Base); use Rose::Object::MakeMethods::Generic ( scalar => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen - import_status errors headers data num_imported) ], + import_status errors headers data num_imported num_importable) ], ); __PACKAGE__->run_before('check_auth'); @@ -147,6 +147,7 @@ sub test_and_import { $worker->run; $worker->save_objects if !$params{test}; + $self->num_importable(scalar grep { !$_ } map { scalar @{ $_->{errors} } } @{ $self->data }); $self->import_status($params{test} ? 'tested' : 'imported'); $self->action_new; diff --git a/SL/Controller/CsvImport/CustomerVendor.pm b/SL/Controller/CsvImport/CustomerVendor.pm index 5fe15af6e..1fb29cc29 100644 --- a/SL/Controller/CsvImport/CustomerVendor.pm +++ b/SL/Controller/CsvImport/CustomerVendor.pm @@ -52,7 +52,7 @@ sub check_duplicates { my %by_name; if ('check_db' eq $self->controller->profile->get('duplicates')) { - %by_name = map { ( $normalizer->($_->name) => 1 ) } @{ $self->existing_objects }; + %by_name = map { ( $normalizer->($_->name) => 'db' ) } @{ $self->existing_objects }; } foreach my $entry (@{ $self->controller->data }) { @@ -60,10 +60,10 @@ sub check_duplicates { my $name = $normalizer->($entry->{object}->name); if (!$by_name{$name}) { - $by_name{$name} = 1; + $by_name{$name} = 'csv'; } else { - push @{ $entry->{errors} }, $::locale->text('Duplicate'); + push @{ $entry->{errors} }, $by_name{$name} eq 'db' ? $::locale->text('Duplicate in database') : $::locale->text('Duplicate in CSV file'); } } } diff --git a/locale/de/all b/locale/de/all index ae6e118ad..547526a9b 100644 --- a/locale/de/all +++ b/locale/de/all @@ -13,7 +13,7 @@ $self->{texts} = { ' Date missing!' => ' Datum fehlt!', ' Part Number missing!' => ' Artikelnummer fehlt!', ' missing!' => ' fehlt!', - '#1 objects were imported.' => '#1 Objekte wurden importiert.', + '#1 of #2 importable objects were imported.' => '#1 von #2 importierbaren Objekten wurden importiert.', '#1 prices were updated.' => '#1 Preise wurden aktualisiert.', '*/' => '*/', '---please select---' => '---bitte auswählen---', @@ -623,7 +623,8 @@ $self->{texts} = { 'Dunning number' => 'Mahnungsnummer', 'Dunning overview' => 'Mahnungsübersicht', 'Dunnings' => 'Mahnungen', - 'Duplicate' => 'Duplikat', + 'Duplicate in CSV file' => 'Duplikat in CSV-Datei', + 'Duplicate in database' => 'Duplikat in Datenbank', 'During this user migration Lx-Office can create such a group for you and grant all users access to all of Lx-Office\'s functions.' => 'Im Rahmen dieser Benutzerdatenmigration kann Lx-Office eine solche Gruppe für Sie anlegen und allen Benutzern Zugriff auf alle Lx-Office-Funktionen gewähren.', 'E-mail' => 'eMail', 'E-mail Statement to' => 'Fälligkeitsabrechnung als eMail an', @@ -807,7 +808,7 @@ $self->{texts} = { 'Form details (second row)' => 'Formulardetails (zweite Positionszeile)', 'Formula' => 'Formel', 'Found #1 errors.' => '#1 Fehler gefunden.', - 'Found #1 objects to import.' => '#1 zu importierende Objekte gefunden.', + 'Found #1 objects of which #2 can be imported.' => 'Es wurden #1 Objekte gefunden, von denen #2 importiert werden können.', 'Free report period' => 'Freier Zeitraum', 'Free-form text' => 'Textzeile', 'Fristsetzung' => 'Fristsetzung', diff --git a/templates/webpages/csv_import/_data.html b/templates/webpages/csv_import/_data.html deleted file mode 100644 index 79fb6ccac..000000000 --- a/templates/webpages/csv_import/_data.html +++ /dev/null @@ -1,11 +0,0 @@ -[% USE LxERP %] - -[%- IF SELF.errors %] - [%- PROCESS 'csv_import/_errors.html' %] -[%- END %] - -[%- IF SELF.import_status == 'imported' %] - [%- PROCESS 'csv_import/_result.html' %] -[%- END %] - -[%- PROCESS 'csv_import/_preview.html' %] diff --git a/templates/webpages/csv_import/_preview.html b/templates/webpages/csv_import/_preview.html index 323fdb483..ee166995f 100644 --- a/templates/webpages/csv_import/_preview.html +++ b/templates/webpages/csv_import/_preview.html @@ -9,8 +9,6 @@ [%- END %] -

[%- LxERP.t8('Found #1 objects to import.', SELF.data.size || 0) %]

- [% IF SELF.data.size %] diff --git a/templates/webpages/csv_import/_result.html b/templates/webpages/csv_import/_result.html index bc0daae11..b67bb7fbc 100644 --- a/templates/webpages/csv_import/_result.html +++ b/templates/webpages/csv_import/_result.html @@ -2,4 +2,8 @@

[%- LxERP.t8('Import summary') %]

-

[%- LxERP.t8('#1 objects were imported.', SELF.data.size || 0) %]

+[%- IF SELF.import_status == 'imported' %] +

[%- LxERP.t8('#1 of #2 importable objects were imported.', SELF.num_imported, SELF.num_importable || 0) %]

+[%- ELSE %] +

[%- LxERP.t8('Found #1 objects of which #2 can be imported.', SELF.data.size || 0, SELF.num_importable || 0) %]

+[%- END %] diff --git a/templates/webpages/csv_import/form.html b/templates/webpages/csv_import/form.html index bc23d54c2..fe17423c0 100644 --- a/templates/webpages/csv_import/form.html +++ b/templates/webpages/csv_import/form.html @@ -140,14 +140,19 @@
[% L.submit_tag('action_test', LxERP.t8('Test and preview')) %] - [% IF SELF.import_status && SELF.data.size %] + [% IF SELF.import_status && SELF.num_importable %] [% L.submit_tag('action_import', LxERP.t8('Import')) %] [%- END %] [%- IF SELF.import_status %] - [%- PROCESS 'csv_import/_data.html' %] + [%- IF SELF.errors %] + [%- PROCESS 'csv_import/_errors.html' %] + [%- END %] + + [%- PROCESS 'csv_import/_result.html' %] + [%- PROCESS 'csv_import/_preview.html' %] [%- END %]