From d949e4f6010e912c35073cae48447aa0a518be47 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 Content-Type: text/plain; charset=utf-8 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 Signed-off-by: Marcel de Rooy --- .../en/includes/modals/display_ticket.inc | 2 + .../prog/en/modules/cataloguing/concerns.tt | 9 +- .../prog/js/modals/display_ticket.js | 108 +++++++++++++++++- 3 files changed, 116 insertions(+), 3 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 556f827ec0..d0086c8f4a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt @@ -182,6 +182,12 @@ } else { result += _("Open"); } + if (row.assignee) { + result += '' + _("Assigned to: ") + $patron_to_html(row.assignee, { + display_cardnumber: false, + url: true + }) + ''; + } } return result; }, @@ -191,7 +197,7 @@ { "data": function(row, type, val, meta) { let resolved = ( row.resolved_date ) ? true : false; - let result = ' ' + _("Details") + ''; + let result = ' ' + _("Details") + ''; return result; }, "searchable": false, @@ -245,6 +251,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 52be245fd4..0958fa165a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/display_ticket.js @@ -5,6 +5,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) { @@ -18,6 +19,14 @@ $(document).ready(function () { // Display ticket details let display = '
    '; display += '
    '; + if (assignee) { + display += + '' + + __("Assignee") + + ": " + + assignee + + ""; + } display += '' + detail + ""; display += "
    "; display += '
    '; @@ -33,7 +42,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) { @@ -67,12 +76,20 @@ $(document).ready(function () { $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 += "
    "; }); @@ -83,16 +100,103 @@ $(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"), + assignee_id: assignee_id, }; $("#comment-spinner").show(); -- 2.30.2