Revision 88ad13f9
Von Tamino Steinert vor 6 Tagen hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
864 | 864 |
$self->js->run('kivi.Part.redisplay_items', \@to_sort)->render; |
865 | 865 |
} |
866 | 866 |
|
867 |
sub action_reorder_variants { |
|
868 |
my ($self) = @_; |
|
869 |
|
|
870 |
my $part= $self->part; |
|
871 |
|
|
872 |
my %sort_keys = ( |
|
873 |
partnumber => sub { $_[0]->partnumber }, |
|
874 |
description => sub { $_[0]->description }, |
|
875 |
sellprice => sub { $_[0]->sellprice }, |
|
876 |
lastcost => sub { $_[0]->lastcost }, |
|
877 |
variant_values => sub { $_[0]->variant_values }, |
|
878 |
); |
|
879 |
foreach my $variant_property (@{$part->variant_properties}) { |
|
880 |
my $key = 'variant_property_' . $variant_property->unique_name; |
|
881 |
$sort_keys{$key} = sub { |
|
882 |
$_[0]->get_variant_property_value_by_unique_name($variant_property->unique_name)->value; |
|
883 |
} |
|
884 |
} |
|
885 |
|
|
886 |
my $method = $sort_keys{$::form->{order_by}}; |
|
887 |
|
|
888 |
my @items = $part->variants; |
|
889 |
|
|
890 |
my %variant_id_to_position = |
|
891 |
map {$_->{id} => $_->{position}} |
|
892 |
@{$::form->{variants}}; |
|
893 |
|
|
894 |
my @to_sort = map { { old_pos => $variant_id_to_position{$_->id}, order_by => $method->($_) } } @items; |
|
895 |
if ($::form->{order_by} =~ /^(sellprice|lastcost)$/) { |
|
896 |
if ($::form->{sort_dir}) { |
|
897 |
@to_sort = sort { $a->{order_by} <=> $b->{order_by} } @to_sort; |
|
898 |
} else { |
|
899 |
@to_sort = sort { $b->{order_by} <=> $a->{order_by} } @to_sort; |
|
900 |
} |
|
901 |
} else { |
|
902 |
if ($::form->{sort_dir}) { |
|
903 |
@to_sort = sort { $a->{order_by} cmp $b->{order_by} } @to_sort; |
|
904 |
} else { |
|
905 |
@to_sort = sort { $b->{order_by} cmp $a->{order_by} } @to_sort; |
|
906 |
} |
|
907 |
}; |
|
908 |
|
|
909 |
$self->js->run('kivi.Part.redisplay_variants', \@to_sort)->render; |
|
910 |
} |
|
911 |
|
|
867 | 912 |
sub action_warehouse_changed { |
868 | 913 |
my ($self) = @_; |
869 | 914 |
|
Auch abrufbar als: Unified diff
Varianten: Sortieren der Variantentabelle ermöglicht