]> wagnertech.de Git - mfinanz.git/commitdiff
Merge branch 'f-cvar-htmlfield'
authorMoritz Bunkus <m.bunkus@linet.de>
Fri, 17 Dec 2021 14:13:09 +0000 (15:13 +0100)
committerMoritz Bunkus <m.bunkus@linet.de>
Fri, 17 Dec 2021 14:13:09 +0000 (15:13 +0100)
25 files changed:
SL/BackgroundJob/CreatePeriodicInvoices.pm
SL/CVar.pm
SL/Controller/CsvImport/Base.pm
SL/Controller/CsvImport/BaseMulti.pm
SL/Controller/CustomVariableConfig.pm
SL/Controller/CustomerVendor.pm
SL/Controller/Order.pm
SL/Controller/Project.pm
SL/Controller/RequirementSpec.pm
SL/DB/CustomVariable.pm
SL/DB/CustomVariableConfig.pm
SL/DN.pm
SL/Form.pm
SL/HTML/Util.pm
SL/Presenter/Text.pm
SL/Template/Plugin/L.pm
locale/de/all
locale/en/all
sql/Pg-upgrade2/custom_variables_convert_width_height_to_pixels.pl [new file with mode: 0644]
templates/print/marei/requirement_spec.tex
templates/webpages/amcvar/render_inputs.html
templates/webpages/amcvar/render_inputs_block.html
templates/webpages/common/render_cvar_input.html
templates/webpages/custom_variable_config/form.html
templates/webpages/requirement_spec/_show_basic_settings.html

index 58f1febab45c3e9c11bae1b2d4a75b1e6f969f5e..f411353873d8990c73504862e93e5dde8642680b 100644 (file)
@@ -451,6 +451,7 @@ sub _email_invoice {
       longdescription => 'html',
       partnotes       => 'html',
       notes           => 'html',
+      $::form->get_variable_content_types_for_cvars,
     },
   );
 
index a905edee7b7d70fd203dfc8aaec66ec734f4bf2f..637f129c880481d0b281461b6679255d8ad4d605 100644 (file)
@@ -10,6 +10,7 @@ use Data::Dumper;
 
 use SL::DBUtils;
 use SL::MoreCommon qw(listify);
+use SL::Presenter::Text;
 use SL::Util qw(trim);
 use SL::DB;
 
@@ -46,7 +47,7 @@ SQL
       } elsif ($config->{type} eq 'number') {
         $config->{precision} = $1 if ($config->{options} =~ m/precision=(\d+)/i);
 
-      } elsif ($config->{type} eq 'textfield') {
+      } elsif ($config->{type} =~ m{^(?:html|text)field$}) {
         $config->{width}  = 30;
         $config->{height} =  5;
         $config->{width}  = $1 if ($config->{options} =~ m/width=(\d+)/i);
@@ -112,7 +113,7 @@ sub get_custom_variables {
   my $custom_variables = $self->get_configs(module => $params{module});
 
   foreach my $cvar (@{ $custom_variables }) {
-    if ($cvar->{type} eq 'textfield') {
+    if ($cvar->{type} =~ m{^(?:html|text)field}) {
       $cvar->{width}  = 30;
       $cvar->{height} =  5;
 
@@ -271,7 +272,7 @@ sub _save_custom_variables {
 
     my $value  = $params{variables}->{"$params{name_prefix}cvar_$config->{name}$params{name_postfix}"};
 
-    if (($config->{type} eq 'text') || ($config->{type} eq 'textfield') || ($config->{type} eq 'select')) {
+    if (any { $config->{type} eq $_ } qw(text textfield htmlfield select)) {
       push @values, undef, undef, $value, undef;
 
     } elsif (($config->{type} eq 'date') || ($config->{type} eq 'timestamp')) {
@@ -375,7 +376,7 @@ sub build_filter_query {
 
     my (@sub_values, @sub_where, $not);
 
-    if (($config->{type} eq 'text') || ($config->{type} eq 'textfield')) {
+    if (any { $config->{type} eq $_ } qw(text textfield htmlfield)) {
       next unless ($params{filter}->{$name});
 
       push @sub_where,  qq|cvar.text_value ILIKE ?|;
@@ -525,6 +526,7 @@ sub add_custom_variables_to_report {
         : $cfg->{type} eq 'vendor'    ? (SL::DB::Manager::Vendor->find_by(id => 1*$ref->{number_value})   || SL::DB::Vendor->new)->name
         : $cfg->{type} eq 'part'      ? (SL::DB::Manager::Part->find_by(id => 1*$ref->{number_value})     || SL::DB::Part->new)->partnumber
         : $cfg->{type} eq 'bool'      ? ($ref->{bool_value} ? $locale->text('Yes') : $locale->text('No'))
+        : $cfg->{type} eq 'htmlfield' ? SL::Presenter::Text::stripped_html($ref->{text_value})
         :                               $ref->{text_value};
     }
   }
index 0a3ec969d6cd1f177e8341d28136456383d1ff2a..1aaec79c9555cc7681596f4d4f8365f19c613aa3 100644 (file)
@@ -293,6 +293,7 @@ sub handle_cvars {
 
   my %type_to_column = ( text      => 'text_value',
                          textfield => 'text_value',
+                         htmlfield => 'text_value',
                          select    => 'text_value',
                          date      => 'timestamp_value_as_date',
                          timestamp => 'timestamp_value_as_date',
index 2632722adf41e4f762019663decfa8d5012d8b35..9ddb86beabe144e9057c628126428c688d465cf0 100644 (file)
@@ -174,6 +174,7 @@ sub handle_cvars {
 
   my %type_to_column = ( text      => 'text_value',
                          textfield => 'text_value',
+                         htmlfield => 'text_value',
                          select    => 'text_value',
                          date      => 'timestamp_value_as_date',
                          timestamp => 'timestamp_value_as_date',
index 0b124e9fb97c068e12e93bbfcd42c5f45413d64d..193523a85be544e6957a4b74025db00c74203465 100644 (file)
@@ -25,6 +25,7 @@ __PACKAGE__->run_before('load_config', only => [ qw(edit update destroy) ]);
 our %translations = (
   text      => t8('Free-form text'),
   textfield => t8('Text field'),
+  htmlfield => t8('HTML field'),
   number    => t8('Number'),
   date      => t8('Date'),
   timestamp => t8('Timestamp'),
@@ -35,7 +36,7 @@ our %translations = (
   part      => t8('Part'),
 );
 
-our @types = qw(text textfield number date bool select customer vendor part); # timestamp
+our @types = qw(text textfield htmlfield number date bool select customer vendor part); # timestamp
 
 #
 # actions
index f2efeb014911ec1fb69f7ffaa4ee46ea7a019a27..608803abb32fc33a9cd6b3ae5757bfb1d5dd0c63 100644 (file)
@@ -1205,9 +1205,7 @@ sub _pre_render {
 
   $self->{template_args} ||= {};
 
-  $::request->{layout}->add_javascripts('kivi.CustomerVendor.js');
-  $::request->{layout}->add_javascripts('kivi.File.js');
-  $::request->{layout}->add_javascripts('kivi.CustomerVendorTurnover.js');
+  $::request->{layout}->add_javascripts("$_.js") for qw (kivi.CustomerVendor kivi.File kivi.CustomerVendorTurnover ckeditor/ckeditor ckeditor/adapters/jquery);
 
   $self->_setup_form_action_bar;
 }
index 81f15e1d0beaf8b73683a3cf3a950f11ba2e9286..759de322b85623eb9035bfbf8c2764387cae0f5c 100644 (file)
@@ -2127,6 +2127,7 @@ sub generate_doc {
           longdescription => 'html',
           partnotes       => 'html',
           notes           => 'html',
+          $::form->get_variable_content_types_for_cvars,
         },
       );
       1;
index 94862e11b98f16a0a234feadadd155536f181378..702db890788a452ae68ae8771d65b57f5d7829e1 100644 (file)
@@ -248,7 +248,7 @@ sub display_form {
 
   CVar->render_inputs(variables => $params{CUSTOM_VARIABLES}) if @{ $params{CUSTOM_VARIABLES} };
 
-  $::request->layout->use_javascript('kivi.File.js');
+  $::request->layout->use_javascript("$_.js") for qw(kivi.File ckeditor/ckeditor ckeditor/adapters/jquery);
   $self->setup_edit_action_bar(callback => $params{callback});
 
   $self->render('project/form', %params);
index 6ba1c4e74ad27002a580e8721802278a537595e0..afbe2bba6f39254466bf9ad981ad07deaf38b7b1 100644 (file)
@@ -87,6 +87,7 @@ sub action_ajax_edit {
   $self->js
     ->hide('#basic_settings')
     ->after('#basic_settings', $html)
+    ->reinit_widgets
     ->render;
 }
 
@@ -333,7 +334,8 @@ sub setup {
 
   $::auth->assert('requirement_spec_edit');
   $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec);
-  $::request->{layout}->use_javascript("${_}.js")  for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec ckeditor/ckeditor ckeditor/adapters/jquery kivi.Part kivi.CustomerVendor);
+  $::request->{layout}->use_javascript("${_}.js")  for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec ckeditor/ckeditor ckeditor/adapters/jquery kivi.Part kivi.CustomerVendor
+                                                          ckeditor/ckeditor ckeditor/adapters/jquery);
   $self->init_visible_section;
 
   return 1;
index cb6c83158bcba5d96720f0f5b794f4c52b26d936..eeae39aafaf9fb9c640aa002b2ecedcadeae63be 100644 (file)
@@ -52,7 +52,7 @@ sub parse_value {
     return $self->timestamp_value(!defined($unparsed) ? undef : ref($unparsed) eq 'DateTime' ? $unparsed->clone : DateTime->from_kivitendo($unparsed));
   }
 
-  # text, textfield, select
+  # text, textfield, htmlfield and select
   $self->text_value($unparsed);
 }
 
@@ -92,7 +92,7 @@ sub value {
     return $self->timestamp_value ? $self->timestamp_value->clone->truncate(to => 'day') : undef;
   }
 
-  goto &text_value; # text, textfield and select
+  goto &text_value; # text, textfield, htmlfield and select
 }
 
 sub value_as_text {
@@ -116,7 +116,7 @@ sub value_as_text {
     return $object ? $object->displayable_name : '';
   }
 
-  goto &text_value; # text, textfield and select
+  goto &text_value; # text, textfield, htmlfield and select
 }
 
 sub is_valid {
index f8bf7a168564088e20f830087fd9aa98f6a44331..6ba2238af9af37de28101792a8f066663dd00c6f 100644 (file)
@@ -37,8 +37,8 @@ sub validate {
 use constant OPTION_DEFAULTS =>
   {
     MAXLENGTH => 75,
-    WIDTH => 30,
-    HEIGHT => 5,
+    WIDTH     => 225,
+    HEIGHT    => 90,
   };
 
 sub processed_options {
@@ -117,6 +117,7 @@ sub value_col {
     customer  => 'number_value',
     vendor    => 'number_value',
     part      => 'number_value',
+    htmlfield => 'text_value',
     text      => 'text_value',
     textfield => 'text_value',
     select    => 'text_value'
index 8224172bf137ea41921e765b0868ec92432a30a7..b3c4d897a3f4d4cc038111f3c9e1d4b6710db78b 100644 (file)
--- a/SL/DN.pm
+++ b/SL/DN.pm
@@ -1217,6 +1217,7 @@ sub print_original_invoice {
                      longdescription => 'html',
                      partnotes       => 'html',
                      notes           => 'html',
+                     $print_form->get_variable_content_types_for_cvars,
                    },
   );
 
index a01e9a8c669697a0035f97195080945731e03498..29d9d6c137c4bb5568985718693141bbfd0eab5c 100644 (file)
@@ -61,6 +61,7 @@ use SL::DBConnect;
 use SL::DBUtils;
 use SL::DB::AdditionalBillingAddress;
 use SL::DB::Customer;
+use SL::DB::CustomVariableConfig;
 use SL::DB::Default;
 use SL::DB::PaymentTerm;
 use SL::DB::Vendor;
@@ -2713,19 +2714,48 @@ sub lastname_used {
 }
 
 sub get_variable_content_types {
-  my %html_variables  = (
-      longdescription => 'html',
-      partnotes       => 'html',
-      notes           => 'html',
-      orignotes       => 'html',
-      notes1          => 'html',
-      notes2          => 'html',
-      notes3          => 'html',
-      notes4          => 'html',
-      header_text     => 'html',
-      footer_text     => 'html',
+  my ($self) = @_;
+
+  my %html_variables = (
+    longdescription  => 'html',
+    partnotes        => 'html',
+    notes            => 'html',
+    orignotes        => 'html',
+    notes1           => 'html',
+    notes2           => 'html',
+    notes3           => 'html',
+    notes4           => 'html',
+    header_text      => 'html',
+    footer_text      => 'html',
   );
-  return \%html_variables;
+
+  return {
+    %html_variables,
+    $self->get_variable_content_types_for_cvars,
+  };
+}
+
+sub get_variable_content_types_for_cvars {
+  my ($self)       = @_;
+  my $html_configs = SL::DB::Manager::CustomVariableConfig->get_all(where => [ type => 'htmlfield' ]);
+  my %types;
+
+  if (@{ $html_configs }) {
+    my %prefix_by_module = (
+      Contacts => 'cp_cvar_',
+      CT       => 'vc_cvar_',
+      IC       => 'ic_cvar_',
+      Projects => 'project_cvar_',
+      ShipTo   => 'shiptocvar_',
+    );
+
+    foreach my $cfg (@{ $html_configs }) {
+      my $prefix = $prefix_by_module{$cfg->module};
+      $types{$prefix . $cfg->name} = 'html' if $prefix;
+    }
+  }
+
+  return %types;
 }
 
 sub current_date {
index f68fb0a1f8d93cf04a4f46bd722eadba0d7134d1..a54425d837c7b00f5d7370d18748d0aa5177b280 100644 (file)
@@ -27,7 +27,7 @@ sub strip {
   if (!%stripper) {
     %stripper = ( parser => HTML::Parser->new );
 
-    $stripper{parser}->handler(text => sub { $stripper{text} .= $_[1]; });
+    $stripper{parser}->handler(text => sub { $stripper{text} .= ' ' . $_[1]; });
   }
 
   $stripper{text} = '';
@@ -35,6 +35,8 @@ sub strip {
   $stripper{parser}->eof;
 
   $stripper{text} =~ s{\&([^;]+);}{ $entities{$1} || "\&$1;" }eg;
+  $stripper{text} =~ s{^ +| +$}{}g;
+  $stripper{text} =~ s{ {2,}}{ }g;
 
   return delete $stripper{text};
 }
index dd855fc096e42200ecdf4ea8a18f389387870ae6..7d56d940be03243c36facae0759dee93a1f50401 100644 (file)
@@ -3,13 +3,17 @@ package SL::Presenter::Text;
 use strict;
 
 use SL::Presenter::EscapedText qw(escape);
+use SL::HTML::Restrict;
+use SL::HTML::Util;
 
 use Exporter qw(import);
-our @EXPORT_OK = qw(format_man_days simple_format truncate);
+our @EXPORT_OK = qw(format_man_days simple_format truncate restricted_html);
 our %EXPORT_TAGS = (ALL => \@EXPORT_OK);
 
 use Carp;
 
+my $html_cleaner;
+
 sub truncate {
   my ($text, %params) = @_;
 
@@ -43,6 +47,17 @@ sub format_man_days {
   escape($output);
 }
 
+sub restricted_html {
+  my ($value) = @_;
+  $html_cleaner //= SL::HTML::Restrict->create;
+  return $html_cleaner->process($value);
+}
+
+sub stripped_html {
+  my ($value) = @_;
+  return SL::HTML::Util::strip($value);
+}
+
 1;
 __END__
 
@@ -89,6 +104,16 @@ paragraph change: they close the current paragraph tag and start a new
 one. Single newlines are converted to line breaks. Carriage returns
 are removed.
 
+=item C<restricted_html $unsafe_html>
+
+Returns HTML code stripped from unwanted/unsupported content. This is
+done via the module L<SL::HTML::Restrict>.
+
+=item C<stripped_html $html>
+
+Returns the raw text with all HTML tags and comments stripped. This is
+done via L<SL::HTML::Util/strip>.
+
 =back
 
 =head1 BUGS
index 1beeb047798e78ede09f6058d0d9831bad75f4ac..abb6046936e536139b641f65976acd10b994405b 100644 (file)
@@ -85,6 +85,8 @@ sub date_tag                 { return _call_presenter('date_tag',
 sub div_tag                  { return _call_presenter('div_tag',                  @_); }
 sub radio_button_tag         { return _call_presenter('radio_button_tag',         @_); }
 sub img_tag                  { return _call_presenter('img_tag',                  @_); }
+sub restricted_html          { return _call_presenter('restricted_html',          @_); }
+sub stripped_html            { return _call_presenter('stripped_html',            @_); }
 
 sub _set_id_attribute {
   my ($attributes, $name, $unique) = @_;
index 5a66718a9dd5801af70c428db5b3b3e3b2fa8874..dad9acfcf4b7c612643f6f6ce5bd21af12dac0c4 100755 (executable)
@@ -1646,6 +1646,7 @@ $self->{texts} = {
   'Groups valid for this client' => 'Für Mandanten gültige Gruppen',
   'HTML'                        => 'HTML',
   'HTML Templates'              => 'HTML-Vorlagen',
+  'HTML field'                  => 'HTML-Feld',
   'Handling of WebDAV'          => 'Behandlung von WebDAV',
   'Hardcopy'                    => 'Seite drucken',
   'Has item type'               => 'Hat Regeltypen',
@@ -3371,10 +3372,10 @@ $self->{texts} = {
   'Text blocks back'            => 'Textblöcke hinten',
   'Text blocks front'           => 'Textblöcke vorne',
   'Text field'                  => 'Textfeld',
-  'Text field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' => 'Textfelder: \'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 and number variables: The default value will be used as-is.' => 'Textzeilen, Textfelder und Zahlenvariablen: Der Standardwert wird so wie er ist übernommen.',
+  '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.',
   'Texts for invoices'          => 'Texte für Rechnungen',
   'Texts for quotations & orders' => 'Texte für Angebote & Aufträge',
   'That export does not exist.' => 'Dieser Export existiert nicht.',
index 4d5c6635976bca47a914a39e373058f88225318a..59c78fdbe6ea054690dc1d7e64bd5569cd15e6be 100644 (file)
@@ -1645,6 +1645,7 @@ $self->{texts} = {
   'Groups valid for this client' => '',
   'HTML'                        => '',
   'HTML Templates'              => '',
+  'HTML field'                  => '',
   'Handling of WebDAV'          => '',
   'Hardcopy'                    => '',
   'Has item type'               => '',
@@ -3367,10 +3368,10 @@ $self->{texts} = {
   'Text blocks back'            => '',
   'Text blocks front'           => '',
   'Text field'                  => '',
-  'Text 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 and number variables: The default value will be used as-is.' => '',
+  'Text, text field, HTML field and number variables: The default value will be used as-is.' => '',
   'Texts for invoices'          => '',
   'Texts for quotations & orders' => '',
   'That export does not exist.' => '',
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 (file)
index 0000000..45b22f8
--- /dev/null
@@ -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 = <<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;
index d8fb2e5dce8ec8264b208a71f6324a480912e73b..bd08dc6951fe8ea86601c9ad6e42a3fb7a02cfd5 100644 (file)
@@ -59,6 +59,23 @@ $( KiviLatex.required_packages_for_html )$
 
 %\tableofcontents
 
+%%%% Deaktiviertes Beispiel, wie benutzerdefinierte Variablen ausgegeben werden können: %%%%
+%% \newpage
+%%
+%% \section{Benutzerdefinierte Variablen}
+%%
+%% %$ ( FOREACH cvar = rspec.cvars_by_config ) $
+%% Name: $ ( KiviLatex.filter(cvar.config.name) ) $
+%%
+%% Wert:% $ ( IF cvar.config.type == 'htmlfield' ) $
+%% $ ( KiviLatex.filter_html(cvar.value_as_text) ) $
+%% % $ ( ELSE ) $
+%% $ ( KiviLatex.filter(cvar.value_as_text) ) $
+%% % $ ( END ) $
+%%
+%% %$ ( END ) $
+%%%% ENDE Beispiel für benutzerdefinierte Variablen %%%%
+
 %% Versionen
 \newpage
 
index 880106a99b7fe4021fbd2434f6bbe26071bbfda8..e269b8e18b420614626c1026ac9e5a91d66ae836 100644 (file)
@@ -19,6 +19,9 @@
 [%- ELSIF var.type == 'textfield' %]
 <textarea name="[% var_name %]" cols="[% HTML.escape(var.width) %]" rows="[% HTML.escape(var.height) %]">[% HTML.escape(var.value) %]</textarea>
 
+[%- ELSIF var.type == 'htmlfield' %]
+<textarea name="[% var_name %]" cols="[% HTML.escape(var.width) %]" rows="[% HTML.escape(var.height) %]" class="texteditor">[% HTML.escape(var.value) %]</textarea>
+
 [%- ELSIF var.type == 'date' %]
 [% L.date_tag(var_name, var.value) %]
 
index 73731625a63dacbec7cfc7ac85039cc36962f289..984c589b085140511cd8828e04ca4b8abea09f44 100644 (file)
 [% render_cvar_tag_options.import(cols=cvar.var.width, rows=cvar.var.height);
    L.textarea_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %]
 
+[%- ELSIF cvar.var.type == 'htmlfield' %]
+[% render_cvar_tag_options.import(cols=cvar.var.width, rows=cvar.var.height, class="texteditor");
+   L.textarea_tag(cvar_tag_name, L.restricted_html(cvar.value), render_cvar_tag_options) %]
+
 [%- ELSIF cvar.var.type == 'date' %]
 [%- L.date_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %]
 
index d4003717800510ecdd0473e4b9646c790dcc3c2c..2db49e8961a0381a822ca4859abde0d74354b136 100644 (file)
@@ -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,7 +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), class='texteditor', style=style_) %]
 [%- ELSIF ( var.config.type == 'date' ) %]
   [% L.date_tag(var_name, var.value) %]
 [%- ELSIF ( var.config.type == 'timestamp' ) %]
index a03bcd26ebfe1336b3d59f1cba6ead48fd04a7d6..c88711a5fb11e2d29d28dbba72cbea4b5317d475 100644 (file)
   (4) [% 'The default value depends on the variable type:' | $T8 %]
   <br>
   <ul>
-   <li>[%- 'Text, text field and number variables: The default value will be used as-is.' | $T8 %]</li>
+   <li>[%- 'Text, text field, HTML field and number variables: The default value will be used as-is.' | $T8 %]</li>
    <li>[%- 'Boolean variables: If the default value is non-empty then the checkbox will be checked by default and unchecked otherwise.' | $T8 %]</li>
    <li>[%- 'Date and timestamp variables: If the default value equals \'NOW\' then the current date/current timestamp will be used. Otherwise the default value is copied as-is.' | $T8 %]</li>
   </ul>
   <br>
   <ul>
    <li>[%- 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' | $T8 %]</li>
-   <li>[%- 'Text 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>
index af756288cbdeb7c12acbc2f2afe79228b80318b3..54166f1277bb90ea5ead13f648c8c1474b4c4e8a 100644 (file)
@@ -1,4 +1,4 @@
-[%- USE HTML -%][%- USE LxERP -%]
+[%- USE HTML -%][%- USE LxERP -%][%- USE L -%]
 <div id="basic_settings" class="basic-settings-context-menu">
  <h2>
   [% IF SELF.requirement_spec.is_template %]
   [% FOREACH var = cvars %]
    <tr class="listrow">
     <td>[% HTML.escape(var.config.description) %]</td>
-    <td>[% HTML.escape(var.value_as_text) %]</td>
+    <td>
+      [%- IF var.config.type == 'htmlfield' -%]
+        [%- L.restricted_html(var.value_as_text) -%]
+      [%- ELSE -%]
+        [%- HTML.escape(var.value_as_text) -%]
+      [%- END -%]
+    </td>
    </tr>
   [% END %]