Bugzilla – Attachment 173104 Details for
Bug 35287
Add additional fields support to ERM licenses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35287: Preparation: Extend AdditionalFields Mixin
Bug-35287-Preparation-Extend-AdditionalFields-Mixi.patch (text/plain), 3.64 KB, created by
Victor Grousset/tuxayo
on 2024-10-22 01:46:56 UTC
(
hide
)
Description:
Bug 35287: Preparation: Extend AdditionalFields Mixin
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-10-22 01:46:56 UTC
Size:
3.64 KB
patch
obsolete
>From 990cc4ea81ebf7aa6480f10eb6cbaa7e4d73fc4b Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Wed, 8 Nov 2023 11:31:18 -0100 >Subject: [PATCH] Bug 35287: Preparation: Extend AdditionalFields Mixin > >The mixin now implements the extended_attributes method to be utilized by any Koha class that implements the AdditionalFields Mixin and is exposed through the REST API >It also implements a strings_map to be utilized in the same fashion as described above. This is useful because additional fields may be an authorised value > >Signed-off-by: Edith Speller <edith.speller@ukhsa.gov.uk> >Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> >--- > Koha/Object/Mixin/AdditionalFields.pm | 79 +++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > >diff --git a/Koha/Object/Mixin/AdditionalFields.pm b/Koha/Object/Mixin/AdditionalFields.pm >index 90f8ab087f..18e5c5efc7 100644 >--- a/Koha/Object/Mixin/AdditionalFields.pm >+++ b/Koha/Object/Mixin/AdditionalFields.pm >@@ -225,6 +225,85 @@ sub additional_field_values { > return Koha::AdditionalFieldValues->_new_from_dbic( $afv_rs ); > } > >+=head3 extended_attributes >+ >+REST API embed of additional_field_values >+ >+=cut >+ >+sub extended_attributes { >+ my ($self, $extended_attributes) = @_; >+ >+ if ($extended_attributes) { >+ $self->set_additional_fields($extended_attributes); >+ } >+ my $afv_rs = $self->_result->extended_attributes; >+ return Koha::AdditionalFieldValues->_new_from_dbic($afv_rs); >+} >+ >+=head3 strings_map >+ >+Returns a map of column name to string representations including the string, >+the mapping type and the mapping category where appropriate. >+ >+Currently handles additional fields values mappings. >+ >+Accepts a param hashref where the 'public' key denotes whether we want the public >+or staff client strings. >+ >+=cut >+ >+sub strings_map { >+ my ( $self, $params ) = @_; >+ >+ my $afvs = $self->get_additional_field_values_for_template; >+ my $strings = {}; >+ >+ foreach my $af_id ( keys %{$afvs} ) { >+ >+ my $additional_field = Koha::AdditionalFields->find($af_id); >+ my $av_cat = $additional_field->effective_authorised_value_category; >+ my @af_value_arr; >+ my $af_value_str; >+ my $value_to_push; >+ >+ foreach my $av_value ( @{ $afvs->{$af_id} } ) { >+ if ($av_cat) { >+ my $av = Koha::AuthorisedValues->search( >+ { >+ category => $av_cat, >+ authorised_value => $av_value, >+ } >+ ); >+ >+ $value_to_push = >+ $av->count ? $params->{public} ? $av->next->opac_description : $av->next->lib : $av_value; >+ } else { >+ $value_to_push = $av_value; >+ } >+ push @af_value_arr, $value_to_push if $value_to_push; >+ } >+ >+ $af_value_str = join( ", ", @af_value_arr ); >+ >+ push( >+ @{ $strings->{additional_field_values} }, >+ { >+ field_label => $additional_field->name, >+ value_str => $af_value_str, >+ type => $av_cat ? 'av' : 'text', >+ field_id => $af_id, >+ } >+ ); >+ } >+ >+ my @sorted = sort { $a->{field_id} <=> $b->{field_id} } @{ $strings->{additional_field_values} }; >+ my @non_empty = grep { $_->{value_str} ne "" } @sorted; >+ $strings->{additional_field_values} = \@non_empty; >+ >+ return $strings; >+} >+ > =head1 AUTHOR > > Koha Development Team <http://koha-community.org/> >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35287
:
158725
|
158726
|
158727
|
158728
|
158729
|
158730
|
158731
|
158732
|
158733
|
158734
|
159634
|
159635
|
159636
|
159637
|
159638
|
159639
|
159640
|
159641
|
159642
|
159643
|
165451
|
165637
|
165638
|
165639
|
165640
|
165641
|
165642
|
165643
|
165644
|
165645
|
165646
|
165647
|
167681
|
169728
|
169729
|
169730
|
169731
|
169732
|
169733
|
169734
|
169735
|
169736
|
169737
|
170448
|
170753
|
172850
|
172851
|
172852
|
172853
|
172854
|
172855
|
172856
|
172857
|
172858
|
172860
|
172861
|
173022
|
173102
|
173103
| 173104 |
173105
|
173106
|
173107
|
173108
|
173109
|
173110
|
173111
|
173112
|
173113
|
173290