use constant OPTION_DEFAULTS =>
{
MAXLENGTH => 75,
- WIDTH => 30,
- HEIGHT => 5,
+ WIDTH => 225,
+ HEIGHT => 90,
};
sub processed_options {
'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.',
'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.' => '',
--- /dev/null
+# @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 = <<SQL;
+ SELECT id, options
+ FROM custom_variable_configs
+ WHERE (COALESCE(options, '') ~ 'WIDTH=|HEIGHT=')
+ AND (type = 'textfield')
+SQL
+
+ return selectall_hashref_query($::form, $self->dbh, $sql);
+}
+
+sub fix_configs {
+ my ($self, $configs) = @_;
+
+ my $sql = <<SQL;
+ UPDATE custom_variable_configs
+ SET options = ?
+ WHERE id = ?
+SQL
+
+ my $update_h = prepare_query($::form, $self->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;
[%- 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) %]
[%- 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' ) %]
<br>
<ul>
<li>[%- 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' | $T8 %]</li>
- <li>[%- '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 %]</li>
+ <li>[%- '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 %]</li>
<li>[%- 'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' | $T8 %]</li>
<li>[%- 'Selection fields: The option field must contain the available options for the selection. Options are separated by \'##\', for example \'Early##Normal##Late\'.' | $T8 %]</li>
</ul>