Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e0900c89

Von Moritz Bunkus vor mehr als 3 Jahren hinzugefügt

  • ID e0900c89f30e6a0ebe9c9152cabbe4410e5b3c31
  • Vorgänger e362ec12
  • Nachfolger a7cdf033

Benutzerdef. Var. als HTML-Feld: allgemeine Infrastruktur

Unterschiede anzeigen:

SL/CVar.pm
use SL::DBUtils;
use SL::MoreCommon qw(listify);
use SL::Presenter::Text;
use SL::Util qw(trim);
use SL::DB;
......
} 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);
......
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;
......
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')) {
......
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 ?|;
......
: $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};
}
}
SL/Controller/CustomVariableConfig.pm
our %translations = (
text => t8('Free-form text'),
textfield => t8('Text field'),
htmlfield => t8('HTML field'),
number => t8('Number'),
date => t8('Date'),
timestamp => t8('Timestamp'),
......
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
SL/DB/CustomVariable.pm
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);
}
......
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 {
......
return $object ? $object->displayable_name : '';
}
goto &text_value; # text, textfield and select
goto &text_value; # text, textfield, htmlfield and select
}
sub is_valid {
SL/DB/CustomVariableConfig.pm
customer => 'number_value',
vendor => 'number_value',
part => 'number_value',
htmlfield => 'text_value',
text => 'text_value',
textfield => 'text_value',
select => 'text_value'
templates/webpages/amcvar/render_inputs.html
[%- 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) %]
templates/webpages/amcvar/render_inputs_block.html
[% 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) %]
templates/webpages/common/render_cvar_input.html
[% 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) %]
[%- 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') %]
[%- ELSIF ( var.config.type == 'date' ) %]
[% L.date_tag(var_name, var.value) %]
[%- ELSIF ( var.config.type == 'timestamp' ) %]

Auch abrufbar als: Unified diff