From 149bd87ce89989bdfe09dbf2593c5da6f361c8e7 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. --- .../en/includes/modals/display_ticket.inc | 31 ++++ .../prog/en/modules/catalogue/detail.tt | 125 ++++++++++++++++ .../prog/en/modules/cataloguing/concerns.tt | 137 +----------------- .../prog/js/modals/display_ticket.js | 112 ++++++++++++++ 4 files changed, 276 insertions(+), 129 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 c20772c09a..29a9772a72 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 %]) @@ -1005,6 +1006,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 %] @@ -1308,6 +1329,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 %] @@ -1320,6 +1345,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/js/modals/display_ticket.js b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js new file mode 100644 index 0000000000..e65104fb21 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -0,0 +1,112 @@ +$(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) { + updates += '
    '; + 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(''); + }); + + $('#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.20.1