From: Bernd Bleßmann Date: Wed, 2 Nov 2016 15:45:44 +0000 (+0100) Subject: Auftrags-Controller: zweite Zeile laden mit Icons und alle zweiten Zeilen laden. X-Git-Tag: release-3.5.4~1829 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=9eb765a5e78cea60962849c8bf0879da85adeff1;p=kivitendo-erp.git Auftrags-Controller: zweite Zeile laden mit Icons und alle zweiten Zeilen laden. --- 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 000000000..9a89b2483 Binary files /dev/null and b/image/collapse3.gif differ diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 741526f86..538e26e4a 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -190,12 +190,58 @@ namespace('kivi.Order', function(ns) { return; } var data = $('#order_form').serializeArray(); - data.push({ name: 'action', value: 'Order/load_second_row' }); - data.push({ name: 'item_id', value: item_id_dom.val() }); + data.push({ name: 'action', value: 'Order/load_second_rows' }); + data.push({ name: 'item_ids[]', value: item_id_dom.val() }); $.post("controller.pl", data, kivi.eval_json_result); }; + ns.load_all_second_rows = function() { + var rows = $('.row_entry').filter(function(idx, elt) { + return $(elt).find('[name="second_row"]').data('loaded') != 1; + }); + + var item_ids = $.map(rows, function(elt) { + var item_id = $(elt).find('[name="orderitem_ids[+]"]').val(); + return { name: 'item_ids[]', value: item_id }; + }); + + if (item_ids.length == 0) { + return; + } + + var data = $('#order_form').serializeArray(); + data.push({ name: 'action', value: 'Order/load_second_rows' }); + data = data.concat(item_ids); + + $.post("controller.pl", data, kivi.eval_json_result); + }; + + ns.hide_second_row = function(row) { + $(row).children().not(':first').hide(); + $(row).data('expanded', false); + var elt = $(row).find('.expand'); + elt.attr('src', "image/expand3.gif"); + elt.attr('alt', kivi.t8('Show details')); + elt.attr('title', kivi.t8('Show details')); + }; + + ns.show_second_row = function(row) { + $(row).children().not(':first').show(); + $(row).data('expanded', true); + var elt = $(row).find('.expand'); + elt.attr('src', "image/collapse3.gif"); + elt.attr('alt', kivi.t8('Hide details')); + elt.attr('title', kivi.t8('Hide details')); + }; + + ns.toggle_second_row = function(row) { + if ($(row).data('expanded') === true) { + ns.hide_second_row(row); + } else { + ns.show_second_row(row); + } + }; ns.init_row_handlers = function() { kivi.run_once_for('.recalc', 'on_change_recalc', function(elt) { @@ -218,14 +264,14 @@ namespace('kivi.Order', function(ns) { event.preventDefault(); var row = $(event.target).parents(".row_entry").first(); ns.load_second_row(row); - $(row).children().not(':first').show(); + ns.show_second_row(row); return false; } if(event.keyCode == 38 && event.shiftKey === true) { // shift arrow up event.preventDefault(); var row = $(event.target).parents(".row_entry").first(); - $(row).children().not(':first').hide(); + ns.hide_second_row(row); return false; } }); @@ -233,10 +279,21 @@ namespace('kivi.Order', function(ns) { event.preventDefault(); var row = $(event.target).parents(".row_entry").first(); ns.load_second_row(row); - $(row).children().not(':first').toggle(); + ns.toggle_second_row(row); return false; }); }); + + kivi.run_once_for('.expand', 'expand_second_row', function(elt) { + $(elt).click(function(event) { + event.preventDefault(); + var row = $(event.target).parents(".row_entry").first(); + ns.load_second_row(row); + ns.toggle_second_row(row); + return false; + }) + }); + }; ns.redisplay_linetotals = function(data) { @@ -486,4 +543,27 @@ $(function(){ $('#row_table_id thead a img').remove(); kivi.Order.renumber_positions(); }); + + $('#expand_all').on('click', function(event) { + event.preventDefault(); + if ($('#expand_all').data('expanded') === true) { + $('#expand_all').data('expanded', false); + $('#expand_all').attr('src', 'image/expand3.gif'); + $('#expand_all').attr('alt', kivi.t8('Show all details')); + $('#expand_all').attr('title', kivi.t8('Show all details')); + $('.row_entry').each(function(idx, elt) { + kivi.Order.hide_second_row(elt); + }); + } else { + $('#expand_all').data('expanded', true); + $('#expand_all').attr('src', "image/collapse3.gif"); + $('#expand_all').attr('alt', kivi.t8('Hide all details')); + $('#expand_all').attr('title', kivi.t8('Hide all details')); + kivi.Order.load_all_second_rows(); + $('.row_entry').each(function(idx, elt) { + kivi.Order.show_second_row(elt); + }); + } + return false; + }); }); diff --git a/js/locale/de.js b/js/locale/de.js index 499b12f07..e69ca31a6 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -47,6 +47,8 @@ namespace("kivi").setupLocale({ "Edit text block":"Textblock bearbeiten", "Enter longdescription":"Langtext eingeben", "Function block actions":"Funktionsblockaktionen", +"Hide all details":"", +"Hide details":"Details verbergen", "History":"Historie", "If you switch to a different tab without saving you will lose the data you've entered in the current tab.":"Wenn Sie auf einen anderen Tab wechseln, ohne vorher zu speichern, so gehen die im aktuellen Tab eingegebenen Daten verloren.", "Map":"Karte", @@ -72,6 +74,8 @@ namespace("kivi").setupLocale({ "Save and keep open":"Speichern und geöffnet lassen", "Section/Function block actions":"Abschnitts-/Funktionsblockaktionen", "Select template to paste":"Einzufügende Vorlage auswählen", +"Show all details":"", +"Show details":"Details anzeigen", "Subject":"Betreff", "Text block actions":"Textblockaktionen", "Text block picture actions":"Aktionen für Textblockbilder", diff --git a/locale/de/all b/locale/de/all index f8c5dcd42..f842d6395 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1416,6 +1416,7 @@ $self->{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 @@ - +
+ [%- 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') %]