From 905d9eddfafc30dd4c53e892a6070035f28e6ce0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 10 Feb 2017 13:25:46 +0100 Subject: [PATCH] Part: multipicker verwenden --- SL/Controller/Part.pm | 15 +++++++-------- templates/webpages/part/_assembly.html | 7 ++++--- templates/webpages/part/_assortment.html | 7 ++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 12494dde2..fce0b6fb3 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -5,6 +5,7 @@ use parent qw(SL::Controller::Base); use Clone qw(clone); use SL::DB::Part; +use SL::DB::PartsGroup; use SL::Controller::Helper::GetModels; use SL::Locale::String qw(t8); use SL::JSON; @@ -260,7 +261,7 @@ sub action_add_multi_assortment_items { my $item_objects = $self->parse_add_items_to_objects(part_type => 'assortment'); my $html = $self->render_assortment_items_to_html($item_objects); - $self->js->run('kivi.Part.close_multi_items_dialog') + $self->js->run('kivi.Part.close_picker_dialogs') ->append('#assortment_rows', $html) ->run('kivi.Part.renumber_positions') ->run('kivi.Part.assortment_recalc') @@ -280,7 +281,7 @@ sub action_add_multi_assembly_items { my $html = $self->render_assembly_items_to_html(\@checked_objects); - $self->js->run('kivi.Part.close_multi_items_dialog') + $self->js->run('kivi.Part.close_picker_dialogs') ->append('#assembly_rows', $html) ->run('kivi.Part.renumber_positions') ->run('kivi.Part.assembly_recalc') @@ -370,11 +371,9 @@ sub action_add_assembly_item { } sub action_show_multi_items_dialog { - require SL::DB::PartsGroup; $_[0]->render('part/_multi_items_dialog', { layout => 0 }, - part_type => 'assortment', - partfilter => '', # can I get at the current input of the partpicker here? - all_partsgroups => SL::DB::Manager::PartsGroup->get_all); + all_partsgroups => SL::DB::Manager::PartsGroup->get_all + ); } sub action_multi_items_update_result { @@ -542,11 +541,11 @@ sub action_test_page { } sub action_part_picker_search { - $_[0]->render('part/part_picker_search', { layout => 0 }, parts => $_[0]->parts); + $_[0]->render('part/part_picker_search', { layout => 0 }); } sub action_part_picker_result { - $_[0]->render('part/_part_picker_result', { layout => 0 }); + $_[0]->render('part/_part_picker_result', { layout => 0 }, parts => $_[0]->parts); } sub action_show { diff --git a/templates/webpages/part/_assembly.html b/templates/webpages/part/_assembly.html index 2428a5135..b1acdd0df 100644 --- a/templates/webpages/part/_assembly.html +++ b/templates/webpages/part/_assembly.html @@ -41,17 +41,18 @@ [% 'Part' | $T8 %]: - [% L.part_picker('add_items[+].parts_id' , '' , style='width: 300px' , class="add_assembly_item_input") %][% L.hidden_tag('add_items[].qty_as_number', 1) %] + [% L.part_picker('add_items[+].parts_id', '', style='width: 300px', multiple=1, id='assembly_picker', action={set_multi_items='kivi.Part.set_multi_assembly_items', on_enter_match_one='kivi.Part.add_assembly_item'}) %] [%- L.button_tag("kivi.Part.add_assembly_item()", LxERP.t8("Add")) %] - [% L.button_tag('kivi.Part.show_multi_items_dialog("assembly",' _ SELF.part.id _ ')', LxERP.t8('Add multiple items')) %] + [% L.button_tag('$("#assembly_picker").data("part_picker").open_dialog()', LxERP.t8('Add multiple items')) %] + [% L.hidden_tag('add_items[].qty_as_number', 1) %] [% ELSE %] - [% END %] + [% END %] [% 'Totals' | $T8 %]: [%- LxERP.format_amount(items_sellprice_sum, 2, 0) %] diff --git a/templates/webpages/part/_assortment.html b/templates/webpages/part/_assortment.html index 866b147c2..934bdc459 100644 --- a/templates/webpages/part/_assortment.html +++ b/templates/webpages/part/_assortment.html @@ -40,16 +40,17 @@ [% 'Part' | $T8 %]: - [% L.part_picker('add_items[+].parts_id' , '' , style='width: 300px' , class="add_assortment_item_input") %][% L.hidden_tag('add_items[].qty_as_number', 1) %] + [% L.part_picker('add_items[+].parts_id', '', style='width: 300px', multiple=1, id='assortment_picker', action={set_multi_items='kivi.Part.set_multi_assortment_items'}) %] [%- L.button_tag("kivi.Part.add_assortment_item()", LxERP.t8("Add")) %] - [% L.button_tag('kivi.Part.show_multi_items_dialog("assortment",' _ SELF.part.id _ ')', LxERP.t8('Add multiple items')) %] - + [% L.button_tag('$("#assortment_picker").data("part_picker").open_dialog()', LxERP.t8('Add multiple items')) %] + [% L.hidden_tag('add_items[].qty_as_number', 1) %] [% ELSE %] + [% END %] [% 'Totals' | $T8 %]: -- 2.20.1