Bugzilla – Attachment 117149 Details for
Bug 8976
Default sequence of subfields in cataloguing and item editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8976: Sort subfields for authority records
Bug-8976-Sort-subfields-for-authority-records.patch (text/plain), 12.82 KB, created by
Jonathan Druart
on 2021-02-22 13:17:10 UTC
(
hide
)
Description:
Bug 8976: Sort subfields for authority records
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-02-22 13:17:10 UTC
Size:
12.82 KB
patch
obsolete
>From b7b17870a2475dc4c0b60091ca782d14879f9abf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 9 Dec 2020 17:07:36 +0100 >Subject: [PATCH] Bug 8976: Sort subfields for authority records > >Same patch for the authority frameworks/records > >Sponsored-by: Orex Digital > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > C4/AuthoritiesMarc.pm | 12 +++--- > admin/auth_subfields_structure.pl | 15 ++++--- > authorities/authorities.pl | 13 ++++--- > .../data/mysql/atomicupdate/bug_8976.perl | 9 ++++- > installer/data/mysql/kohastructure.sql | 1 + > .../modules/admin/auth_subfields_structure.tt | 39 +++++++++++++++---- > 6 files changed, 65 insertions(+), 24 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index b20293b56a..2d80c417a2 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -471,10 +471,10 @@ sub GetTagsLabels { > $res->{$tag}->{repeatable} = $repeatable; > } > $sth= $dbh->prepare( >-"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl,defaultvalue >+"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl,defaultvalue, display_order > FROM auth_subfield_structure > WHERE authtypecode=? >-ORDER BY tagfield,tagsubfield" >+ORDER BY tagfield, display_order, tagsubfield" > ); > $sth->execute($authtypecode); > >@@ -485,17 +485,18 @@ ORDER BY tagfield,tagsubfield" > my $seealso; > my $hidden; > my $isurl; >- my $link; > my $defaultvalue; >+ my $display_order; > > while ( > ( $tag, $subfield, $liblibrarian, , $libopac, $tab, > $mandatory, $repeatable, $authorised_value, $authtypecode, > $value_builder, $kohafield, $seealso, $hidden, >- $isurl, $defaultvalue, $link ) >+ $isurl, $defaultvalue, $display_order ) > = $sth->fetchrow > ) > { >+ $res->{$tag}->{$subfield}->{subfield} = $subfield; > $res->{$tag}->{$subfield}->{lib} = ($forlibrarian or !$libopac)?$liblibrarian:$libopac; > $res->{$tag}->{$subfield}->{tab} = $tab; > $res->{$tag}->{$subfield}->{mandatory} = $mandatory; >@@ -507,9 +508,10 @@ ORDER BY tagfield,tagsubfield" > $res->{$tag}->{$subfield}->{seealso} = $seealso; > $res->{$tag}->{$subfield}->{hidden} = $hidden; > $res->{$tag}->{$subfield}->{isurl} = $isurl; >- $res->{$tag}->{$subfield}->{link} = $link; > $res->{$tag}->{$subfield}->{defaultvalue} = $defaultvalue; >+ $res->{$tag}->{$subfield}->{display_order} = $display_order; > } >+ > return $res; > } > >diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl >index c68a8aa28e..d7dba6c002 100755 >--- a/admin/auth_subfields_structure.pl >+++ b/admin/auth_subfields_structure.pl >@@ -34,7 +34,7 @@ sub string_search { > my $dbh = C4::Context->dbh; > $searchstring=~ s/\'/\\\'/g; > my @data=split(' ',$searchstring); >- my $sth=$dbh->prepare("Select * from auth_subfield_structure where (tagfield like ? and authtypecode=?) order by tagfield"); >+ my $sth=$dbh->prepare("Select * from auth_subfield_structure where (tagfield like ? and authtypecode=?) order by tagfield, display_order"); > $sth->execute("$searchstring%",$authtypecode); > my $results = $sth->fetchall_arrayref({}); > return (scalar(@$results), $results); >@@ -124,7 +124,7 @@ if ($op eq 'add_form') { > closedir DIR; > > # build values list >- my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and authtypecode=?"); # and tagsubfield='$tagsubfield'"); >+ my $sth=$dbh->prepare("select * from auth_subfield_structure where tagfield=? and authtypecode=? order by display_order"); # and tagsubfield='$tagsubfield'"); > $sth->execute($tagfield,$authtypecode); > my @loop_data = (); > my $i=0; >@@ -189,9 +189,9 @@ if ($op eq 'add_form') { > $template->param(tagfield => "$input->param('tagfield')"); > # my $sth=$dbh->prepare("replace auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl) > # values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >- my $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl,defaultvalue) >- values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >- my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=?, defaultvalue=? >+ my $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl,defaultvalue, display_order) >+ values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >+ my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=?, defaultvalue=?, display_order=? > where authtypecode=? and tagfield=? and tagsubfield=?"); > my @tagsubfield = $input->multi_param('tagsubfield'); > my @liblibrarian = $input->multi_param('liblibrarian'); >@@ -205,6 +205,8 @@ if ($op eq 'add_form') { > my @frameworkcodes = $input->multi_param('frameworkcode'); > my @value_builder =$input->multi_param('value_builder'); > my @defaultvalue = $input->multi_param('defaultvalue'); >+ >+ my $display_order; > for (my $i=0; $i<= $#tagsubfield ; $i++) { > my $tagfield =$input->param('tagfield'); > my $tagsubfield =$tagsubfield[$i]; >@@ -241,6 +243,7 @@ if ($op eq 'add_form') { > $hidden, > $isurl, > $defaultvalue, >+ $display_order->{$tagfield} || 0, > ( > $authtypecode, > $tagfield, >@@ -265,8 +268,10 @@ if ($op eq 'add_form') { > $hidden, > $isurl, > $defaultvalue, >+ display_order => $display_order->{$tagfield} || 0, > ); > } >+ $display_order->{$tagfield}++; > } > } > print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode"); >diff --git a/authorities/authorities.pl b/authorities/authorities.pl >index 7131254b65..103e10698a 100755 >--- a/authorities/authorities.pl >+++ b/authorities/authorities.pl >@@ -477,14 +477,17 @@ sub build_tabs { > } > else { > my @subfields_data; >- foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) { >- next if ( length $subfield != 1 ); >- next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9'; >- next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop ); >+ foreach my $subfield ( >+ sort { $a->{display_order} <=> $b->{display_order} || $a->{subfield} cmp $b->{subfield} } >+ grep { ref($_) && %$_ } # Not a subfield (values for "important", "lib", "mandatory", etc.) or empty >+ values %{ $tagslib->{$tag} } ) >+ { >+ next if $subfield->{hidden} && $subfield->{subfield} ne '9'; >+ next if ( $subfield->{tab} ne $tabloop ); > push( > @subfields_data, > &create_input( >- $tag, $subfield, '', $index_tag, $tabloop, $record, >+ $tag, $subfield->{subfield}, '', $index_tag, $tabloop, $record, > $authorised_values_sth,$input > ) > ); >diff --git a/installer/data/mysql/atomicupdate/bug_8976.perl b/installer/data/mysql/atomicupdate/bug_8976.perl >index a16c555bc0..6c7a1426c4 100644 >--- a/installer/data/mysql/atomicupdate/bug_8976.perl >+++ b/installer/data/mysql/atomicupdate/bug_8976.perl >@@ -8,6 +8,13 @@ if( CheckVersion( $DBversion ) ) { > }); > } > >+ unless ( column_exists( 'auth_subfield_structure', 'display_order' ) ) { >+ $dbh->do(q{ >+ ALTER TABLE auth_subfield_structure >+ ADD COLUMN display_order INT(2) NOT NULL DEFAULT 0 AFTER defaultvalue >+ }); >+ } >+ > # Always end with this (adjust the bug info) >- NewVersion( $DBversion, XXXXX, "Description"); >+ NewVersion( $DBversion, 8976, "Description"); > } >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 033a6f505a..8a8529d08b 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -844,6 +844,7 @@ CREATE TABLE `auth_subfield_structure` ( > `kohafield` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT '', > `frameworkcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', > `defaultvalue` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, >+ `display_order` INT(2) NOT NULL DEFAULT 0, > PRIMARY KEY (`authtypecode`,`tagfield`,`tagsubfield`), > KEY `tab` (`authtypecode`,`tab`), > CONSTRAINT `auth_subfield_structure_ibfk_1` FOREIGN KEY (`authtypecode`) REFERENCES `auth_types` (`authtypecode`) ON DELETE CASCADE ON UPDATE CASCADE >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt >index e3638a24a8..653c3debb7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt >@@ -44,13 +44,13 @@ > <div id="subfieldtabs" class="toptabs numbered"> > <ul> > [% FOREACH loo IN loop %] >- [% IF ( loo.new_subfield ) %] >- <li><a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]">New</a></li> >- [% ELSE %] >- <li><a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]"> >- [% loo.tagsubfield | html %] >- </a></li> >- [% END %] >+ <li id="tab_subfield_[% loo.tagsubfield | html %]"> >+ [% IF ( loo.new_subfield ) %] >+ <a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]">New</a> >+ [% ELSE %] >+ <a href="#sub[% loo.tagsubfield | html_entity %]field" title="[% loo.liblibrarian | html_entity %]">[% loo.tagsubfield | html %]</a> >+ [% END %] >+ </li> > [% END %] > </ul> > >@@ -350,13 +350,36 @@ > [% Asset.js("js/admin-menu.js") | $raw %] > <script> > $(document).ready(function() { >- $('#subfieldtabs').tabs(); > $("#table_authsubfieldstructure").dataTable($.extend(true, {}, dataTablesDefaults, { > "columnDefs": [ > { 'sortable': false, 'targets': [ 'NoSort' ] } > ], >+ aaSorting: [], > paginate: false > })); >+ >+ var tabs = $('#subfieldtabs').tabs(); >+ var current_index; >+ tabs.find( ".ui-tabs-nav" ).sortable({ >+ axis: "x", >+ start: function (e, ui) { >+ current_index = $(ui.item[0]).index(); >+ }, >+ stop: function (e, ui) { >+ var new_index = $(ui.item[0]).index(); >+ if (current_index < new_index) new_index++; >+ var subfield_code = $(ui.item[0]).attr('id').replace( /^tab_subfield_/, ''); >+ var content = $('#sub' + subfield_code + 'field'); >+ var panels = $("#subfieldtabs > div"); >+ if ( new_index < $(panels).size() ){ >+ $(content).insertBefore($("#subfieldtabs > div")[new_index]); >+ } else { >+ $(content).insertAfter($("#subfieldtabs > div")[new_index-1]); >+ } >+ tabs.tabs("refresh"); >+ } >+ }); >+ > }); > </script> > [% END %] >-- >2.20.1
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 8976
:
114345
|
114346
|
114347
|
114348
|
114349
|
114350
|
114351
|
114352
|
114353
|
114354
|
114355
|
114492
|
114493
|
114494
|
114495
|
114496
|
114497
|
114498
|
117147
|
117148
|
117149
|
117150
|
117151
|
117152
|
117153
|
117268
|
117269
|
117270
|
117271
|
117272
|
117273
|
117274
|
117275
|
117276
|
117477
|
117478