From: Moritz Bunkus Date: Fri, 12 Nov 2021 16:28:02 +0000 (+0100) Subject: Benutzerdef. Var. als HTML-Feld: Breite & Höhe in Pixeln angeben X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~269^2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=9f3c46ffb16c200246c545faa7f17686aa461483;p=kivitendo-erp.git Benutzerdef. Var. als HTML-Feld: Breite & Höhe in Pixeln angeben --- diff --git a/SL/DB/CustomVariableConfig.pm b/SL/DB/CustomVariableConfig.pm index c9f07219b..6ba2238af 100644 --- a/SL/DB/CustomVariableConfig.pm +++ b/SL/DB/CustomVariableConfig.pm @@ -37,8 +37,8 @@ sub validate { use constant OPTION_DEFAULTS => { MAXLENGTH => 75, - WIDTH => 30, - HEIGHT => 5, + WIDTH => 225, + HEIGHT => 90, }; sub processed_options { diff --git a/locale/de/all b/locale/de/all index 67f877063..9b84bc664 100755 --- a/locale/de/all +++ b/locale/de/all @@ -3364,7 +3364,7 @@ $self->{texts} = { 'Text blocks back' => 'Textblöcke hinten', 'Text blocks front' => 'Textblöcke vorne', 'Text field' => 'Textfeld', - 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' => 'Textfelder und HTML-Felder: \'WIDTH=w HEIGHT=h\' setzen die Breite und die Höhe des Textfeldes. Wenn nicht anders angegeben, so werden sie 30 Zeichen breit und fünf Zeichen hoch dargestellt.', + 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the field in pixels. They default to 225 and 90 respectively.' => 'Textfelder und HTML-Felder: \'WIDTH=w HEIGHT=h\' setzen die Breite und die Höhe des Feldes in Pixeln. Wenn nicht anders angegeben, so werden sie 225 Pixel breit und 90 Pixel hoch dargestellt.', 'Text in CSV File' => 'Spalte in der CSV Datei', 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' => 'Textzeilen: \'MAXLENGTH=n\' setzt eine Maximallänge von n Zeichen.', 'Text, text field, HTML field and number variables: The default value will be used as-is.' => 'Textzeilen, Textfelder, HTML-Felder und Zahlenvariablen: Der Standardwert wird so wie er ist übernommen.', diff --git a/locale/en/all b/locale/en/all index 26cee2d0f..4581ae8de 100644 --- a/locale/en/all +++ b/locale/en/all @@ -3363,7 +3363,7 @@ $self->{texts} = { 'Text blocks back' => '', 'Text blocks front' => '', 'Text field' => '', - 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' => '', + 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the field in pixels. They default to 225 and 90 respectively.' => '', 'Text in CSV File' => '', 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' => '', 'Text, text field, HTML field and number variables: The default value will be used as-is.' => '', diff --git a/sql/Pg-upgrade2/custom_variables_convert_width_height_to_pixels.pl b/sql/Pg-upgrade2/custom_variables_convert_width_height_to_pixels.pl new file mode 100644 index 000000000..45b22f8b3 --- /dev/null +++ b/sql/Pg-upgrade2/custom_variables_convert_width_height_to_pixels.pl @@ -0,0 +1,59 @@ +# @tag: custom_variables_convert_width_height_to_pixels +# @description: Benutzerdefinierte Variablen: Optionen »WIDTH« & »HEIGHT« nach Pixel konvertieren +# @depends: release_3_5_8 +package SL::DBUpgrade2::custom_variables_convert_width_height_to_pixels; + +use strict; +use utf8; + +use parent qw(SL::DBUpgrade2::Base); + +use SL::DBUtils; + +sub find_configs { + my ($self) = @_; + + my $sql = <dbh, $sql); +} + +sub fix_configs { + my ($self, $configs) = @_; + + my $sql = <dbh, $sql); + + # Old defaults: 30 columns, 5 rows + # New defaults: 225px width, 90px height + + foreach my $config (@{ $configs }) { + $config->{options} =~ s{WIDTH=(\d+)}{ int($1 * (225 / 30.0)) }eg; + $config->{options} =~ s{HEIGHT=(\d+)}{ int($1 * ( 90 / 5.0)) }eg; + + $update_h->execute(@{$config}{qw(options id)}) || $self->db_error($sql); + } + + $update_h->finish; +} + +sub run { + my ($self) = @_; + + my $configs = $self->find_configs; + $self->fix_configs($configs) if @{ $configs }; + + return 1; +} + +1; diff --git a/templates/webpages/common/render_cvar_input.html b/templates/webpages/common/render_cvar_input.html index 36445d630..2db49e896 100644 --- a/templates/webpages/common/render_cvar_input.html +++ b/templates/webpages/common/render_cvar_input.html @@ -5,6 +5,7 @@ [%- USE LxERP %] [%- DEFAULT var_name = HTML.escape(cvar_name_prefix) _ HTML.escape(var.config.name) _ HTML.escape(cvar_name_postfix) %] +[%- SET style_ = "width: " _ var.config.processed_options.WIDTH _ "px; height: " _ var.config.processed_options.HEIGHT _ "px" %] [%- IF ( hide_non_editable && !var.config.is_flag('editable') ) %] [% L.hidden_tag(var_name, var.value) %] @@ -15,9 +16,9 @@ [%- ELSIF ( var.config .type == 'bool' ) %] [% L.checkbox_tag(var_name, checked = var.value, for_submit = 1) %] [%- ELSIF ( var.config .type == 'textfield' ) %] - [% L.textarea_tag(var_name, var.value, cols = var.config.processed_options.WIDTH, rows = var.config.processed_options.HEIGHT) %] + [% L.textarea_tag(var_name, var.value, style=style_) %] [%- ELSIF ( var.config .type == 'htmlfield' ) %] - [% L.textarea_tag(var_name, L.restricted_html(var.value), cols = var.config.processed_options.WIDTH, rows = var.config.processed_options.HEIGHT, class='texteditor') %] + [% L.textarea_tag(var_name, L.restricted_html(var.value), class='texteditor', style=style_) %] [%- ELSIF ( var.config.type == 'date' ) %] [% L.date_tag(var_name, var.value) %] [%- ELSIF ( var.config.type == 'timestamp' ) %] diff --git a/templates/webpages/custom_variable_config/form.html b/templates/webpages/custom_variable_config/form.html index 50355e609..c88711a5f 100644 --- a/templates/webpages/custom_variable_config/form.html +++ b/templates/webpages/custom_variable_config/form.html @@ -138,7 +138,7 @@
  • [%- 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' | $T8 %]
  • -
  • [%- 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' | $T8 %]
  • +
  • [%- 'Text field and HTML field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the field in pixels. They default to 225 and 90 respectively.' | $T8 %]
  • [%- 'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' | $T8 %]
  • [%- 'Selection fields: The option field must contain the available options for the selection. Options are separated by \'##\', for example \'Early##Normal##Late\'.' | $T8 %]