Revision d3c4f19b
Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt
SL/Controller/CsvImport/Base.pm | ||
---|---|---|
288 | 288 |
sub handle_cvars { |
289 | 289 |
my ($self, $entry) = @_; |
290 | 290 |
|
291 |
my $object = $entry->{object_to_save} || $entry->{object}; |
|
292 |
return unless $object->can('cvars_by_config'); |
|
293 |
|
|
291 | 294 |
my %type_to_column = ( text => 'text_value', |
292 | 295 |
textfield => 'text_value', |
293 | 296 |
select => 'text_value', |
... | ... | |
296 | 299 |
number => 'number_value_as_number', |
297 | 300 |
bool => 'bool_value' ); |
298 | 301 |
|
302 |
# autovivify all cvars (cvars_by_config will do that for us) |
|
299 | 303 |
my @cvars; |
300 | 304 |
my %changed_cvars; |
301 | 305 |
foreach my $config (@{ $self->all_cvar_configs }) { |
... | ... | |
310 | 314 |
} |
311 | 315 |
|
312 | 316 |
# merge existing with new cvars. swap every existing with the imported one, push the rest |
313 |
if (@cvars) { |
|
314 |
my $object = $entry->{object_to_save} || $entry->{object}; |
|
315 |
my @orig_cvars = $object->custom_variables; |
|
316 |
for (@orig_cvars) { |
|
317 |
$_ = $changed_cvars{ $_->config->name } if $changed_cvars{ $_->config->name }; |
|
318 |
delete $changed_cvars{ $_->config->name }; |
|
319 |
} |
|
320 |
push @orig_cvars, values %changed_cvars; |
|
321 |
|
|
322 |
$object->custom_variables(\@orig_cvars); |
|
317 |
my @orig_cvars = @{ $object->cvars_by_config }; |
|
318 |
for (@orig_cvars) { |
|
319 |
$_ = $changed_cvars{ $_->config->name } if $changed_cvars{ $_->config->name }; |
|
320 |
delete $changed_cvars{ $_->config->name }; |
|
323 | 321 |
} |
322 |
push @orig_cvars, values %changed_cvars; |
|
323 |
$object->custom_variables(\@orig_cvars); |
|
324 | 324 |
} |
325 | 325 |
|
326 | 326 |
sub init_profile { |
Auch abrufbar als: Unified diff
CsvImport: Bei Imports ohne CVars deren Standard setzen, wenn vorhanden.