DisplayableNamePrefs: Benutzereinstellungen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 23 Jan 2019 15:17:16 +0000 (16:17 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 25 Jan 2019 12:31:32 +0000 (13:31 +0100)
SL/AM.pm
bin/mozilla/am.pl
templates/webpages/am/config.html

index e48f55a..5db3f71 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -47,6 +47,9 @@ use SL::DB::AuthUser;
 use SL::DB::Default;
 use SL::DB::Employee;
 use SL::DB::Chart;
+use SL::DB::Customer;
+use SL::DB::Part;
+use SL::DB::Vendor;
 use SL::DB;
 use SL::GenericTranslations;
 
@@ -507,6 +510,23 @@ sub save_template {
   return $error;
 }
 
+sub displayable_name_specs_by_module {
+  +{
+     'SL::DB::Customer' => {
+       specs => SL::DB::Customer->displayable_name_specs,
+       prefs => SL::DB::Customer->displayable_name_prefs,
+     },
+     'SL::DB::Vendor' => {
+       specs => SL::DB::Vendor->displayable_name_specs,
+       prefs => SL::DB::Vendor->displayable_name_prefs,
+     },
+     'SL::DB::Part' => {
+       specs => SL::DB::Part->displayable_name_specs,
+       prefs => SL::DB::Part->displayable_name_prefs,
+     },
+  };
+}
+
 sub save_preferences {
   $main::lxdebug->enter_sub();
 
@@ -522,6 +542,16 @@ sub save_preferences {
       map { ($_ => $form->{$_}) } SL::DB::AuthUser::CONFIG_VARS(),
     });
 
+  # Displayable name preferences
+  my $displayable_name_specs_by_module = displayable_name_specs_by_module();
+  foreach my $specs (@{ $form->{displayable_name_specs} }) {
+    if (!$specs->{value} || $specs->{value} eq $displayable_name_specs_by_module->{$specs->{module}}->{prefs}->get_default()) {
+      $displayable_name_specs_by_module->{$specs->{module}}->{prefs}->delete($specs->{value});
+    } else {
+      $displayable_name_specs_by_module->{$specs->{module}}->{prefs}->store_value($specs->{value});
+    }
+  }
+
   $main::lxdebug->leave_sub();
 
   return 1;
index e561b7c..432eb7b 100644 (file)
@@ -659,6 +659,8 @@ sub config {
   $form->{enabled_quick_searchmodules} = \@{$enabled_quick_search};
   $form->{default_quick_searchmodules} = \@quick_search_modules;
 
+  $form->{displayable_name_specs_by_module} = AM->displayable_name_specs_by_module();
+
   $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
   $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
   $form->{todo_cfg}            = { TODO->get_user_config('login' => $::myconfig{login}) };
index 3cea818..f64ce7d 100644 (file)
         [% L.input_tag('form_cvars_nr_cols',  MYCONFIG.form_cvars_nr_cols || 3,  size = 5) %]
       </td>
      </tr>
+
      <tr>
       <th align="right">[% 'Quick Searches that will be shown in the header for this user' | $T8 %]</th>
       <td colspan=2>
         </div>
       </td>
     </tr>
+
+     <tr>
+       <th align="right">[% 'Displayable Name Preferences' | $T8 %]</th>
+       <td>
+         <table>
+           [% FOREACH module=displayable_name_specs_by_module.keys.sort %]
+           [%- SET spec=displayable_name_specs_by_module.$module -%]
+           <tr>
+             <td align="right">[% spec.specs.title %]</td>
+             <td>
+               <table>
+                 <tr>
+                   <th align="left" class="listheading">[% 'Option' | $T8 %]</th>
+                   <th align="left" class="listheading">[% 'Name'   | $T8 %]</th>
+                 </tr>
+                 [% FOREACH option=spec.specs.options %]
+                 <tr>
+                   <td>[% option.title %]</td>
+                   <td>[% option.name  %]</td>
+                 </tr>
+                 [% END %]
+                 <tr>
+                   <th align="left">[% 'Display' | $T8 %]:</th>
+                   <td>
+                     [% L.hidden_tag("displayable_name_specs[+].module", module) %]
+                     [% L.input_tag("displayable_name_specs[].value", spec.prefs.get, size=50) %]
+                   </td>
+                 </tr>
+               </table>
+             </td>
+           </tr>
+           [% END %]
+         </table>
+       </td>
+
     </table>
    </div>