From b3f5694383b00d1705d79a7bfdc6e4582870a1f6 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/en/modules/intranet-main.tt | 2 +- .../prog/js/modals/display_ticket.js | 119 +++++++++++++++ 5 files changed, 284 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 c5e7330c11..7c95fcb97d 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/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 6ee857b1ca..bb71c500d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -177,7 +177,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..788eaf49e0 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -0,0 +1,119 @@ +$(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(''); + }); + + $('#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