Revision b00c1e17
Von Tamino Steinert vor 6 Tagen hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
245 | 245 |
$select_tag_options{empty_title} = t8("Select Variant Property First"); |
246 | 246 |
} |
247 | 247 |
|
248 |
foreach my $variant (@{$self->part->variants}) { |
|
249 |
my $select_tag_name = "add_variant_property_value_" . $variant->id; |
|
250 |
my $new_select_tag = select_tag( |
|
251 |
$select_tag_name, \@options, |
|
252 |
%select_tag_options |
|
253 |
); |
|
254 |
$self->js->replaceWith("#$select_tag_name", $new_select_tag); |
|
255 |
} |
|
248 |
my $new_select_tag = select_tag( |
|
249 |
"variants[].add_variant_property_value", \@options, |
|
250 |
%select_tag_options |
|
251 |
); |
|
252 |
$self->js->replaceWith('[name^="variants[].add_variant_property_value"]', $new_select_tag); |
|
253 |
|
|
254 |
my $new_select_tag_multible = select_tag( |
|
255 |
"add_variant_property_value_for_selected_variants", \@options, |
|
256 |
%select_tag_options |
|
257 |
); |
|
258 |
$self->js->replaceWith("#add_variant_property_value_for_selected_variants", $new_select_tag_multible); |
|
256 | 259 |
|
257 | 260 |
$self->js->render(); |
258 | 261 |
} |
... | ... | |
262 | 265 |
|
263 | 266 |
my $variant_property_id = $::form->{add_variant_property}; |
264 | 267 |
die t8("Please select a variant property") unless ($variant_property_id); |
268 |
my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}}; |
|
265 | 269 |
foreach my $variant (@{$self->part->variants}) { |
266 | 270 |
die t8("Please select a new variant property value for all variants") |
267 |
unless $::form->{"add_variant_property_value_" . $variant->id};
|
|
271 |
unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"};
|
|
268 | 272 |
} |
269 | 273 |
|
270 | 274 |
SL::DB->client->with_transaction(sub { |
... | ... | |
275 | 279 |
foreach my $variant (@{$self->part->variants}) { |
276 | 280 |
SL::DB::VariantPropertyValuePart->new( |
277 | 281 |
part_id => $variant->id, |
278 |
variant_property_value_id => $::form->{"add_variant_property_value_" . $variant->id},
|
|
282 |
variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
|
|
279 | 283 |
)->save; |
280 | 284 |
} |
281 | 285 |
1; |
Auch abrufbar als: Unified diff
Varianten: Schnellbearbeitung von Varianten