From 7635ed753582a9fce2842c07fb6f071f4e512ac9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 29 Dec 2023 11:53:25 +0000 Subject: [PATCH] Bug 35657: Add option to set assignee during update This patch exposes the UI to allow setting assignee from the ticket update modal. Test plan 1) Apply the patches and run the database updates 2) Enable catalog concerns - `CatalogConcerns` or `OPACCatalogConcerns` 3) Submit a catalog concern via the OPAC or Staff client biblio page 4) Navigate to the concerns management page 'Cataloging > Catalog concerns' 5) Note there is no assignee displayed in the status field for your new concern. 6) Click the concern to view it's details 7) Note that in the modal there is now a new 'Change assignee' option 8) Use this new option to search for and assign a librarian to the concern. 9) Submit the update 10) Your assignee should now appear in the 'status' data field in the table 11) Clicking through to details again, you should see when the assignee was set and should also be able to re-assign it Signed-off-by: Paul Derscheid --- .../en/includes/modals/display_ticket.inc | 2 + .../prog/en/modules/cataloguing/concerns.tt | 9 +- .../prog/js/modals/display_ticket.js | 102 +++++++++++++++++- 3 files changed, 109 insertions(+), 4 deletions(-) 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 index 5a3479a0de..8b4768c525 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/display_ticket.inc @@ -20,6 +20,8 @@
  • + +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt index 5826fe2cee..ac0f04e0f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt @@ -181,6 +181,12 @@ } else { result += _("Open"); } + if (row.assignee) { + result += '' + _("Assigned to: ") + $patron_to_html(row.assignee, { + display_cardnumber: false, + url: true + }) + ''; + } } return result; }, @@ -190,7 +196,7 @@ { "data": function(row, type, val, meta) { let resolved = ( row.resolved_date ) ? true : false; - let result = ' ' + _("Details") + ''; + let result = ' ' + _("Details") + ''; return result; }, "searchable": false, @@ -244,6 +250,7 @@ [% END %] }); + [% INCLUDE 'select2.inc' %] [% 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 index 61fecbea3a..3e2c908cef 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -4,6 +4,7 @@ $(document).ready(function() { let button = $(event.relatedTarget); let ticket_id = button.data('concern'); let resolved = button.data('resolved'); + let assignee = button.data('assignee'); modal.find('.modal-footer input').val(ticket_id); if ( resolved ) { @@ -17,6 +18,9 @@ $(document).ready(function() { // Display ticket details let display = '
    '; display += '
    '; + if (assignee) { + display += '' + __("Assignee") + ': ' + assignee + ''; + } display += '' + detail + ''; display += '
    '; display += '
    '; @@ -32,7 +36,7 @@ $(document).ready(function() { url: "/api/v1/tickets/" + ticket_id + "/updates", method: "GET", headers: { - "x-koha-embed": [ "user", "+strings" ] + "x-koha-embed": [ "user", "assignee", "+strings" ] }, }).success(function(data) { let updates_display = $('#concern-updates'); @@ -52,10 +56,18 @@ $(document).ready(function() { url: true }) + ' (' + $datetime(item.date) + ')'; if ( item.status ) { - updates += ''; + updates += ''; updates += item._strings.status ? escape_str(item._strings.status.str) : ""; updates += '' } + if ( item.assignee ) { + updates += ''; + updates += $patron_to_html(item.assignee, { + display_cardnumber: false, + url: true + }); + updates += '' + } updates += ''; updates += '
    '; }); @@ -67,16 +79,100 @@ $(document).ready(function() { // Clear any previously entered update message $('#update_message').val(''); $('#public').prop( "checked", false ); + + // Patron select2 + $("#assignee_id").kohaSelect({ + dropdownParent: $(".modal-content", "#ticketDetailsModal"), + width: '50%', + dropdownAutoWidth: true, + allowClear: true, + minimumInputLength: 3, + ajax: { + url: '/api/v1/patrons', + delay: 250, + dataType: 'json', + headers: { + "x-koha-embed": "library" + }, + data: function(params) { + let q = buildPatronSearchQuery(params.term); + let query = { + 'q': JSON.stringify(q), + '_page': params.page, + '_order_by': '+me.surname,+me.firstname', + }; + return query; + }, + processResults: function(data, params) { + let results = []; + data.results.forEach(function(patron) { + patron.id = patron.patron_id; + results.push(patron); + }); + return { + "results": results, "pagination": { "more": data.pagination.more } + }; + }, + }, + templateResult: function (patron) { + if (patron.library_id == loggedInLibrary) { + loggedInClass = "ac-currentlibrary"; + } else { + loggedInClass = ""; + } + + let $patron = $("") + .append( + "" + + (patron.surname + ? escape_str(patron.surname) + ", " + : "") + + (patron.firstname + ? escape_str(patron.firstname) + " " + : "") + + (patron.cardnumber + ? " (" + escape_str(patron.cardnumber) + ")" + : "") + + "" + + (patron.date_of_birth + ? ' ' + + $get_age(patron.date_of_birth) + + " " + + __("years") + + "" + : "") + + (patron.library ? + " " + + escape_str(patron.library.name) + + "" + : "") + + "" + ) + .addClass(loggedInClass); + return $patron; + }, + templateSelection: function (patron) { + if (!patron.surname) { + return patron.text; + } + return ( + escape_str(patron.surname) + ", " + escape_str(patron.firstname) + ); + }, + placeholder: "Search for a patron" + }); }); $('#ticketDetailsModal').on('click', '.updateSubmit', function(e) { let clicked = $(this); let ticket_id = $('#ticket_id').val(); + let assignee_id = $('#assignee_id').val(); let params = { 'public': $('#public').is(":checked"), 'message': $('#update_message').val(), 'user_id': logged_in_user_borrowernumber, - 'status': clicked.data('status') + 'status': clicked.data('status'), + 'assignee_id': assignee_id }; $('#comment-spinner').show(); -- 2.44.0