Revision 8abdb778
Von Tamino Steinert vor 5 Tagen hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
291 | 291 |
|
292 | 292 |
my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants_properties}}; |
293 | 293 |
|
294 |
my $variant_property_id = delete $::form->{add_variant_property}; |
|
295 |
if ($variant_property_id) { |
|
294 |
my @variant_property_ids = @{$::form->{variant_property_ids} || []}; |
|
295 |
|
|
296 |
my $new_variant_property_id = delete $::form->{add_variant_property}; |
|
297 |
if ($new_variant_property_id) { |
|
298 |
push @variant_property_ids, $new_variant_property_id; |
|
296 | 299 |
foreach my $variant (@{$self->part->variants}) { |
297 | 300 |
my $variant_values = $variant_id_to_values{$variant->id}; |
298 |
$variant_values->{"variant_property_$variant_property_id"} = |
|
301 |
$variant_values->{"variant_property_$new_variant_property_id"} =
|
|
299 | 302 |
delete $variant_values->{"add_variant_property_value"} |
300 | 303 |
or die t8("Please select a new variant property value for all variants"); |
301 | 304 |
} |
302 | 305 |
} |
303 | 306 |
|
304 |
my ($one_variant_id) = keys %variant_id_to_values; |
|
305 |
my %variant_property_ids = |
|
306 |
map { $_ => 1 } |
|
307 |
grep {$_ =~ m/^variant_property_/} |
|
308 |
keys %{$variant_id_to_values{$one_variant_id}}; |
|
309 |
my $variant_property_id_string = join " ", sort keys %variant_property_ids; |
|
307 |
my $variant_property_id_string = join " ", sort @variant_property_ids; |
|
310 | 308 |
|
311 | 309 |
my %variant_property_values_to_variant; |
312 | 310 |
foreach my $variant (@{$self->part->variants}) { |
... | ... | |
315 | 313 |
my $current_variant_property_id_string = |
316 | 314 |
join " ", |
317 | 315 |
sort |
316 |
map {$_ =~ s/^variant_property_//; $_} |
|
318 | 317 |
grep {$_ =~ m/^variant_property_/} |
319 | 318 |
keys %variant_values; |
320 | 319 |
|
... | ... | |
325 | 324 |
my $variant_property_values = |
326 | 325 |
join " ", |
327 | 326 |
sort |
328 |
map {$variant_values{$_}}
|
|
329 |
keys %variant_property_ids;
|
|
327 |
map {$variant_values{"variant_property_$_"}}
|
|
328 |
@variant_property_ids;
|
|
330 | 329 |
|
331 | 330 |
if (defined $variant_property_values_to_variant{$variant_property_values}) { |
332 | 331 |
my $matching_variant = $variant_property_values_to_variant{$variant_property_values}; |
... | ... | |
342 | 341 |
|
343 | 342 |
my @variant_properties = |
344 | 343 |
map {SL::DB::Manager::VariantProperty->find_by(id => $_)} |
345 |
map {$_ =~ s/^variant_property_//; $_} |
|
346 |
keys %variant_property_ids; |
|
344 |
@variant_property_ids; |
|
347 | 345 |
|
348 | 346 |
$self->part->variant_properties(\@variant_properties); |
349 | 347 |
$self->part->save; |
Auch abrufbar als: Unified diff
Varianten: FIX: Eigenschaften ohne Varianten bearbeiten können