Langtext-Dialog: Größe prozentual zum Hauptfenster einstellbar pro Benutzer
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 11 Apr 2022 14:23:44 +0000 (16:23 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 11 Apr 2022 14:58:48 +0000 (16:58 +0200)
Ist hier in der Benutzereinstellung ein Wert != 0 gewählt, so wird der Dialog
entsprechend dargestellt. Auch die Größe des Editor-Bereichs wird in diesem
Fall angpepasst.
Ist 0 oder kein Wert gewählt, so ist das Verhalten wie zuvor.

14 files changed:
SL/AM.pm
SL/Controller/DeliveryOrder.pm
SL/Controller/Order.pm
SL/Helper/UserPreferences/DisplayPreferences.pm [new file with mode: 0644]
bin/mozilla/am.pl
bin/mozilla/do.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl
js/kivi.SalesPurchase.js
locale/de/all
locale/en/all
templates/webpages/am/config.html
templates/webpages/generic/set_longdescription.html

index 2ec2252..2d8ed4c 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -52,6 +52,7 @@ use SL::DB::Part;
 use SL::DB::Vendor;
 use SL::DB;
 use SL::GenericTranslations;
+use SL::Helper::UserPreferences::DisplayPreferences;
 use SL::Helper::UserPreferences::PositionsScrollbar;
 use SL::Helper::UserPreferences::PartPickerSearch;
 use SL::Helper::UserPreferences::TimeRecording;
@@ -551,6 +552,10 @@ sub time_recording_use_duration {
   SL::Helper::UserPreferences::TimeRecording->new()->get_use_duration();
 }
 
+sub longdescription_dialog_size_percentage {
+  SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
+}
+
 sub save_preferences {
   $main::lxdebug->enter_sub();
 
@@ -591,6 +596,9 @@ sub save_preferences {
   if (exists $form->{time_recording_use_duration}) {
     SL::Helper::UserPreferences::TimeRecording->new()->store_use_duration($form->{time_recording_use_duration})
   }
+  if (exists $form->{longdescription_dialog_size_percentage}) {
+    SL::Helper::UserPreferences::DisplayPreferences->new()->store_longdescription_dialog_size_percentage($form->{longdescription_dialog_size_percentage})
+  }
 
   $main::lxdebug->leave_sub();
 
index 1bb641c..97bfbca 100644 (file)
@@ -33,6 +33,7 @@ use SL::DB::TransferType;
 use SL::Helper::CreatePDF qw(:all);
 use SL::Helper::PrintOptions;
 use SL::Helper::ShippedQty;
+use SL::Helper::UserPreferences::DisplayPreferences;
 use SL::Helper::UserPreferences::PositionsScrollbar;
 use SL::Helper::UserPreferences::UpdatePositions;
 
@@ -1781,7 +1782,8 @@ sub pre_render {
                                                 } } @all_objects;
   }
 
-  $self->{template_args}{in_out} = $self->type_data->transfer;
+  $self->{template_args}{in_out}                                 = $self->type_data->transfer;
+  $self->{template_args}{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
 
   $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted};
 
index 43e8dc4..0250781 100644 (file)
@@ -33,6 +33,7 @@ use SL::DB::Translation;
 use SL::Helper::CreatePDF qw(:all);
 use SL::Helper::PrintOptions;
 use SL::Helper::ShippedQty;
+use SL::Helper::UserPreferences::DisplayPreferences;
 use SL::Helper::UserPreferences::PositionsScrollbar;
 use SL::Helper::UserPreferences::UpdatePositions;
 
@@ -2025,6 +2026,7 @@ sub pre_render {
       && $::instance_conf->get_transport_cost_reminder_article_number_id ) {
     $self->{template_args}->{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load;
   }
+  $self->{template_args}->{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
 
   $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted};
 
diff --git a/SL/Helper/UserPreferences/DisplayPreferences.pm b/SL/Helper/UserPreferences/DisplayPreferences.pm
new file mode 100644 (file)
index 0000000..f3bcae3
--- /dev/null
@@ -0,0 +1,66 @@
+package SL::Helper::UserPreferences::DisplayPreferences;
+
+use strict;
+use parent qw(Rose::Object);
+
+use SL::Helper::UserPreferences;
+
+use Rose::Object::MakeMethods::Generic (
+  'scalar --get_set_init' => [ qw(user_prefs) ],
+);
+
+sub get_longdescription_dialog_size_percentage {
+  $_[0]->user_prefs->get('longdescription_dialog_size_percentage');
+}
+
+sub store_longdescription_dialog_size_percentage {
+  $_[0]->user_prefs->store('longdescription_dialog_size_percentage', $_[1]);
+}
+
+sub init_user_prefs {
+  SL::Helper::UserPreferences->new(
+    namespace => $_[0]->namespace,
+  )
+}
+
+# read only stuff
+sub namespace     { 'DisplayPreferences' }
+sub version       { 1 }
+
+1;
+
+__END__
+
+=pod
+
+=encoding utf-8
+
+=head1 NAME
+
+SL::Helper::UserPreferences::DisplayPreferences - preferences intended
+to store user settings for various display settings.
+
+=head1 SYNOPSIS
+
+  use SL::Helper::UserPreferences::DisplayPreferences;
+  my $prefs = SL::Helper::UserPreferences::DisplayPreferences->new();
+
+  $prefs->store_use_duration(1);
+  my $value = $prefs->get_longdescription_dialog_size_percentage;
+
+=head1 DESCRIPTION
+
+This module manages storing the user's choise for settings for
+various display settings.
+For now the preferred procentual size of the edit-dialog for longdescriptions
+of positions can be stored.
+
+=head1 BUGS
+
+None yet :)
+
+=head1 AUTHOR
+
+Bernd Bleßmann E<lt>bernd@kivitendo-premium.deE<gt>
+
+=cut
index 0b29a83..541abab 100644 (file)
@@ -659,12 +659,13 @@ 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();
-  $form->{positions_scrollbar_height}       = AM->positions_scrollbar_height();
-  $form->{purchase_search_makemodel}        = AM->purchase_search_makemodel();
-  $form->{sales_search_customer_partnumber} = AM->sales_search_customer_partnumber();
-  $form->{positions_show_update_button}     = AM->positions_show_update_button();
-  $form->{time_recording_use_duration}      = AM->time_recording_use_duration();
+  $form->{displayable_name_specs_by_module}       = AM->displayable_name_specs_by_module();
+  $form->{positions_scrollbar_height}             = AM->positions_scrollbar_height();
+  $form->{purchase_search_makemodel}              = AM->purchase_search_makemodel();
+  $form->{sales_search_customer_partnumber}       = AM->sales_search_customer_partnumber();
+  $form->{positions_show_update_button}           = AM->positions_show_update_button();
+  $form->{time_recording_use_duration}            = AM->time_recording_use_duration();
+  $form->{longdescription_dialog_size_percentage} = AM->longdescription_dialog_size_percentage();
 
   $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
   $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
index 581ec5b..e0b4dbc 100644 (file)
@@ -39,6 +39,7 @@ use POSIX qw(strftime);
 use SL::Controller::DeliveryOrder;
 use SL::DB::DeliveryOrder;
 use SL::DB::DeliveryOrder::TypeData qw(:types validate_type);
+use SL::Helper::UserPreferences::DisplayPreferences;
 use SL::DO;
 use SL::IR;
 use SL::IS;
@@ -517,6 +518,7 @@ sub form_header {
 
 
   $form->{follow_up_trans_info} = $form->{donumber} .'('. $form->{VC_OBJ}->name .')' if $form->{VC_OBJ};
+  $form->{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
 
   $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.File kivi.MassDeliveryOrderPrint kivi.SalesPurchase kivi.Part kivi.CustomerVendor kivi.Validator ckeditor/ckeditor ckeditor/adapters/jquery kivi.io));
 
index 1b9a782..b0df30c 100644 (file)
@@ -34,6 +34,7 @@
 
 use SL::FU;
 use SL::Helper::Flash qw(flash_later);
+use SL::Helper::UserPreferences::DisplayPreferences;
 use SL::IR;
 use SL::IS;
 use SL::DB::BankTransactionAccTrans;
@@ -456,9 +457,10 @@ sub form_header {
     $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
   }
 
-  $TMPL_VAR{is_format_html}      = $form->{format} eq 'html';
-  $TMPL_VAR{dateformat}          = $myconfig{dateformat};
-  $TMPL_VAR{numberformat}        = $myconfig{numberformat};
+  $TMPL_VAR{is_format_html}                         = $form->{format} eq 'html';
+  $TMPL_VAR{dateformat}                             = $myconfig{dateformat};
+  $TMPL_VAR{numberformat}                           = $myconfig{numberformat};
+  $TMPL_VAR{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
 
   # hiddens
   $TMPL_VAR{HIDDENS} = [qw(
index 57a79af..d0e2506 100644 (file)
@@ -35,6 +35,7 @@
 use SL::FU;
 use SL::IS;
 use SL::OE;
+use SL::Helper::UserPreferences::DisplayPreferences;
 use SL::MoreCommon qw(restore_form save_form);
 use SL::RecordLinks;
 
@@ -625,11 +626,12 @@ sub form_header {
     $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
   }
 
-  $TMPL_VAR{is_type_normal_invoice} = $form->{type} eq "invoice";
-  $TMPL_VAR{is_type_credit_note}    = $form->{type}   eq "credit_note";
-  $TMPL_VAR{is_format_html}         = $form->{format} eq 'html';
-  $TMPL_VAR{dateformat}             = $myconfig{dateformat};
-  $TMPL_VAR{numberformat}           = $myconfig{numberformat};
+  $TMPL_VAR{is_type_normal_invoice}                 = $form->{type} eq "invoice";
+  $TMPL_VAR{is_type_credit_note}                    = $form->{type}   eq "credit_note";
+  $TMPL_VAR{is_format_html}                         = $form->{format} eq 'html';
+  $TMPL_VAR{dateformat}                             = $myconfig{dateformat};
+  $TMPL_VAR{numberformat}                           = $myconfig{numberformat};
+  $TMPL_VAR{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
 
   # hiddens
   $TMPL_VAR{HIDDENS} = [qw(
index 610215b..3ac2fc2 100644 (file)
@@ -42,6 +42,7 @@ use SL::FU;
 use SL::OE;
 use SL::IR;
 use SL::IS;
+use SL::Helper::UserPreferences::DisplayPreferences;
 use SL::MoreCommon qw(ary_diff restore_form save_form);
 use SL::ReportGenerator;
 use SL::YAML;
@@ -50,7 +51,6 @@ use List::Util qw(min max reduce sum);
 use Data::Dumper;
 
 use SL::Controller::Order;
-
 use SL::DB::Customer;
 use SL::DB::TaxZone;
 use SL::DB::PaymentTerm;
@@ -622,8 +622,9 @@ sub form_header {
   }
 
   $::request->{layout}->add_javascripts_inline("\$(function(){$dispatch_to_popup});");
-  $TMPL_VAR->{dateformat}          = $myconfig{dateformat};
-  $TMPL_VAR->{numberformat}        = $myconfig{numberformat};
+  $TMPL_VAR->{dateformat}                             = $myconfig{dateformat};
+  $TMPL_VAR->{numberformat}                           = $myconfig{numberformat};
+  $TMPL_VAR->{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
 
   if ($form->{type} eq 'sales_order') {
     if (!$form->{periodic_invoices_config}) {
index a350e19..4dc390b 100644 (file)
@@ -1,4 +1,6 @@
 namespace('kivi.SalesPurchase', function(ns) {
+  this.longdescription_dialog_size_percentage = 0;
+
   this.edit_longdescription = function(row) {
     var $element = $('#longdescription_' + row);
 
@@ -17,8 +19,20 @@ namespace('kivi.SalesPurchase', function(ns) {
   };
 
   this.edit_longdescription_with_params = function(params) {
+    var dialog_width    = 800;
+    var dialog_height   = 500;
+    var textarea_width  = 750;
+    var textarea_height = 220;
+    if (this.longdescription_dialog_size_percentage != 0) {
+      dialog_width    = Math.ceil(window.innerWidth  * this.longdescription_dialog_size_percentage/100);
+      dialog_height   = Math.ceil(window.innerHeight * this.longdescription_dialog_size_percentage/100);
+      textarea_width  = Math.ceil(dialog_width * 95/100);
+      textarea_height = dialog_height - 220;
+      if (textarea_height <= 0) textarea_height = 220;
+    }
+
     var $container = $('#popup_edit_longdescription_input_container');
-    var $edit      = $('<textarea id="popup_edit_longdescription_input" class="texteditor-in-dialog texteditor-space-for-toolbar" wrap="soft" style="width: 750px; height: 220px;"></textarea>');
+    var $edit      = $('<textarea id="popup_edit_longdescription_input" class="texteditor-in-dialog texteditor-space-for-toolbar" wrap="soft" style="width: ' + textarea_width + 'px; height: ' + textarea_height + 'px;"></textarea>');
 
     $container.children().remove();
     $container.append($edit);
@@ -44,6 +58,8 @@ namespace('kivi.SalesPurchase', function(ns) {
       id:    'edit_longdescription_dialog',
       dialog: {
         title: kivi.t8('Enter longdescription'),
+        width:  dialog_width,
+        height: dialog_height,
         open:  function() { kivi.focus_ckeditor_when_ready('#popup_edit_longdescription_input'); },
         close: function() { $('#popup_edit_longdescription_input_container').children().remove(); }
       }
index 9c443ae..b4c12b7 100755 (executable)
@@ -2046,6 +2046,7 @@ $self->{texts} = {
   'Long Description (quotations & orders)' => 'Langtext (Angebote & Aufträge)',
   'Long Description for invoices' => 'Langtext für Rechnungen',
   'Long Description for quotations & orders' => 'Langtext für Angebote & Aufträge',
+  'Longdescription dialog size percentage from main window (0 means fix values)' => 'Prozentuale Größe des Langtext-Dialogs im Verhältnis zum Hauptfenster (0 bedeutet feste Größe)',
   'Loss'                        => 'Verlust',
   'Loss carried forward account' => 'Verlustvortragskonto',
   'Luxembourg'                  => 'Luxemburg',
index f1c9c7a..0c0c44f 100644 (file)
@@ -2046,6 +2046,7 @@ $self->{texts} = {
   'Long Description (quotations & orders)' => '',
   'Long Description for invoices' => '',
   'Long Description for quotations & orders' => '',
+  'Longdescription dialog size percentage from main window (0 means fix values)' => '',
   'Loss'                        => '',
   'Loss carried forward account' => '',
   'Luxembourg'                  => '',
index 4a8d64d..cd0e7ee 100644 (file)
       </td>
      </tr>
 
+     <tr>
+      <th align="right">[% 'Longdescription dialog size percentage from main window (0 means fix values)' | $T8 %]</th>
+      <td>
+        [% L.input_tag('longdescription_dialog_size_percentage', longdescription_dialog_size_percentage, size = 5) %]
+      </td>
+     </tr>
      [%- IF INSTANCE_CONF.get_feature_experimental_order -%]
      <tr>
       <th align="right">[% 'Scrollbar height percentage for form postion area (0 means no scrollbar)' | $T8 %]</th>
index 3187637..eb74675 100644 (file)
@@ -25,3 +25,9 @@
   <a onclick="$('#edit_longdescription_dialog').dialog('close');" href="#">[% LxERP.t8("Abort") %]</a>
  </p>
 </div>
+
+<script>
+  $(function() {
+    kivi.SalesPurchase.longdescription_dialog_size_percentage = "[% longdescription_dialog_size_percentage %]";
+  });
+</script>