From c8fe3435de025822655ef88dc5d105f140156237 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 30 May 2020 16:14:37 +0200 Subject: [PATCH] Some lines of the base.js file mysteriously disappeared... --- static/js/base.js | 68 ++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/static/js/base.js b/static/js/base.js index c9a4caff..87a79af2 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -335,39 +335,45 @@ function autoCompleteNote(field_id, note_list_id, notes, notes_display, alias_pr }) }); - $("#validate_" + id).html(""); + });// end getJSON alias + }); +}// end function autocomplete - // Perform a PATCH request to the API in order to update the transaction - // If the user has insufficient rights, an error message will appear - $.ajax({ - "url": "/api/note/transaction/transaction/" + id + "/", - type: "PATCH", - dataType: "json", - headers: { - "X-CSRFTOKEN": CSRF_TOKEN - }, - data: { - "resourcetype": "RecurrentTransaction", - "valid": !validated, - "invalidity_reason": invalidity_reason, - }, - success: function () { - // Refresh jQuery objects - $(".validate").click(de_validate); - refreshBalance(); - // error if this method doesn't exist. Please define it. - refreshHistory(); - }, - error: function (err) { - addMsg("Une erreur est survenue lors de la validation/dévalidation " + - "de cette transaction : " + err.responseText, "danger"); +// When a validate button is clicked, we switch the validation status +function de_validate(id, validated) { + let invalidity_reason = $("#invalidity_reason_" + id).val(); + $("#validate_" + id).html("⟳ ..."); - refreshBalance(); - // error if this method doesn't exist. Please define it. - refreshHistory(); - } - }); - }); + // Perform a PATCH request to the API in order to update the transaction + // If the user has insufficient rights, an error message will appear + $.ajax({ + "url": "/api/note/transaction/transaction/" + id + "/", + type: "PATCH", + dataType: "json", + headers: { + "X-CSRFTOKEN": CSRF_TOKEN + }, + data: { + "resourcetype": "RecurrentTransaction", + "valid": !validated, + "invalidity_reason": invalidity_reason, + }, + success: function () { + // Refresh jQuery objects + $(".validate").click(de_validate); + + refreshBalance(); + // error if this method doesn't exist. Please define it. + refreshHistory(); + }, + error: function (err) { + addMsg("Une erreur est survenue lors de la validation/dévalidation " + + "de cette transaction : " + err.responseText, "danger"); + + refreshBalance(); + // error if this method doesn't exist. Please define it. + refreshHistory(); + } }); }