Last tweaks

This commit is contained in:
Ludovic Stephan 2019-12-23 18:55:15 +01:00
parent f7ce2edd87
commit 7438445110
2 changed files with 8 additions and 8 deletions

View file

@ -14,7 +14,7 @@ function KHistory(options = {}) {
if ($(this).hasClass('opegroup')) { if ($(this).hasClass('opegroup')) {
var opegroup = $(this).data('id'); var opegroup = $(this).data('id');
$(this).siblings('.ope').filter(function () { $(this).siblings('.ope').filter(function () {
return $(this).data('opegroup') == opegroup return $(this).data('group') == opegroup
}).addClass('ui-selected'); }).addClass('ui-selected');
} }
}); });
@ -38,14 +38,16 @@ function KHistory(options = {}) {
case 'operation': case 'operation':
for (let ope of opegroup['opes']) { for (let ope of opegroup['opes']) {
var $ope = this._opeHtml(ope, is_cof, trigramme); 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); $opegroup.after($ope);
} }
break; break;
case 'transfer': case 'transfer':
for (let transfer of opegroup['opes']) { for (let transfer of opegroup['opes']) {
var $transfer = this._transferHtml(transfer); var $transfer = this._transferHtml(transfer);
$transfer.data('transfergroup', opegroup['id']); $transfer.data('group', opegroup['id']);
$transfer.data('group_type', type);
$opegroup.after($transfer); $opegroup.after($transfer);
} }
break; break;
@ -268,10 +270,8 @@ function KHistory(options = {}) {
"operations": [], "operations": [],
} }
this.$container.find('.ope.ui-selected').each(function () { this.$container.find('.ope.ui-selected').each(function () {
if ($(this).data("transfergroup")) type = $(this).data("group_type");
opes_to_cancel["transfers"].push($(this).data("id")); opes_to_cancel[`${type}s`].push($(this).data("id"));
else
opes_to_cancel["operations"].push($(this).data("id"));
}); });
if (opes_to_cancel["transfers"].length > 0 && opes_to_cancel["operations"].length > 0) { 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 // Lancer 2 requêtes AJAX et gérer tous les cas d'erreurs possibles est trop complexe

View file

@ -1799,7 +1799,7 @@ def cancel_transfers(request):
.filter(pk__in=transfers) .filter(pk__in=transfers)
.order_by("pk") .order_by("pk")
) )
data["canceled"] = transfers data["canceled"] = list(transfers)
if transfers_already_canceled: if transfers_already_canceled:
data["warnings"]["already_canceled"] = transfers_already_canceled data["warnings"]["already_canceled"] = transfers_already_canceled
return JsonResponse(data) return JsonResponse(data)