1 package SL::Controller::TopQuickSearch::Article;
4 use parent qw(Rose::Object);
6 use SL::Locale::String qw(t8);
8 use SL::Controller::Helper::GetModels;
9 use SL::Controller::Base;
11 use Rose::Object::MakeMethods::Generic (
12 'scalar --get_set_init' => [ qw(parts models part) ],
15 sub auth { 'part_service_assembly_edit' }
17 sub name { 'article' }
19 sub description_config { t8('Articles') }
21 sub description_field { t8('Articles') }
23 sub query_autocomplete {
26 my $objects = $self->models->get;
30 value => $_->displayable_name,
31 label => $_->displayable_name,
37 sub select_autocomplete {
39 $self->redirect_to_part($::form->{id});
45 my $objects = $self->models->get;
47 return !@$objects ? ()
48 : @$objects == 1 ? $self->redirect_to_part($objects->[0]->id)
49 : $self->redirect_to_search($::form->{term});
52 sub redirect_to_search {
53 my ($self, $term) = @_;
55 SL::Controller::Base->new->url_for(
56 controller => 'ic.pl',
57 action => 'generate_report',
59 (searchitems => $self->part_type) x!!$self->part_type,
63 sub redirect_to_part {
64 my ($self, $term) = @_;
66 SL::Controller::Base->new->url_for(
67 controller => 'controller.pl',
68 action => 'Part/edit',
80 SL::Controller::Helper::GetModels->new(
85 (part_type => $self->part_type) x!!$self->part_type,
86 or => [ obsolete => undef, obsolete => 0 ],
87 'all:substr:multi::ilike' => $::form->{term},
95 partnumber => t8('Partnumber'),