Projekt-Picker: Stil der Beschreibung angeben können
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 7 May 2021 10:34:36 +0000 (12:34 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 7 May 2021 10:34:36 +0000 (12:34 +0200)
dem Picker kann mit "description_style" mitgegeben werden, wie die
Ergebnisse angezeigt werden. Mögliche Werte: "both", "number",
"description" und "full" (in SL::DB::Project->full_description)
definiert).

SL/Controller/Project.pm
SL/Presenter/Project.pm
js/autocomplete_project.js
templates/webpages/project/test_page.html

index ba460c5..94862e1 100644 (file)
@@ -120,10 +120,14 @@ sub action_ajax_autocomplete {
 
   $::form->{sort_by} = 'customer_and_description';
 
+  my $description_style = ($::form->{description_style} =~ m{both|number|description|full})
+                        ? $::form->{description_style}
+                        : 'full';
+
   my @hashes = map {
    +{
-     value         => $_->full_description(style => 'full'),
-     label         => $_->full_description(style => 'full'),
+     value         => $_->full_description(style => $description_style),
+     label         => $_->full_description(style => $description_style),
      id            => $_->id,
      projectnumber => $_->projectnumber,
      description   => $_->description,
index af40c30..8aecdfe 100644 (file)
@@ -39,7 +39,7 @@ sub project_picker {
   push @classes, 'project_autocomplete';
 
 
-  my %data_params = map { $_ => delete $params{$_}  } grep { defined $params{$_} } qw(customer_id active valid);
+  my %data_params = map { $_ => delete $params{$_}  } grep { defined $params{$_} } qw(customer_id active valid description_style);
 
   my $ret =
     input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id,
index aba6821..6a566c4 100644 (file)
@@ -93,6 +93,9 @@ namespace('kivi', function(k){
         data['filter.valid'] = 'valid'; // default
       }
 
+      if (o.description_style)
+        data['description_style'] = o.description_style;
+
       return data;
     }
 
index 95c3c83..2580482 100644 (file)
 [% P.project.picker('project12_id', '', active='both', valid='both',style='width: 300px') %] all (active, inactive, valid, invalid)
 <br>
 
+<br>
+[% P.project.picker('project13_id', '', style='width: 300px') %] description style full (default)
+<br>
+
+<br>
+[% P.project.picker('project14_id', '', description_style='full', style='width: 300px') %] description style full (explicit)
+<br>
+
+<br>
+[% P.project.picker('project15_id', '', description_style='both', style='width: 300px') %] description style both
+<br>
+
+<br>
+[% P.project.picker('project16_id', '', description_style='number', style='width: 300px') %] description style number
+<br>
+
+<br>
+[% P.project.picker('project17_id', '', description_style='description', style='width: 300px') %] description style description
+<br>
+
+<br>
+
 Runtime test:<br>
 <div id='runtime_picker'>'