Revision e0900c89
Von Moritz Bunkus vor etwa 3 Jahren hinzugefügt
SL/CVar.pm | ||
---|---|---|
10 | 10 |
|
11 | 11 |
use SL::DBUtils; |
12 | 12 |
use SL::MoreCommon qw(listify); |
13 |
use SL::Presenter::Text; |
|
13 | 14 |
use SL::Util qw(trim); |
14 | 15 |
use SL::DB; |
15 | 16 |
|
... | ... | |
46 | 47 |
} elsif ($config->{type} eq 'number') { |
47 | 48 |
$config->{precision} = $1 if ($config->{options} =~ m/precision=(\d+)/i); |
48 | 49 |
|
49 |
} elsif ($config->{type} eq 'textfield') {
|
|
50 |
} elsif ($config->{type} =~ m{^(?:html|text)field$}) {
|
|
50 | 51 |
$config->{width} = 30; |
51 | 52 |
$config->{height} = 5; |
52 | 53 |
$config->{width} = $1 if ($config->{options} =~ m/width=(\d+)/i); |
... | ... | |
112 | 113 |
my $custom_variables = $self->get_configs(module => $params{module}); |
113 | 114 |
|
114 | 115 |
foreach my $cvar (@{ $custom_variables }) { |
115 |
if ($cvar->{type} eq 'textfield') {
|
|
116 |
if ($cvar->{type} =~ m{^(?:html|text)field}) {
|
|
116 | 117 |
$cvar->{width} = 30; |
117 | 118 |
$cvar->{height} = 5; |
118 | 119 |
|
... | ... | |
271 | 272 |
|
272 | 273 |
my $value = $params{variables}->{"$params{name_prefix}cvar_$config->{name}$params{name_postfix}"}; |
273 | 274 |
|
274 |
if (($config->{type} eq 'text') || ($config->{type} eq 'textfield') || ($config->{type} eq 'select')) {
|
|
275 |
if (any { $config->{type} eq $_ } qw(text textfield htmlfield select)) {
|
|
275 | 276 |
push @values, undef, undef, $value, undef; |
276 | 277 |
|
277 | 278 |
} elsif (($config->{type} eq 'date') || ($config->{type} eq 'timestamp')) { |
... | ... | |
375 | 376 |
|
376 | 377 |
my (@sub_values, @sub_where, $not); |
377 | 378 |
|
378 |
if (($config->{type} eq 'text') || ($config->{type} eq 'textfield')) {
|
|
379 |
if (any { $config->{type} eq $_ } qw(text textfield htmlfield)) {
|
|
379 | 380 |
next unless ($params{filter}->{$name}); |
380 | 381 |
|
381 | 382 |
push @sub_where, qq|cvar.text_value ILIKE ?|; |
... | ... | |
525 | 526 |
: $cfg->{type} eq 'vendor' ? (SL::DB::Manager::Vendor->find_by(id => 1*$ref->{number_value}) || SL::DB::Vendor->new)->name |
526 | 527 |
: $cfg->{type} eq 'part' ? (SL::DB::Manager::Part->find_by(id => 1*$ref->{number_value}) || SL::DB::Part->new)->partnumber |
527 | 528 |
: $cfg->{type} eq 'bool' ? ($ref->{bool_value} ? $locale->text('Yes') : $locale->text('No')) |
529 |
: $cfg->{type} eq 'htmlfield' ? SL::Presenter::Text::stripped_html($ref->{text_value}) |
|
528 | 530 |
: $ref->{text_value}; |
529 | 531 |
} |
530 | 532 |
} |
SL/Controller/CustomVariableConfig.pm | ||
---|---|---|
25 | 25 |
our %translations = ( |
26 | 26 |
text => t8('Free-form text'), |
27 | 27 |
textfield => t8('Text field'), |
28 |
htmlfield => t8('HTML field'), |
|
28 | 29 |
number => t8('Number'), |
29 | 30 |
date => t8('Date'), |
30 | 31 |
timestamp => t8('Timestamp'), |
... | ... | |
35 | 36 |
part => t8('Part'), |
36 | 37 |
); |
37 | 38 |
|
38 |
our @types = qw(text textfield number date bool select customer vendor part); # timestamp |
|
39 |
our @types = qw(text textfield htmlfield number date bool select customer vendor part); # timestamp
|
|
39 | 40 |
|
40 | 41 |
# |
41 | 42 |
# actions |
SL/DB/CustomVariable.pm | ||
---|---|---|
52 | 52 |
return $self->timestamp_value(!defined($unparsed) ? undef : ref($unparsed) eq 'DateTime' ? $unparsed->clone : DateTime->from_kivitendo($unparsed)); |
53 | 53 |
} |
54 | 54 |
|
55 |
# text, textfield, select |
|
55 |
# text, textfield, htmlfield and select
|
|
56 | 56 |
$self->text_value($unparsed); |
57 | 57 |
} |
58 | 58 |
|
... | ... | |
92 | 92 |
return $self->timestamp_value ? $self->timestamp_value->clone->truncate(to => 'day') : undef; |
93 | 93 |
} |
94 | 94 |
|
95 |
goto &text_value; # text, textfield and select |
|
95 |
goto &text_value; # text, textfield, htmlfield and select
|
|
96 | 96 |
} |
97 | 97 |
|
98 | 98 |
sub value_as_text { |
... | ... | |
116 | 116 |
return $object ? $object->displayable_name : ''; |
117 | 117 |
} |
118 | 118 |
|
119 |
goto &text_value; # text, textfield and select |
|
119 |
goto &text_value; # text, textfield, htmlfield and select
|
|
120 | 120 |
} |
121 | 121 |
|
122 | 122 |
sub is_valid { |
SL/DB/CustomVariableConfig.pm | ||
---|---|---|
117 | 117 |
customer => 'number_value', |
118 | 118 |
vendor => 'number_value', |
119 | 119 |
part => 'number_value', |
120 |
htmlfield => 'text_value', |
|
120 | 121 |
text => 'text_value', |
121 | 122 |
textfield => 'text_value', |
122 | 123 |
select => 'text_value' |
templates/webpages/amcvar/render_inputs.html | ||
---|---|---|
19 | 19 |
[%- ELSIF var.type == 'textfield' %] |
20 | 20 |
<textarea name="[% var_name %]" cols="[% HTML.escape(var.width) %]" rows="[% HTML.escape(var.height) %]">[% HTML.escape(var.value) %]</textarea> |
21 | 21 |
|
22 |
[%- ELSIF var.type == 'htmlfield' %] |
|
23 |
<textarea name="[% var_name %]" cols="[% HTML.escape(var.width) %]" rows="[% HTML.escape(var.height) %]" class="texteditor">[% HTML.escape(var.value) %]</textarea> |
|
24 |
|
|
22 | 25 |
[%- ELSIF var.type == 'date' %] |
23 | 26 |
[% L.date_tag(var_name, var.value) %] |
24 | 27 |
|
templates/webpages/amcvar/render_inputs_block.html | ||
---|---|---|
27 | 27 |
[% render_cvar_tag_options.import(cols=cvar.var.width, rows=cvar.var.height); |
28 | 28 |
L.textarea_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
29 | 29 |
|
30 |
[%- ELSIF cvar.var.type == 'htmlfield' %] |
|
31 |
[% render_cvar_tag_options.import(cols=cvar.var.width, rows=cvar.var.height, class="texteditor"); |
|
32 |
L.textarea_tag(cvar_tag_name, L.restricted_html(cvar.value), render_cvar_tag_options) %] |
|
33 |
|
|
30 | 34 |
[%- ELSIF cvar.var.type == 'date' %] |
31 | 35 |
[%- L.date_tag(cvar_tag_name, cvar.value, render_cvar_tag_options) %] |
32 | 36 |
|
templates/webpages/common/render_cvar_input.html | ||
---|---|---|
16 | 16 |
[% L.checkbox_tag(var_name, checked = var.value, for_submit = 1) %] |
17 | 17 |
[%- ELSIF ( var.config .type == 'textfield' ) %] |
18 | 18 |
[% L.textarea_tag(var_name, var.value, cols = var.config.processed_options.WIDTH, rows = var.config.processed_options.HEIGHT) %] |
19 |
[%- ELSIF ( var.config .type == 'htmlfield' ) %] |
|
20 |
[% L.textarea_tag(var_name, L.restricted_html(var.value), cols = var.config.processed_options.WIDTH, rows = var.config.processed_options.HEIGHT, class='texteditor') %] |
|
19 | 21 |
[%- ELSIF ( var.config.type == 'date' ) %] |
20 | 22 |
[% L.date_tag(var_name, var.value) %] |
21 | 23 |
[%- ELSIF ( var.config.type == 'timestamp' ) %] |
Auch abrufbar als: Unified diff
Benutzerdef. Var. als HTML-Feld: allgemeine Infrastruktur