X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/ea1df49dd6040f9b904759faa7f461fff3d95d7c..9eb765a5e78cea60962849c8bf0879da85adeff1:/SL/Controller/Order.pm diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 78e9e5436..b11e364b9 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -594,6 +594,43 @@ sub action_get_item_longdescription { $_[0]->render(\ $longdescription, { type => 'text' }); } +# load the second row for one or more items (cvars only for now) +# +# 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) = @_; + + 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(); +} + +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_' . $item_id . ') [name = "second_row"]', $row_as_html) + ->data('.row_entry:has(#item_' . $item_id . ') [name = "second_row"]', 'loaded', 1); +} + sub _js_redisplay_linetotals { my ($self) = @_; @@ -1289,15 +1326,6 @@ should be implemented. C does not use the currently inserted string for filtering. -=item * Performance - -Rendering a 50 items order takes twice as long as the old code. - -90% of that is rendering the (hidden) second rows, and 50% of those again are -checks for is_valid and C on the cvar input template. - -Suggestion: fetch second rows when asked for. - =back =head1 AUTHOR