From 751500f1b8ffe74035044f71cc1ee2b189cee635 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Wed, 1 May 2024 23:33:47 +0200 Subject: [PATCH] Bug 36372: provide an interface to set the source of a record from the staff interface Test plan : - apply Cypress patch - running cypress patch in ktd will fail - apply code patches, cypress tests will pass - open any record in the staff interface - with superlibrarian user, click on the "Edit" button group. - you should be able to click on the "Set record source" below the "Edit record button". - you will be given a form to choose between any defined record source. If none defined there would be a link to configure the record sources. - change a users permissions to have cataloguing permissions but without the "set_record_source" permissions. - login as this forementionned user and go to any record view. - the "Set record source" button should now be greyed out and not possible to click. --- catalogue/detail.pl | 9 +++++ .../prog/en/includes/cat-toolbar.inc | 9 ++++- .../prog/en/includes/modals/record_source.inc | 34 +++++++++++++++++++ .../integration/Catalogue/Detail_spec.ts | 6 ++-- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modals/record_source.inc diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 9a1306cf055..0a1bd963070 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -98,6 +98,15 @@ unless ( $biblio ) { exit; } + +if ( $query->param('set_record_source') eq '1' ) { + $biblio->metadata->set( { record_source_id => $query->param('record_source_id') } )->store; + my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" ); +} + +$template->param( record_sources => Koha::RecordSources->search() ); + my $marc_record = eval { $biblio->metadata->record }; my $invalid_marc_record = $@ || !$marc_record; if ($invalid_marc_record) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 37a7d05ee00..ff0b71a3b02 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -35,7 +35,7 @@ [% END %] -[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] +[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel || CAN_user_editcatalogue_set_record_sources ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
[% INCLUDE modals/place_booking.inc %] + [% INCLUDE modals/record_source.inc %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/record_source.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/record_source.inc new file mode 100644 index 00000000000..73417fa0bca --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/record_source.inc @@ -0,0 +1,34 @@ + + diff --git a/t/cypress/integration/Catalogue/Detail_spec.ts b/t/cypress/integration/Catalogue/Detail_spec.ts index 277f79c14af..918f6aee147 100644 --- a/t/cypress/integration/Catalogue/Detail_spec.ts +++ b/t/cypress/integration/Catalogue/Detail_spec.ts @@ -19,9 +19,9 @@ describe("Set record_source button is present", () => { cy.get("#record_source_id").select("No specified source"); cy.get("button").contains("Set record source").click(); - cy.intercept("GET", '/api/v1/record_sources*').as('listSources') + cy.intercept("GET", "/api/v1/record_sources*").as("listSources"); cy.visit("/cgi-bin/koha/admin/record_sources"); - cy.wait('@listSources') + cy.wait("@listSources"); cy.get("tr:last-child a.delete").click(); cy.contains("Poop"); cy.get("button.approve").click(); @@ -36,4 +36,4 @@ describe("Set record_source button is present", () => { cy.visit("/cgi-bin/koha/catalogue/detail.pl?biblionumber=51"); cy.get("#catalogue_detail_record_source").contains("Poop"); }); -}); \ No newline at end of file +}); -- 2.39.5