From: Bernd Bleßmann Date: Tue, 26 Jan 2021 11:35:30 +0000 (+0100) Subject: PartPicker: Mehrfachauswahl: Option um Anzeige-Begrenzung zu setzen X-Git-Tag: kivitendo-mebil_0.1-0~9^2~501 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8c30110b9ee3e0c7f21a49df3ae91dd8f31f1caf;p=kivitendo-erp.git PartPicker: Mehrfachauswahl: Option um Anzeige-Begrenzung zu setzen Diese war vorher fest auf 100 eingestellt. 100 bleibt die Voreinstellung. --- diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index a0ff1e700..cfc94eea1 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -423,14 +423,14 @@ sub action_show_multi_items_dialog { } sub action_multi_items_update_result { - my $max_count = 100; + my $max_count = $::form->{limit}; my $count = $_[0]->multi_items_models->count; if ($count == 0) { my $text = escape($::locale->text('No results.')); $_[0]->render($text, { layout => 0 }); - } elsif ($count > $max_count) { + } elsif ($max_count && $count > $max_count) { my $text = escape($::locale->text('Too many results (#1 from #2).', $count, $max_count)); $_[0]->render($text, { layout => 0 }); } else { diff --git a/SL/Presenter/Part.pm b/SL/Presenter/Part.pm index 40c172b2f..ef962ec79 100644 --- a/SL/Presenter/Part.pm +++ b/SL/Presenter/Part.pm @@ -256,6 +256,11 @@ where C is the dom id of the part picker. Or you can even do it the other way round setting C to 1 on creation and open a single selection popup with js. +If C<%params> contains C the alternative popup will not +show any results if there are more than C results. A warning +message is displayed in this case. Set C to 0 to disable +the limitation. The limit defaults to 100. + 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 a9c58ba73..3f64c3a59 100644 --- a/js/kivi.Part.js +++ b/js/kivi.Part.js @@ -312,7 +312,8 @@ namespace('kivi.Part', function(ns) { commit_none: function(){ }, commit_one: function(){ $('#update_button').click(); }, commit_many: function(){ self.open_dialog(); } - } + }, + multiple_limit: 100 }, $real.data('part-picker-data'), options); this.$real = $real; this.real_id = $real.attr('id'); @@ -698,7 +699,8 @@ namespace('kivi.Part', function(ns) { update_results: function() { var self = this; var data = $('#multi_items_form').serializeArray(); - data.push({ name: 'type', value: self.pp.type }); + data.push({ name: 'type', value: self.pp.type }); + data.push({ name: 'limit', value: self.pp.o.multiple_limit }); var ppdata = self.pp.ajax_data(function(){ var val = $('#multi_items_filter').val(); return val === undefined ? '' : val diff --git a/templates/webpages/part/test_page.html b/templates/webpages/part/test_page.html index e1ef28c11..0101db1e5 100644 --- a/templates/webpages/part/test_page.html +++ b/templates/webpages/part/test_page.html @@ -50,8 +50,8 @@ All parts including make models of all vendors with multi select popup:
All parts including customer partnumbers of all customers:
[% P.part.picker('part_id23', undef, with_customer_partnumber=1) %]

-single select dialog for glass-popup-button; multi select with extra button:
-[% P.part.picker('part_id31', undef, multiple=0) %] +single select dialog for glass-popup-button; multi select with extra button (and limited to 5 results):
+[% P.part.picker('part_id31', undef, multiple=0, multiple_limit=5) %] [% L.button_tag('$("#part_id31").data("part_picker").o.multiple=1; $("#part_id31").data("part_picker").open_dialog()', 'Add multiple items') %]

Styling