Revision 1ba55874
Von Tamino Steinert vor 5 Monaten hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
|
||
my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants_properties}};
|
||
|
||
my $variant_property_id = delete $::form->{add_variant_property};
|
||
if ($variant_property_id) {
|
||
my @variant_property_ids = @{$::form->{variant_property_ids} || []};
|
||
|
||
my $new_variant_property_id = delete $::form->{add_variant_property};
|
||
if ($new_variant_property_id) {
|
||
push @variant_property_ids, $new_variant_property_id;
|
||
foreach my $variant (@{$self->part->variants}) {
|
||
my $variant_values = $variant_id_to_values{$variant->id};
|
||
$variant_values->{"variant_property_$variant_property_id"} =
|
||
$variant_values->{"variant_property_$new_variant_property_id"} =
|
||
delete $variant_values->{"add_variant_property_value"}
|
||
or die t8("Please select a new variant property value for all variants");
|
||
}
|
||
}
|
||
|
||
my ($one_variant_id) = keys %variant_id_to_values;
|
||
my %variant_property_ids =
|
||
map { $_ => 1 }
|
||
grep {$_ =~ m/^variant_property_/}
|
||
keys %{$variant_id_to_values{$one_variant_id}};
|
||
my $variant_property_id_string = join " ", sort keys %variant_property_ids;
|
||
my $variant_property_id_string = join " ", sort @variant_property_ids;
|
||
|
||
my %variant_property_values_to_variant;
|
||
foreach my $variant (@{$self->part->variants}) {
|
||
... | ... | |
my $current_variant_property_id_string =
|
||
join " ",
|
||
sort
|
||
map {$_ =~ s/^variant_property_//; $_}
|
||
grep {$_ =~ m/^variant_property_/}
|
||
keys %variant_values;
|
||
|
||
... | ... | |
my $variant_property_values =
|
||
join " ",
|
||
sort
|
||
map {$variant_values{$_}}
|
||
keys %variant_property_ids;
|
||
map {$variant_values{"variant_property_$_"}}
|
||
@variant_property_ids;
|
||
|
||
if (defined $variant_property_values_to_variant{$variant_property_values}) {
|
||
my $matching_variant = $variant_property_values_to_variant{$variant_property_values};
|
||
... | ... | |
|
||
my @variant_properties =
|
||
map {SL::DB::Manager::VariantProperty->find_by(id => $_)}
|
||
map {$_ =~ s/^variant_property_//; $_}
|
||
keys %variant_property_ids;
|
||
@variant_property_ids;
|
||
|
||
$self->part->variant_properties(\@variant_properties);
|
||
$self->part->save;
|
templates/design40_webpages/part/_parent_variant.html | ||
---|---|---|
</th>
|
||
[% FOREACH variant_property = SELF.part.variant_properties %]
|
||
<th id="variant_property_variant_property_[% variant_property.id %]_header_id">
|
||
[% L.hidden_tag('variant_property_ids[]', variant_property.id) %]
|
||
<span>
|
||
<a style="color:#e0e0d6"
|
||
href='#' onClick='javascript:kivi.Part.reorder_variants_properties("variant_property_[% variant_property.id %]")'>
|
Auch abrufbar als: Unified diff
Varianten: FIX: Eigenschaften ohne Varianten bearbeiten können