From eb4b5f58cf02f50ca180692e8bc15d3e12b578d0 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 16 Aug 2022 11:38:45 +0100 Subject: [PATCH] Bug 31028: Add resolve action This patch adds a resolution workflow to the catalog concerns management page. --- .../prog/en/modules/cataloguing/concerns.tt | 87 +++++++++++++++---- 1 file changed, 69 insertions(+), 18 deletions(-) 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 7ba2c8e442..607cb9ab89 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt @@ -48,7 +48,7 @@ Reported - Concern + Details Title Status Actions @@ -98,6 +98,39 @@ + + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -146,7 +179,14 @@ "orderable": true }, { - "data": "message", + "data": "message:resolution_message", + "render": function(data, type, row, meta) { + let result = ''+row.message+''; + if ( row.resolution_message ) { + result += ''+_('Resolution: %s').format(row.resolution_message)+''; + } + return result; + }, "searchable": true, "orderable": true }, @@ -175,7 +215,10 @@ }, { "data": function( row, type, val, meta ) { - var result = ' '+_("Resolve")+''; + let result = ''; + if ( !row.resolved_date ) { + result += ' '+_("Resolve")+''; + } return result; }, "searchable": false, @@ -193,22 +236,30 @@ concerns.DataTable().columns('3').search('').draw(); }); - $('#table_concerns').on( "click", '.resolve_concern', function () { - var concern_id = decodeURIComponent($(this).data('concern-id')); - - $("#delete_confirm_modal_button").unbind("click").on( "click", function () { - $.ajax({ - method: "PUT", - url: "/api/v1/catalog/concerns/"+concern_id - }).success(function() { - $("#delete_confirm_modal").modal('hide'); - concerns.api().ajax.reload(function (data) { - $("#concern_action_result_dialog").hide(); - $("#concern_delete_success").html(_("Concern #%s deleted successfully.").format(concern_id)).show(); - }); - }).error(function () { - $("#concern_delete_error").html(_("Error deleting concern #%s. Check the logs.").format(concern_id)).show(); + $('#resolveConcernModal').on('show.bs.modal', function (event) { + let modal = $(this); + let button = $(event.relatedTarget); + let concern = button.data('concern'); + + modal.find('.modal-footer input').val(concern) + }); + + $('#resolveConcernModal').on('click', '#resolveConfirm', function(e) { + let concern_id = $('#concern_id').val(); + let params = { notify: $('#resolve_notify').is(":checked"), message: $('#resolve_message').val() }; + + $.ajax({ + url: "/api/v1/catalog/concerns/"+concern_id+"/resolve", + method: "POST", + data: JSON.stringify(params) + }).success(function() { + $("#resolveConcernModal").modal('hide'); + concerns.DataTable().ajax.reload(function (data) { + $("#concern_action_result_dialog").hide(); + $("#concern_delete_success").html(_("Concern #%s deleted successfully.").format(concern_id)).show(); }); + }).error(function () { + $("#concern_resolve_error").html(_("Error resolving concern #%s. Check the logs.").format(concern_id)).show(); }); }); -- 2.20.1