Commit 4b63583 1 parent 37326db commit 4b63583 Copy full SHA for 4b63583
File tree 1 file changed +9
-4
lines changed
lib/MusicBrainz/Server/Edit
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use List::UtilsBy qw( partition_by );
3
3
use Moose::Role;
4
4
use namespace::autoclean;
5
5
6
- use MusicBrainz::Server::Entity::Util::JSON qw( to_json_object ) ;
6
+ use MusicBrainz::Server::Entity::Util::JSON qw( to_json_array ) ;
7
7
use MusicBrainz::Server::Translation ' l' ;
8
8
9
9
sub edit_category { l(' Work' ) }
@@ -21,16 +21,21 @@ sub grouped_attributes_by_type {
21
21
grep { $_ } map { $_ -> {attribute_value_id } } @$attributes
22
22
);
23
23
24
- return partition_by { $_ -> type-> l_name } map {
25
- my $attr = MusicBrainz::Server::Entity::WorkAttribute-> new(
24
+ my %partitioned_attributes = partition_by { $_ -> type-> l_name } map {
25
+ MusicBrainz::Server::Entity::WorkAttribute-> new(
26
26
id => $_ -> {id },
27
27
type_id => $_ -> {attribute_type_id },
28
28
type => $attribute_types -> {$_ -> {attribute_type_id }},
29
29
value => $_ -> {attribute_text } // $attribute_values -> {$_ -> {attribute_value_id }}-> value,
30
30
value_id => $_ -> {attribute_value_id }
31
31
);
32
- $to_json ? to_json_object($attr ) : $attr ;
33
32
} @$attributes ;
33
+
34
+ if ($to_json ) {
35
+ %partitioned_attributes = map { $_ => to_json_array($partitioned_attributes {$_ }) } keys %partitioned_attributes ;
36
+ }
37
+
38
+ return %partitioned_attributes ;
34
39
}
35
40
36
41
1;
You can’t perform that action at this time.
0 commit comments