diff --git a/kfet/static/kfet/js/history.js b/kfet/static/kfet/js/history.js index 5608c02f..98bc7a2a 100644 --- a/kfet/static/kfet/js/history.js +++ b/kfet/static/kfet/js/history.js @@ -14,7 +14,7 @@ function KHistory(options = {}) { if ($(this).hasClass('opegroup')) { var opegroup = $(this).data('id'); $(this).siblings('.ope').filter(function () { - return $(this).data('opegroup') == opegroup + return $(this).data('group') == opegroup }).addClass('ui-selected'); } }); @@ -38,14 +38,16 @@ function KHistory(options = {}) { case 'operation': for (let ope of opegroup['opes']) { var $ope = this._opeHtml(ope, is_cof, trigramme); - $ope.data('opegroup', opegroup['id']); + $ope.data('group', opegroup['id']); + $ope.data('group_type', type); $opegroup.after($ope); } break; case 'transfer': for (let transfer of opegroup['opes']) { var $transfer = this._transferHtml(transfer); - $transfer.data('transfergroup', opegroup['id']); + $transfer.data('group', opegroup['id']); + $transfer.data('group_type', type); $opegroup.after($transfer); } break; @@ -268,10 +270,8 @@ function KHistory(options = {}) { "operations": [], } this.$container.find('.ope.ui-selected').each(function () { - if ($(this).data("transfergroup")) - opes_to_cancel["transfers"].push($(this).data("id")); - else - opes_to_cancel["operations"].push($(this).data("id")); + type = $(this).data("group_type"); + opes_to_cancel[`${type}s`].push($(this).data("id")); }); if (opes_to_cancel["transfers"].length > 0 && opes_to_cancel["operations"].length > 0) { // Lancer 2 requêtes AJAX et gérer tous les cas d'erreurs possibles est trop complexe diff --git a/kfet/views.py b/kfet/views.py index 4944546e..e4fd2564 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -1799,7 +1799,7 @@ def cancel_transfers(request): .filter(pk__in=transfers) .order_by("pk") ) - data["canceled"] = transfers + data["canceled"] = list(transfers) if transfers_already_canceled: data["warnings"]["already_canceled"] = transfers_already_canceled return JsonResponse(data)