From 9eb765a5e78cea60962849c8bf0879da85adeff1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 2 Nov 2016 16:45:44 +0100 Subject: [PATCH] Auftrags-Controller: zweite Zeile laden mit Icons und alle zweiten Zeilen laden. --- SL/Controller/Order.pm | 43 +++++---- image/collapse3.gif | Bin 0 -> 64 bytes js/kivi.Order.js | 90 +++++++++++++++++- js/locale/de.js | 4 + locale/de/all | 2 + locale/en/all | 2 + templates/webpages/order/tabs/_row.html | 23 ++++- templates/webpages/order/tabs/basic_data.html | 8 +- 8 files changed, 145 insertions(+), 27 deletions(-) create mode 100644 image/collapse3.gif diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 144a195d2..b11e364b9 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -594,30 +594,41 @@ sub action_get_item_longdescription { $_[0]->render(\ $longdescription, { type => 'text' }); } -# load the second row for an item (cvars only for now) +# load the second row for one or more items (cvars only for now) # -# This action gets the html code for the items second row by rendering a template for -# the second row and calls a javascript function with this html code via client js. -sub action_load_second_row { +# This action gets the html code for all items second rows by rendering a template for +# the second row and sets the html code via client js. +sub action_load_second_rows { my ($self) = @_; - my $idx = first_index { $_ eq $::form->{item_id} } @{ $::form->{orderitem_ids} }; - my $item = $self->order->items_sorted->[$idx]; + foreach my $item_id (@{ $::form->{item_ids} }) { + my $idx = first_index { $_ eq $item_id } @{ $::form->{orderitem_ids} }; + my $item = $self->order->items_sorted->[$idx]; + + $self->_js_load_second_row($item, $item_id, 0); + } + + $self->js->render(); +} - # Parse values from form (they are formated while rendering (template)). - # Workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values). - # This parsing is not necessary at all, if we assure that the second row/cvars are only loaded once. - #foreach my $var (@{ $item->cvars_by_config }) { - # $var->unparsed_value($::form->parse_amount(\%::myconfig, $var->{__unparsed_value})) if ($var->config->type eq 'number' && exists($var->{__unparsed_value})); - #} - #$item->parse_custom_variable_values; +sub _js_load_second_row { + my ($self, $item, $item_id, $do_parse) = @_; + + if ($do_parse) { + # Parse values from form (they are formated while rendering (template)). + # Workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values). + # This parsing is not necessary at all, if we assure that the second row/cvars are only loaded once. + foreach my $var (@{ $item->cvars_by_config }) { + $var->unparsed_value($::form->parse_amount(\%::myconfig, $var->{__unparsed_value})) if ($var->config->type eq 'number' && exists($var->{__unparsed_value})); + } + $item->parse_custom_variable_values; + } my $row_as_html = $self->p->render('order/tabs/_second_row', ITEM => $item); $self->js - ->html('.row_entry:has(#item_' . $::form->{item_id} . ') [name = "second_row"]', $row_as_html) - ->data('.row_entry:has(#item_' . $::form->{item_id} . ') [name = "second_row"]', 'loaded', 1) - ->render(); + ->html('.row_entry:has(#item_' . $item_id . ') [name = "second_row"]', $row_as_html) + ->data('.row_entry:has(#item_' . $item_id . ') [name = "second_row"]', 'loaded', 1); } sub _js_redisplay_linetotals { diff --git a/image/collapse3.gif b/image/collapse3.gif new file mode 100644 index 0000000000000000000000000000000000000000..9a89b2483047b4c8afa5c8afed90068019710b2a GIT binary patch literal 64 zcmZ?wbhEHb{texts} = { 'Here you only provide the credentials for logging into the database.' => 'Hier geben Sie nur die Logindaten für die Anmeldung an der Datenbank ein.', 'Here\'s an example command line:' => 'Hier ist eine Kommandozeile, die als Beispiel dient:', 'Hide Filter' => 'Filter verbergen', + 'Hide all details' => 'Alle Details verbergen', 'Hide by default' => 'Standardmäßig verstecken', 'Hide chart details' => 'Konteninformation verstecken', 'Hide details' => 'Details verbergen', @@ -2593,6 +2594,7 @@ $self->{texts} = { 'Show TODO list' => 'Aufgabenliste anzeigen', 'Show Transfer via default' => 'Ein- / Auslagern über Standardlagerplatz anzeigen (zusätzlicher Knopf in Beleg Lieferschein)', 'Show administration link' => 'Link zur Administration anzeigen', + 'Show all details' => 'Alle Details anzeigen', 'Show all parts' => 'Alle Artikel anzeigen', 'Show by default' => 'Standardmäßig anzeigen', 'Show custom variable search inputs' => 'Suchoptionen für Benutzerdefinierte Variablen verstecken', diff --git a/locale/en/all b/locale/en/all index e3269a1a1..bc30d2116 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1415,6 +1415,7 @@ $self->{texts} = { 'Here you only provide the credentials for logging into the database.' => '', 'Here\'s an example command line:' => '', 'Hide Filter' => '', + 'Hide all details' => '', 'Hide by default' => '', 'Hide chart details' => '', 'Hide details' => '', @@ -2584,6 +2585,7 @@ $self->{texts} = { 'Show TODO list' => '', 'Show Transfer via default' => '', 'Show administration link' => '', + 'Show all details' => '', 'Show all parts' => '', 'Show by default' => '', 'Show custom variable search inputs' => '', diff --git a/templates/webpages/order/tabs/_row.html b/templates/webpages/order/tabs/_row.html index 88888e9db..ce6e94fa2 100644 --- a/templates/webpages/order/tabs/_row.html +++ b/templates/webpages/order/tabs/_row.html @@ -6,7 +6,14 @@ - + + [%- IF MYCONFIG.show_form_details %] + [% L.img_tag(src="image/collapse3.gif", + alt=LxERP.t8('Hide details'), title=LxERP.t8('Hide details'), class="expand") %] + [%- ELSE %] + [% L.img_tag(src="image/expand3.gif", + alt=LxERP.t8('Show details'), title=LxERP.t8('Show details'), class="expand") %] + [%- END %] [% L.hidden_tag("orderitem_ids[+]", ID) %] [% L.hidden_tag("order.orderitems[+].id", ITEM.id, id='item_' _ ID) %] [% L.hidden_tag("order.orderitems[].parts_id", ITEM.parts_id) %] @@ -100,11 +107,17 @@ - + -
- [%- LxERP.t8("Loading...") %] -
+ [%- IF MYCONFIG.show_form_details %] +
+ [%- PROCESS order/tabs/_second_row.html ITEM=ITEM %] +
+ [%- ELSE %] +
+ [%- LxERP.t8("Loading...") %] +
+ [%- END %] diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index 61348b7b8..fe0a27f10 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -155,7 +155,13 @@ - + -- 2.20.1
+ [%- IF MYCONFIG.show_form_details %] + [%- L.img_tag(src="image/collapse3.gif", alt=LxERP.t8('Hide all details'), title=LxERP.t8('Hide all details'), id='expand_all') %] + [%- ELSE %] + [%- L.img_tag(src="image/expand3.gif", alt=LxERP.t8('Show all details'), title=LxERP.t8('Show all details'), id='expand_all') %] + [%- END %] + [%- 'position' | $T8 %] [%- LxERP.t8('reorder item') %] [%- LxERP.t8('delete item') %]