From: Sven Schöling Date: Wed, 18 Sep 2013 14:53:29 +0000 (+0200) Subject: PartPicker get_models X-Git-Tag: release-3.1.0beta1~44 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=fa7a37a2e2d294b1dfe6ef5b89e5acb0f8c4eb3b;p=kivitendo-erp.git PartPicker get_models --- diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 38b3b5502..97c0159cc 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -6,37 +6,16 @@ use parent qw(SL::Controller::Base); use Clone qw(clone); use SL::DB::Part; use SL::Controller::Helper::GetModels; -use SL::Controller::Helper::Filtered; -use SL::Controller::Helper::Sorted; -use SL::Controller::Helper::Paginated; -use SL::Controller::Helper::Filtered; use SL::Locale::String qw(t8); use SL::JSON; use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(parts) ], + 'scalar --get_set_init' => [ qw(parts models) ], ); # safety __PACKAGE__->run_before(sub { $::auth->assert('part_service_assembly_edit') }); -__PACKAGE__->make_filtered( - ONLY => [ qw(part_picker_search part_picker_result ajax_autocomplete) ], - LAUNDER_TO => 'filter', -); -__PACKAGE__->make_paginated( - ONLY => [ qw(part_picker_search part_picker_result ajax_autocomplete) ], -); - -__PACKAGE__->make_sorted( - ONLY => [ qw(part_picker_search part_picker_result ajax_autocomplete) ], - - DEFAULT_BY => 'partnumber', - DEFAULT_DIR => 1, - - partnumber => t8('Partnumber'), -); - sub action_ajax_autocomplete { my ($self, %params) = @_; @@ -92,7 +71,23 @@ sub action_part_picker_result { } sub init_parts { - $_[0]->get_models(with_objects => [ qw(unit_obj) ]); + $_[0]->models->get (with_objects => [ qw(unit_obj) ]); +} + +sub init_models { + my ($self) = @_; + + SL::Controller::Helper::GetModels->new( + controller => $self, + model => 'Part', + sorted => { + _default => { + by => 'partnumber', + dir => 1, + }, + partnumber => t8('Partnumber'), + } + ); } 1; diff --git a/templates/webpages/part/_part_picker_result.html b/templates/webpages/part/_part_picker_result.html index 6b848f3b4..eba16dcd8 100644 --- a/templates/webpages/part/_part_picker_result.html +++ b/templates/webpages/part/_part_picker_result.html @@ -23,7 +23,7 @@
-[% L.paginate_controls(target='#part_picker_result', selector='#part_picker_result') %] +[% L.paginate_controls(target='#part_picker_result', selector='#part_picker_result', models=SELF.models) %]