$_[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 {
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) {
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;
}
});
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) {
$('#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;
+ });
});
"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",
"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",
'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',
'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',
'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' => '',
'Show TODO list' => '',
'Show Transfer via default' => '',
'Show administration link' => '',
+ 'Show all details' => '',
'Show all parts' => '',
'Show by default' => '',
'Show custom variable search inputs' => '',
<tbody class="row_entry">
<tr class="listrow0">
- <td style='display:none'>
+ <td align="center">
+ [%- 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) %]
</tr>
- <tr class="listrow1" style="display:none">
+ <tr class="listrow1" [%- IF !MYCONFIG.show_form_details -%]style="display:none"[%- END -%]>
<td colspan="100%">
- <div name="second_row">
- [%- LxERP.t8("Loading...") %]
- </div>
+ [%- IF MYCONFIG.show_form_details %]
+ <div name="second_row" data-loaded="1">
+ [%- PROCESS order/tabs/_second_row.html ITEM=ITEM %]
+ </div>
+ [%- ELSE %]
+ <div name="second_row">
+ [%- LxERP.t8("Loading...") %]
+ </div>
+ [%- END %]
</td>
</tr>
<table id="row_table_id" width="100%">
<thead>
<tr class="listheading">
- <th class="listheading" style='display:none'></th>
+ <th class="listheading" style='text-align:center' nowrap width="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 %]
+ </th>
<th class="listheading" nowrap width="3" >[%- 'position' | $T8 %] </th>
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>