From 70dc91d274b9e59f04f017466efb0bdf914001af Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 25 Oct 2022 16:02:09 +0100 Subject: [PATCH] Bug 31028: Add display to details page This patch adds the display of biblio specific concerns to the biblio detail display page. Test plan 1) Enable the feature as in prior patch test plans 2) Add a concern as per prior patch test plans 3) Confirm that a new tab appears at the bottom of the catalog record details display and all functionality from the concern management page is precent. Signed-off-by: David Nind Signed-off-by: Helen Oliver Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../en/includes/modals/display_ticket.inc | 31 ++++ .../prog/en/modules/catalogue/detail.tt | 125 ++++++++++++++++ .../prog/en/modules/cataloguing/concerns.tt | 137 +----------------- .../prog/en/modules/intranet-main.tt | 2 +- .../prog/js/modals/display_ticket.js | 120 +++++++++++++++ 5 files changed, 285 insertions(+), 130 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc new file mode 100644 index 0000000000..3bf471ae4f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc @@ -0,0 +1,31 @@ + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 713b45be35..6aa948a4d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -299,6 +299,7 @@ [% IF Koha.Preference('AcquisitionDetails') %]
  • Acquisition details
  • [% END %] [% IF suggestions.count %]
  • Suggestion details
  • [% END %] [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]
  • Editions
  • [% END %][% END %] +[% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %]
  • Concerns ([% biblio.tickets.count | html %])
  • [% END %] [% IF ( LocalCoverImages ) %]
  • Images ([% localimages.count || 0 | html %]) @@ -1007,6 +1008,26 @@ Note that permanent location is a code, and location may be an authval. [% END %] [% END %] +[% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %] +
    +
    + Hide resolved + | Show all +
    + + + + + + + + + + +
    ReportedDetailsStatusActions
    +
    +[% END %] + [% IF ( LocalCoverImages ) %]
    [% IF localimages.count %] @@ -1310,6 +1331,10 @@ Note that permanent location is a code, and location may be an authval. [% INCLUDE 'modals/add_catalog_concern.inc' %] [% END %] + [% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %] + [% INCLUDE 'modals/display_ticket.inc' %] + [% END %] + [% MACRO jsinclude BLOCK %] [% INCLUDE 'catalog-strings.inc' %] [% Asset.js("js/catalog.js") | $raw %] @@ -1322,6 +1347,106 @@ Note that permanent location is a code, and location may be an authval. var logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]"; [% Asset.js("js/modals/add_catalog_concern.js") | $raw %] + [% END %] + [% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %] + + [% Asset.js("js/modals/display_ticket.js") | $raw %] [% END %] + [% Asset.js("js/modals/display_ticket.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 3960236332..f60d4d4cae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -172,7 +172,7 @@
    [%# Following statement must be in one line for translatability %] - [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count %] + [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count %]
    [% IF pending_article_requests %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js new file mode 100644 index 0000000000..653f3f9726 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -0,0 +1,120 @@ +$(document).ready(function() { + $('#ticketDetailsModal').on('show.bs.modal', function(event) { + let modal = $(this); + let button = $(event.relatedTarget); + let ticket_id = button.data('concern'); + let resolved = button.data('resolved'); + modal.find('.modal-footer input').val(ticket_id); + + if ( resolved ) { + $('#resolveTicket').hide(); + } else { + $('#resolveTicket').show(); + } + + let detail = $('#detail_' + ticket_id).text(); + + // Display ticket details + let display = '
    '; + display += '
    '; + display += '' + detail + ''; + display += '
    '; + display += '
    '; + display += '' + __("Loading updates . . .") + ''; + display += '
    '; + display += '
    '; + + let details = modal.find('#concern-details'); + details.html(display); + + // Load any existing updates + $.ajax({ + url: "/api/v1/tickets/" + ticket_id + "/updates", + method: "GET", + headers: { + "x-koha-embed": "user" + }, + }).success(function(data) { + let updates_display = $('#concern-updates'); + let updates = ''; + data.forEach(function(item, index) { + if ( item.public ) { + updates += '
    '; + updates += '' + __("Public") + ''; + } + else { + updates += '
    '; + updates += '' + __("Private") + ''; + } + updates += '' + item.message + ''; + updates += '' + $patron_to_html(item.user, { + display_cardnumber: false, + url: true + }) + ' (' + $datetime(item.date) + ')'; + updates += '
    '; + }); + updates_display.html(updates); + }).error(function() { + + }); + + // Clear any previously entered update message + $('#update_message').val(''); + $('#public').prop( "checked", false ); + }); + + $('#ticketDetailsModal').on('click', '#updateTicket', function(e) { + let ticket_id = $('#ticket_id').val(); + let params = { + 'public': $('#public').is(":checked"), + message: $('#update_message').val(), + user_id: logged_in_user_borrowernumber + }; + + $('#comment-spinner').show(); + + $.ajax({ + url: "/api/v1/tickets/" + ticket_id + "/updates", + method: "POST", + data: JSON.stringify(params), + ontentType: "application/json; charset=utf-8" + }).success(function() { + $('#comment-spinner').hide(); + $('#ticketDetailsModal').modal('hide'); + $('#table_concerns').DataTable().ajax.reload(function(data) { + $("#concern_action_result_dialog").hide(); + $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show(); + }); + }).error(function() { + $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs.").format(ticket_id)).show(); + }); + }); + + $('#ticketDetailsModal').on('click', '#resolveTicket', function(e) { + let ticket_id = $('#ticket_id').val(); + let params = { + 'public': $('#public').is(":checked"), + message: $('#update_message').val(), + user_id: logged_in_user_borrowernumber, + state: 'resolved' + }; + + $('#resolve-spinner').show(); + + $.ajax({ + url: "/api/v1/tickets/" + ticket_id + "/updates", + method: "POST", + data: JSON.stringify(params), + ontentType: "application/json; charset=utf-8" + }).success(function() { + $('#resolve-spinner').hide(); + $("#ticketDetailsModal").modal('hide'); + $('#table_concerns').DataTable().ajax.reload(function(data) { + $("#concern_action_result_dialog").hide(); + $("#concern_delete_success").html(__("Concern #%s updated successfully.").format(ticket_id)).show(); + }); + }).error(function() { + $("#concern_update_error").html(__("Error resolving concern #%s. Check the logs.").format(ticket_id)).show(); + }); + }); +}); -- 2.39.5