X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d3b2be265715bdde58118795f2fb870bafa7edd9..3bed12835acd27f26ff501eb46cd741135cf24f8:/SL/Controller/Part.pm diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index eb1d52b64..9666296aa 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 { @@ -501,22 +500,19 @@ sub action_ajax_autocomplete { # if someone types something, and hits enter, assume he entered the full name. # if something matches, treat that as sole match - # unfortunately get_models can't do more than one per package atm, so we d it - # the oldfashioned way. + # since we need a second get models instance with different filters for that, + # we only modify the original filter temporarily in place if ($::form->{prefer_exact}) { + local $::form->{filter}{'all::ilike'} = delete local $::form->{filter}{'all:substr:multi::ilike'}; + + my $exact_models = SL::Controller::Helper::GetModels->new( + controller => $self, + sorted => 0, + paginated => { per_page => 2 }, + with_objects => [ qw(unit_obj classification) ], + ); my $exact_matches; - if (1 == scalar @{ $exact_matches = SL::DB::Manager::Part->get_all( - query => [ - obsolete => 0, - SL::DB::Manager::Part->type_filter($::form->{filter}{part_type}), - SL::DB::Manager::PartClassification->classification_filter($::form->{filter}{classification_id}), - or => [ - description => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, - partnumber => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, - ] - ], - limit => 2, - ) }) { + if (1 == scalar @{ $exact_matches = $exact_models->get }) { $self->parts($exact_matches); } } @@ -542,11 +538,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 { @@ -617,7 +613,7 @@ sub add { sub _set_javascript { my ($self) = @_; - $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery); + $::request->layout->use_javascript("${_}.js") for qw(kivi.Part kivi.File kivi.PriceRule ckeditor/ckeditor ckeditor/adapters/jquery); $::request->layout->add_javascripts_inline("\$(function(){kivi.PriceRule.load_price_rules_for_part(@{[ $self->part->id ]})});") if $self->part->id; }