From 83381f25d171ab6b6a085d1f82851c8e31c1527f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 14 Jan 2014 13:55:48 +0100 Subject: [PATCH] Artikelstammdaten: Spracheinstellungen rein in eigenem Tab bearbeiten MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Der alte Mechanismus öffnete ein normales Popup-Fenster, in dem eine URL geladen wurde, die dann die Maske angezeigt hat. Das Zurückschreiben geschah schon via JavaScript. Mit der Methode gibt's zwei Probleme: 1. Es ist langsam, weil ein überflüssiger Roundtrip zum Server gemacht wird. Die Informationen sind bereits alle beim initialen Anzeigen der Maske vorhanden. 2. Es handelt sich um einen GET-Request, an den sämtliche Übersetzungen als GET-Parameter angehängt werden. Damit kann man problemlos in die Größenbeschränkung bei GET-Requests laufen. --- SL/IC.pm | 26 +++---- bin/mozilla/ic.pl | 46 +------------ js/parts_language_selection.js | 12 ---- locale/de/all | 4 +- templates/webpages/client_config/form.html | 1 - .../webpages/common/select_warehouse_bin.html | 1 - .../webpages/dbupgrade/default_bin_parts.html | 1 - templates/webpages/ic/form_footer.html | 4 ++ templates/webpages/ic/form_header.html | 12 ++-- .../webpages/ic/parts_language_selection.html | 67 ------------------- .../webpages/ic/tabs/_edit_translations.html | 22 ++++++ 11 files changed, 44 insertions(+), 152 deletions(-) delete mode 100644 js/parts_language_selection.js delete mode 100644 templates/webpages/ic/parts_language_selection.html create mode 100644 templates/webpages/ic/tabs/_edit_translations.html diff --git a/SL/IC.pm b/SL/IC.pm index ff8484b7e..d37f66f90 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -146,15 +146,10 @@ SQL } # get translations - $form->{language_values} = ""; $query = qq|SELECT language_id, translation, longdescription FROM translation WHERE parts_id = ?|; - my $trq = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); - while (my $tr = $trq->fetchrow_hashref("NAME_lc")) { - $form->{language_values} .= "---+++---" . join('--++--', @{$tr}{qw(language_id translation longdescription)}); - } - $trq->finish; + $form->{translations} = selectall_hashref_query($form, $dbh, $query, conv_i($form->{id})); # is it an orphan my @referencing_tables = qw(invoice orderitems inventory); @@ -401,16 +396,17 @@ sub save { # delete translation records do_query($form, $dbh, qq|DELETE FROM translation WHERE parts_id = ?|, conv_i($form->{id})); - if ($form->{language_values} ne "") { - foreach my $item (split(/---\+\+\+---/, $form->{language_values})) { - my ($language_id, $translation, $longdescription) = split(/--\+\+--/, $item); - if ($translation ne "") { - $query = qq|INSERT into translation (parts_id, language_id, translation, longdescription) - VALUES ( ?, ?, ?, ? )|; - @values = (conv_i($form->{id}), conv_i($language_id), $translation, $longdescription); - do_query($form, $dbh, $query, @values); - } + my @translations = grep { $_->{language_id} && $_->{translation} } @{ $form->{translations} || [] }; + if (@translations) { + $query = qq|INSERT into translation (parts_id, language_id, translation, longdescription) + VALUES ( ?, ?, ?, ? )|; + $sth = $dbh->prepare($query); + + foreach my $translation (@translations) { + do_statement($form, $sth, $query, conv_i($form->{id}), conv_i($translation->{language_id}), $translation->{translation}, $translation->{longdescription}); } + + $sth->finish(); } # delete price records diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index f986715eb..473467b4e 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1608,6 +1608,8 @@ sub form_header { $form->{bin_id} ||= $default_bin_id || $form->{WAREHOUSES}->[$max -1]->{BINS}->[0]->{id}; } + $form->{LANGUAGES} = SL::DB::Manager::Language->get_all_sorted; + $form->{translations_map} = { map { ($_->{language_id} => $_) } @{ $form->{translations} || [] } }; IC->retrieve_buchungsgruppen(\%myconfig, $form); @{ $form->{BUCHUNGSGRUPPEN} } = grep { $_->{id} eq $form->{buchungsgruppen_id} || ($form->{id} && $form->{orphaned}) || !$form->{id} } @{ $form->{BUCHUNGSGRUPPEN} }; @@ -2063,50 +2065,6 @@ sub price_row { $lxdebug->leave_sub(); } -sub parts_language_selection { - $lxdebug->enter_sub(); - - $auth->assert('part_service_assembly_edit'); - - my $languages = IC->retrieve_languages(\%myconfig, $form); - - if ($form->{language_values} ne "") { - foreach my $item (split(/---\+\+\+---/, $form->{language_values})) { - my ($language_id, $translation, $longdescription) = split(/--\+\+--/, $item); - - foreach my $language (@{ $languages }) { - next unless ($language->{id} == $language_id); - - $language->{translation} = $translation; - $language->{longdescription} = $longdescription; - - $language->{translation_area} = ($language->{translation_rows} = $form->numtextrows($language->{translation}, 40)) > 1; - $language->{longdescription_rows} = max 4, $form->numtextrows($language->{longdescription}, 40); - - last; - } - } - } - - my @header_sort = qw(name longdescription); - my %header_title = ( "name" => $locale->text("Name"), - "longdescription" => $locale->text("Long Description"), - ); - - my @header = - map(+{ "column_title" => $header_title{$_}, - "column" => $_, - }, - @header_sort); - - $form->{"title"} = $locale->text("Language Values"); - $form->header(); - print $form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header, - "LANGUAGES" => $languages, }); - - $lxdebug->leave_sub(); -} - sub ajax_autocomplete { $main::lxdebug->enter_sub(); diff --git a/js/parts_language_selection.js b/js/parts_language_selection.js deleted file mode 100644 index a0607165f..000000000 --- a/js/parts_language_selection.js +++ /dev/null @@ -1,12 +0,0 @@ -function parts_language_selection_window(input_name) { - var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; - var name = document.getElementsByName(input_name)[0].value; - url = "ic.pl?" + - "INPUT_ENCODING=UTF-8&" + - "action=parts_language_selection&" + - "id=" + encodeURIComponent(document.ic.id.value) + "&" + - "language_values=" + encodeURIComponent(document.ic.language_values.value) + "&" + - "name=" + encodeURIComponent(name) + "&" + - "input_name=" + encodeURIComponent(input_name) + "&" - window.open(url, "_new_generic", parm); -} diff --git a/locale/de/all b/locale/de/all index 98d6920ed..3d1d60090 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1210,7 +1210,6 @@ $self->{texts} = { 'Language' => 'Sprache', 'Language (database ID)' => 'Sprache (Datenbank-ID)', 'Language (name)' => 'Sprache (Name)', - 'Language Values' => 'Sprachübersetzungen', 'Language deleted!' => 'Sprache gelöscht!', 'Language missing!' => 'Sprache fehlt!', 'Language saved!' => 'Sprache gespeichert!', @@ -1589,7 +1588,6 @@ $self->{texts} = { 'Please enter the taxnumber in the client configuration.' => 'Bitte geben Sie in der Mandantenkonfiguration die Steuernummer an.', 'Please enter values' => 'Bitte Werte eingeben', 'Please insert object dimensions below.' => 'Bitte geben Sie die Abmessungen unten ein', - 'Please insert your language values below' => 'Bitte die Übersetzungen unten eintragen', 'Please insert your longdescription below' => 'Bitte den Langtext eingeben', 'Please install the below listed modules or ask your system administrator to.' => 'Bitte installieren Sie die unten aufgeführten Module, oder bitten Sie Ihren Administrator darum.', 'Please log in to the administration panel.' => 'Bitte melden Sie sich im Administrationsbereich an.', @@ -1887,7 +1885,6 @@ $self->{texts} = { 'Service Number missing!' => 'Dienstleistungsnummer fehlt!', 'Service, assembly or part' => 'Dienstleistung, Erzeugnis oder Ware', 'Services' => 'Dienstleistungen', - 'Set Language Values' => 'Spracheinstellungen', 'Set eMail text' => 'E-Mail Text eingeben', 'Settings' => 'Einstellungen', 'Setup Menu' => 'Menü-Variante', @@ -2386,6 +2383,7 @@ $self->{texts} = { 'Transfer qty' => 'Umlagermenge', 'Transfer successful' => 'Lagervorgang erfolgreich', 'Translation' => 'Übersetzung', + 'Translations' => 'Übersetzungen', 'Trial Balance' => 'Summen- und Saldenliste', 'Trial balance between %s and %s' => 'Summen- und Saldenlisten vom %s bis zum %s', 'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.', diff --git a/templates/webpages/client_config/form.html b/templates/webpages/client_config/form.html index 58d2789a0..0f85512b3 100644 --- a/templates/webpages/client_config/form.html +++ b/templates/webpages/client_config/form.html @@ -1,6 +1,5 @@ [%- USE L %][% USE LxERP %][% USE HTML %][%- USE JavaScript -%] - - diff --git a/templates/webpages/ic/tabs/_edit_translations.html b/templates/webpages/ic/tabs/_edit_translations.html new file mode 100644 index 000000000..61884bf2f --- /dev/null +++ b/templates/webpages/ic/tabs/_edit_translations.html @@ -0,0 +1,22 @@ +[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%] + +
+ + + + + + + + [%- FOREACH language = LANGUAGES %] + [% SET language_id = language.id + translation = translations_map.$language_id %] + [% L.hidden_tag('translations[+].language_id', language.id) %] + + + + + + [%- END %] +
[% LxERP.t8("Language") %][% LxERP.t8("Description") %][% LxERP.t8("Long Description") %]
[% HTML.escape(language.description) %][% L.input_tag("translations[].translation", translation.translation) %][% L.textarea_tag("translations[].longdescription", translation.longdescription, id="translations_longdescription_" _ language_id, style="width: 500px; height: 100px") %]
+
-- 2.20.1