From 0c73b206cea0c8f057852e75bd4ee22c19bfdbc3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 19 Jul 2019 14:20:38 +0200 Subject: [PATCH] =?utf8?q?PartPicker=20nach=20Kunden-=20und=20Lieferanten-?= =?utf8?q?Artikel-Nr.=20suchen=20und=20filtern=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Part.pm | 21 ++++++++++++++++--- SL/Presenter/Part.pm | 4 ++++ js/kivi.Part.js | 10 ++++++++- .../webpages/part/_multi_items_dialog.html | 2 +- .../webpages/part/part_picker_search.html | 2 +- templates/webpages/part/test_page.html | 13 ++++++++++-- 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 2b5ac56c5..6092f2962 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -399,8 +399,15 @@ sub action_add_assembly_item { } sub action_show_multi_items_dialog { + my ($self) = @_; + + my $search_term = $self->models->filtered->laundered->{all_substr_multi__ilike}; + $search_term ||= $self->models->filtered->laundered->{all_with_makemodel_substr_multi__ilike}; + $search_term ||= $self->models->filtered->laundered->{all_with_customer_partnumber_substr_multi__ilike}; + $_[0]->render('part/_multi_items_dialog', { layout => 0 }, - all_partsgroups => SL::DB::Manager::PartsGroup->get_all + all_partsgroups => SL::DB::Manager::PartsGroup->get_all, + search_term => $search_term ); } @@ -562,7 +569,9 @@ sub action_ajax_autocomplete { # 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'}; + local $::form->{filter}{'all::ilike'} = delete local $::form->{filter}{'all:substr:multi::ilike'}; + local $::form->{filter}{'all_with_makemodel::ilike'} = delete local $::form->{filter}{'all_with_makemodel:substr:multi::ilike'}; + local $::form->{filter}{'all_with_customer_partnumber::ilike'} = delete local $::form->{filter}{'all_with_customer_partnumber:substr:multi::ilike'}; my $exact_models = SL::Controller::Helper::GetModels->new( controller => $self, @@ -598,7 +607,13 @@ sub action_test_page { } sub action_part_picker_search { - $_[0]->render('part/part_picker_search', { layout => 0 }); + my ($self) = @_; + + my $search_term = $self->models->filtered->laundered->{all_substr_multi__ilike}; + $search_term ||= $self->models->filtered->laundered->{all_with_makemodel_substr_multi__ilike}; + $search_term ||= $self->models->filtered->laundered->{all_with_customer_partnumber_substr_multi__ilike}; + + $_[0]->render('part/part_picker_search', { layout => 0 }, search_term => $search_term); } sub action_part_picker_result { diff --git a/SL/Presenter/Part.pm b/SL/Presenter/Part.pm index 145d9128f..bc5ee8ade 100644 --- a/SL/Presenter/Part.pm +++ b/SL/Presenter/Part.pm @@ -241,6 +241,10 @@ C. If C<%params> contains C only parts with a unit that's convertible to unit will be used for autocompletion. +If C<%params> contains C or C even +parts will be used for autocompletion which partnumber is a vendor partnumber +(makemodel) or a customer partnumber. + Obsolete parts will by default not be displayed for selection. However they are accepted as default values and can persist during updates. As with other selectors though, they are not selectable once overridden. diff --git a/js/kivi.Part.js b/js/kivi.Part.js index e8a721d29..4f813bbf4 100644 --- a/js/kivi.Part.js +++ b/js/kivi.Part.js @@ -334,7 +334,6 @@ namespace('kivi.Part', function(ns) { }, ajax_data: function(term) { var data = { - 'filter.all:substr:multi::ilike': term, current: this.$real.val(), }; @@ -356,6 +355,15 @@ namespace('kivi.Part', function(ns) { if (this.o.convertible_unit) data['filter.unit_obj.convertible_to'] = this.o.convertible_unit; + var filter_name = 'all'; + if (this.o.with_makemodel) { + filter_name = 'all_with_makemodel'; + } + if (this.o.with_customer_partnumber) { + filter_name = 'all_with_customer_partnumber'; + } + data['filter.' + filter_name + ':substr:multi::ilike'] = term; + return data; }, set_item: function(item) { diff --git a/templates/webpages/part/_multi_items_dialog.html b/templates/webpages/part/_multi_items_dialog.html index dfaeb949c..49916e039 100644 --- a/templates/webpages/part/_multi_items_dialog.html +++ b/templates/webpages/part/_multi_items_dialog.html @@ -5,7 +5,7 @@ - + diff --git a/templates/webpages/part/part_picker_search.html b/templates/webpages/part/part_picker_search.html index aa50c7d8b..49b08c40b 100644 --- a/templates/webpages/part/part_picker_search.html +++ b/templates/webpages/part/part_picker_search.html @@ -5,7 +5,7 @@
-[% LxERP.t8("Filter") %]: [% L.input_tag('part_picker_filter', SELF.models.filtered.laundered.all_substr_multi__ilike, class='part_picker_filter') %] +[% LxERP.t8("Filter") %]: [% L.input_tag('part_picker_filter', search_term, class='part_picker_filter') %]
[% L.checkbox_tag('no_paginate', checked=FORM.no_paginate, id='no_paginate', for_submit=1, label=LxERP.t8('All as list')) %] diff --git a/templates/webpages/part/test_page.html b/templates/webpages/part/test_page.html index 02d54d900..3918ee6d1 100644 --- a/templates/webpages/part/test_page.html +++ b/templates/webpages/part/test_page.html @@ -32,14 +32,23 @@ Artikel-Status: Ungültig
[% P.part.picker('part_id17', undef, status="obsolete") %]
Artikel-Status: Alle
[% P.part.picker('part_id18', undef, status="all") %]
- +
Pre-filled:
[% P.part.picker('part_id6', pre_filled_part) %]
Convertible unit 'Std': (only select parts with unit Tag/Std/Min)
[% P.part.picker('part_id7', undef, convertible_unit='Std') %]
- +
With multi select popup
[% P.part.picker('part_id8', undef, multiple=1) %]
+With multi select popup (only obsolete)
+[% P.part.picker('part_id8', undef, multiple=1, status='obsolete') %]
+
+All parts including make models of all vendors:
+[% P.part.picker('part_id', undef, with_makemodel=1) %]
+All parts including make models of all vendors with multi select popup:
+[% P.part.picker('part_id', undef, with_makemodel=1, multiple=1) %]
+All parts including customer partnumbers of all customers:
+[% P.part.picker('part_id', undef, with_customer_partnumber=1) %]

Styling

-- 2.20.1
[%- LxERP.t8("Description") %]/[%- LxERP.t8("Partnumber") %]:[%- L.input_tag('multi_items_filter', SELF.multi_items_models.filtered.laundered.all_substr_multi__ilike) %][%- L.input_tag('multi_items_filter', search_term) %] [%- LxERP.t8("Partsgroup") %] [%- L.select_tag('multi_items.filter.partsgroup_id', all_partsgroups, title_key='partsgroup', value_key='id', with_empty=1) %]