]> wagnertech.de Git - mfinanz.git/commitdiff
PartPicker: Mehrfachauswahl: Option um Anzeige-Begrenzung zu setzen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 26 Jan 2021 11:35:30 +0000 (12:35 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 27 Jan 2021 11:26:15 +0000 (12:26 +0100)
Diese war vorher fest auf 100 eingestellt. 100 bleibt die Voreinstellung.

SL/Controller/Part.pm
SL/Presenter/Part.pm
js/kivi.Part.js
templates/webpages/part/test_page.html

index a0ff1e7002b6820d342c8f2ecd082a0e1ed156a1..cfc94eea14a0355d0a32bd49b41007e3e5258375 100644 (file)
@@ -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 {
index 40c172b2f171feb342f8938b65215b424ad427a4..ef962ec79bdd1c14a6e071923efb5fb62998531b 100644 (file)
@@ -256,6 +256,11 @@ where C<pp_id> is the dom id of the part picker.
 Or you can even do it the other way round setting C<multiple> to 1 on creation
 and open a single selection popup with js.
 
+If C<%params> contains C<multiple_limit> the alternative popup will not
+show any results if there are more than C<multiple_limit> results. A warning
+message is displayed in this case. Set C<multiple_limit> 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.
index a9c58ba737f5b6b8d82cc133958c6e357825e82b..3f64c3a59cc825f0acfae955eec5074bbf1673e2 100644 (file)
@@ -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
index e1ef28c11ebb8c4d82bceaca065fe7a1b579dda6..0101db1e5756f3e2c14cc8da4259d4bf0d6c622c 100644 (file)
@@ -50,8 +50,8 @@ All parts including make models of all vendors with multi select popup: <br>
 All parts including customer partnumbers of all customers: <br>
 [% P.part.picker('part_id23', undef, with_customer_partnumber=1) %]<br>
 <br>
-single select dialog for glass-popup-button; multi select with extra button:<br>
-[% 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):<br>
+[% 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') %]<br>
 
 <h2>Styling</h2>