From 49fec1549bd7d344dc794fab4a550a8fe732d578 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 31 Mar 2022 15:51:14 +0000 Subject: [PATCH] Bug 30422: Authorities editor update broke the feature added by Bug 20154 This patch corrects JavaScript in authorities templates so that clicking "Edit" on the authority detail page will take you to the authority edit page while keeping the same tab open. This patch also corrects the JavaScript which should have been automatically moving the cursor focus to the first form field when switching tabs in the editor. This patch also adds the "Section" headings which are present in the basic cataloging editor but were not added here at the time of the page's tabs revision. To test, apply the patch and locate an authority record in your catalog. - Without changing tabs, choose "Edit record" from the "Edit" dropdown menu." - The authorities editor should load and display the "Section 0" tab. - Return to the authority detail page and select a tab besides tab 0. - Click back to tab 0. Editing the record at this point should open the editor to Section 0. - Return to the authority detail page. - Click any of the numbered tabs besides tab 0. - Choose "Edit record" from the "Edit" dropdown menu. - When the authorities edit page loads the same tab should be preselected. - Test that when you switch tabs in the authority editor the cursor focus is automatically moved to the first visible input. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers --- .../en/modules/authorities/authorities.tt | 28 +++++++++++-------- .../prog/en/modules/authorities/detail.tt | 8 ++++++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt index 2954c8d934..f454623a9f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -21,17 +21,21 @@ }); var Sticky; $(document).ready(function() { - var tabs = $('#authoritytabs').tabs().bind('show.ui-tabs', function(e, ui) { - $("#"+ui.panel.id+" input:eq(0)").focus(); - }); - - $( "ul.sortable_field", tabs ).sortable(); - $( "ul.sortable_subfield", tabs ).sortable(); + var tabs = $('#authoritytabs').tabs({ + activate: function(e, ui) { + $("#"+ $(ui.newPanel).attr("id") + " .input_marceditor:visible:eq(0)").focus(); + } + }); + + /* On page load, check for location.hash in the page URL */ + var hash = location.hash; + var hashPieces = hash.split('?'); + if( hashPieces[0] !== "" ){ + var activeTab = $("[href='" + hashPieces[0] + "']"); + selectTab(activeTab); + window.scrollTo( 0, 0 ); + } - [% IF tab %] - link = $("a[href='#[% tab | html %]']"); - selectTab( link ); - [% END %] $( "ul.sortable_field", tabs ).sortable(); $( "ul.sortable_subfield", tabs ).sortable(); Sticky = $("#toolbar"); @@ -368,7 +372,9 @@ [% FOREACH BIG_LOO IN BIG_LOOP %]
- + [% IF ( BIG_LOOP.size > 1 ) %] +

Section [% BIG_LOO.number | html %]

+ [% END %] [% previous = "" %] [% FOREACH innerloo IN BIG_LOO.innerloop %] [% IF ( innerloo.tag ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt index b753722ee3..68c493bee4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt @@ -134,6 +134,14 @@ $("#authoritiestabs a:first").tab("show"); } + var editAuth = $("#editAuth"); + var editAuthLink = editAuth.attr("href"); + + $("a[data-toggle='tab']").on("shown.bs.tab", function (e) { + var newTabId = $(this).attr("href"); + editAuth.attr("href", editAuthLink + newTabId ); + }); + [% IF ( displayhierarchy ) %] $('#hierarchies').jstree({ "types" : { -- 2.39.5