https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26635
--- Comment #23 from Agustín Moyano <[email protected]> --- (In reply to Martin Renvoize from comment #22) > (In reply to Tomás Cohen Arazi from comment #21) > > (In reply to Tomás Cohen Arazi from comment #18) > > > (In reply to Martin Renvoize from comment #17) > > > > I'm not sure we need the full AV object expanded.. and I'm thinking if > > > > would > > > > be 'nicer' to access it directly rather than have to do a subsequent > > > > lookup > > > > in JS? > > > > > > I would go for an $av->to_api object, that names things better: > > > lib/lib_opac > > > => description, picking the right one according to the caller context. > > > > What do you think, Agustín? > > I'm onboard with this... embedding them and using to_api to make the naming > clear.. I reckon we could be onto a winner Now it is actually doing a "to_api" on avs when it does: + $avs = $self->_do_api_mapping($avs); and then +sub _do_api_mapping { + my ($self, $json_object) = @_; + # Rename attributes if there's a mapping + if ( $self->can('to_api_mapping') ) { + foreach my $column ( keys %{ $self->to_api_mapping } ) { + my $mapped_column = $self->to_api_mapping->{$column}; + if ( exists $json_object->{$column} + && defined $mapped_column ) + { + # key != undef + $json_object->{$mapped_column} = delete $json_object->{$column}; + } + elsif ( exists $json_object->{$column} + && !defined $mapped_column ) + { + # key == undef + delete $json_object->{$column}; + } + } + } return $json_object; } what we are currently lacking is "to_api_mapping" in AuthorisedValues -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
