mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-25 11:37:22 +02:00
Validation/devalidation of a transaction on profile page
This commit is contained in:
committed by
Bombar Maxime
parent
da12733508
commit
a1f37f0eea
@ -229,3 +229,42 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// When a validate button is clicked, we switch the validation status
|
||||
function de_validate(id, validated) {
|
||||
$("#validate_" + id).html("<strong style=\"font-size: 16pt;\">⟳ ...</strong>");
|
||||
|
||||
// Perform a PATCH request to the API in order to update the transaction
|
||||
// If the user has insuffisent rights, an error message will appear
|
||||
$.ajax({
|
||||
"url": "/api/note/transaction/transaction/" + id + "/",
|
||||
type: "PATCH",
|
||||
dataType: "json",
|
||||
headers: {
|
||||
"X-CSRFTOKEN": CSRF_TOKEN
|
||||
},
|
||||
data: {
|
||||
"resourcetype": "TemplateTransaction",
|
||||
valid: !validated
|
||||
},
|
||||
success: function () {
|
||||
// Refresh jQuery objects
|
||||
$(".validate").click(de_validate);
|
||||
|
||||
refreshBalance();
|
||||
// error if this method doesn't exist. Please define it.
|
||||
refreshHistory();
|
||||
},
|
||||
error: function(err) {
|
||||
let msgDiv = $("#messages");
|
||||
let html = msgDiv.html();
|
||||
html += "<div class='alert alert-danger'>Une erreur est survenue lors de la validation/dévalidation " +
|
||||
"de cette transaction : " + err.responseText + "</div>";
|
||||
msgDiv.html(html);
|
||||
|
||||
refreshBalance();
|
||||
// error if this method doesn't exist. Please define it.
|
||||
refreshHistory();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -177,31 +177,3 @@ function consume(source, dest, quantity, amount, reason, type, category, templat
|
||||
refreshBalance();
|
||||
});
|
||||
}
|
||||
|
||||
// When a validate button is clicked, we switch the validation status
|
||||
function de_validate(id, validated) {
|
||||
$("#validate_" + id).html("<strong style=\"font-size: 16pt;\">⟳ ...</strong>");
|
||||
|
||||
// Perform a PATCH request to the API in order to update the transaction
|
||||
// If the user has insuffisent rights, an error message will appear
|
||||
// TODO: Add this error message
|
||||
$.ajax({
|
||||
"url": "/api/note/transaction/transaction/" + id + "/",
|
||||
type: "PATCH",
|
||||
dataType: "json",
|
||||
headers: {
|
||||
"X-CSRFTOKEN": CSRF_TOKEN
|
||||
},
|
||||
data: {
|
||||
"resourcetype": "TemplateTransaction",
|
||||
valid: !validated
|
||||
},
|
||||
success: function () {
|
||||
refreshHistory();
|
||||
refreshBalance();
|
||||
|
||||
// Refresh jQuery objects
|
||||
$(".validate").click(de_validate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user