Bugzilla – Attachment 162358 Details for
Bug 35067
Allow authorised value parent category so categories can be linked and shown together
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35067: Show parent authorised value options in biblio editor
Bug-35067-Show-parent-authorised-value-options-in-.patch (text/plain), 10.22 KB, created by
Aleisha Amohia
on 2024-02-23 00:49:27 UTC
(
hide
)
Description:
Bug 35067: Show parent authorised value options in biblio editor
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2024-02-23 00:49:27 UTC
Size:
10.22 KB
patch
obsolete
>From dcc0b48ac881971c8ef70927eeb6eafe67c8a5aa Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Thu, 22 Feb 2024 02:42:54 +0000 >Subject: [PATCH] Bug 35067: Show parent authorised value options in biblio > editor > >This enhancement adds the option to link a parent authorised value category to a new authorised value category. >When the authorised value category is allocated to a biblio framework subfield, its values, plus it's parent's values, will show as possible options for that subfield in the cataloguing biblio editor. > >To test: > >1) Install database updates and restart services. You may also need to rebuild schema files to capture the change to the database. >2) Go to Koha Administration -> Authorised Values. Notice the table listing authorised values now has a 'Parent category' column. >3) Click the button to add a New category. Notice there is a 'Parent category' dropdown available to set, containing all of the existing authorised value categories. Give your new category a name (for eg, CHILD), and choose any parent category (perhaps LANG). Save. >4) Add a value or set of values to your new category CHILD. >5) Once saved, go back to the main Authorised Values page and confirm your new category CHILD is showing with the correct parent category in the 'Parent category' column. > >6) Go to Koha Administration -> MARC bibliographic frameworks. >7) Click the Actions dropdown for the Default framework and click on MARC structure. >8) Search for a tag and click the Actions dropdown, then choose Edit subfields. For example if testing with the LANG authorised value category, choose the 041 tag and Edit its subfields. >9) Go to the 'a' subfield tab. Go down to 'Other options (choose one)' and assign your new category CHILD to the Authorised value setting. Save. > >10) Go to Cataloguing and add a new record using the default framework. >11) Go to the tag your just edited, i.e. the 041 tag. Click the dropdown to open it. >12) Confirm a heading for your new category CHILD shows with its authorised value(s) listed below it as selectable options. Confirm that the parent category i.e. LANG shows underneath, with its authorised value(s) listed below as selectable options. >13) Confirm you are able to choose a value from either list and save the record as normal. > >Sponsored-by: Education Services Australia SCIS >--- > Koha/UI/Form/Builder/Biblio.pm | 17 ++++++++++--- > .../prog/en/modules/cataloguing/addbiblio.tt | 24 +++++++++++++++++++ > 2 files changed, 38 insertions(+), 3 deletions(-) > >diff --git a/Koha/UI/Form/Builder/Biblio.pm b/Koha/UI/Form/Builder/Biblio.pm >index 340b27b27d2..e1cd810ad3a 100644 >--- a/Koha/UI/Form/Builder/Biblio.pm >+++ b/Koha/UI/Form/Builder/Biblio.pm >@@ -21,6 +21,7 @@ use C4::ClassSource qw( GetClassSources ); > use Koha::DateUtils qw( dt_from_string ); > use Koha::ItemTypes; > use Koha::Libraries; >+use Koha::AuthorisedValueCategories; > > =head1 NAME > >@@ -298,16 +299,19 @@ sub build_authorized_values_list { > > my @authorised_values; > my %authorised_lib; >+ my %authorised_category; > > # builds list, depending on authorised value... > > #---- branch > my $category = $tagslib->{$tag}->{$subfield}->{authorised_value}; >+ my $avc = Koha::AuthorisedValueCategories->find( $category ); > if ( $category eq "branches" ) { > my $libraries = Koha::Libraries->search_filtered({}, {order_by => ['branchname']}); > while ( my $l = $libraries->next ) { > push @authorised_values, $l->branchcode; > $authorised_lib{$l->branchcode} = $l->branchname; >+ $authorised_category{$l->branchcode} = $category; > } > } > elsif ( $category eq "itemtypes" ) { >@@ -318,6 +322,7 @@ sub build_authorized_values_list { > while ( $itemtype = $itemtypes->next ) { > push @authorised_values, $itemtype->itemtype; > $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description; >+ $authorised_category{$itemtype->itemtype} = $category; > } > $value = $itemtype unless ($value); > } >@@ -334,28 +339,32 @@ sub build_authorized_values_list { > ($class_source eq $default_source); > push @authorised_values, $class_source; > $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'}; >+ $authorised_category{$class_source} = $category; > } > $value = $default_source unless $value; > } > else { > my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{branch} : ''; >- my $query = 'SELECT authorised_value, lib FROM authorised_values'; >+ my $query = 'SELECT authorised_value, lib, category FROM authorised_values'; > $query .= ' LEFT JOIN authorised_values_branches ON ( id = av_id )' if $branch_limit; > $query .= ' WHERE category = ?'; > $query .= ' AND ( branchcode = ? OR branchcode IS NULL )' if $branch_limit; >- $query .= ' GROUP BY authorised_value,lib ORDER BY lib, lib_opac'; >+ $query .= ' OR category = ?' if $avc->parent; >+ $query .= ' GROUP BY authorised_value,lib, category ORDER BY lib, lib_opac'; > my $authorised_values_sth = C4::Context->dbh->prepare($query); > > $authorised_values_sth->execute( > $tagslib->{$tag}->{$subfield}->{authorised_value}, > $branch_limit ? $branch_limit : (), >+ $avc->parent ? $avc->parent : (), > ); > > push @authorised_values, ""; > >- while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) { >+ while ( my ( $value, $lib, $this_category ) = $authorised_values_sth->fetchrow_array ) { > push @authorised_values, $value; > $authorised_lib{$value} = $lib; >+ $authorised_category{$value} = $this_category; > } > } > >@@ -366,7 +375,9 @@ sub build_authorized_values_list { > default => $value, > values => \@authorised_values, > labels => \%authorised_lib, >+ avcs => \%authorised_category, > ( ( grep { $_ eq $category } ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $category ) ), >+ avc => $avc, > }; > > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >index b4d1015100f..9a6547a4ba8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -1208,18 +1208,42 @@ $(document).ready(function(){ > [% ELSE %] > <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]"> > [% END %] >+ [% IF mv.avc.parent %] >+ <optgroup label="[% mv.avc.category_name | html %]"> >+ [% END %] >+ > [% SET matched = 0 %] > [% FOREACH aval IN mv.values %] >+ [% IF mv.avcs.$aval == mv.category %] > [% IF aval == mv.default %] > [% SET matched = 1 %] > <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> > [% ELSE %] > <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option> > [% END %] >+ [% END %] > > [% END %] >+ >+ [% IF mv.avc.parent %] >+ </optgroup> >+ <optgroup label="[% mv.avc.parent | html %]"> >+ [% FOREACH aval IN mv.values %] >+ [% IF mv.avcs.$aval != mv.category %] >+ [% IF aval == mv.default %] >+ [% SET matched = 1 %] >+ <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option> >+ [% ELSE %] >+ <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option> >+ [% END %] >+ [% END %] >+ [% END %] >+ </optgroup> >+ [% END %] >+ > [% UNLESS matched # If the current value is not in the authorised value list %] > <option value="[%- mv.default | html -%]" selected="selected">[%- mv.default | html -%] (Not an authorised value)</option> >+ > </select> > <span style="float:right;" title="The current value [% mv.default | html %] is not configured for the authorised value category controlling this subfield"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></span> > [% ELSE %] >-- >2.30.2
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 35067
:
162312
|
162326
|
162327
|
162328
|
162329
|
162355
|
162356
|
162357
|
162358
|
162702
|
162703
|
162704
|
162705
|
162706
|
162708