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