mirror of https://gitlab.crans.org/bde/nk20
Fix (de)validation of transactions
This commit is contained in:
parent
05fb50965b
commit
5d15b8c613
|
@ -27,7 +27,9 @@ class HistoryTable(tables.Table):
|
||||||
total = tables.Column() # will use Transaction.total() !!
|
total = tables.Column() # will use Transaction.total() !!
|
||||||
|
|
||||||
valid = tables.Column(attrs={"td": {"id": lambda record: "validate_" + str(record.id),
|
valid = tables.Column(attrs={"td": {"id": lambda record: "validate_" + str(record.id),
|
||||||
"class": lambda record: str(record.valid).lower() + ' validate'}})
|
"class": lambda record: str(record.valid).lower() + ' validate',
|
||||||
|
"onclick": lambda record: 'de_validate(' + str(record.id) + ', '
|
||||||
|
+ str(record.valid).lower() + ')'}})
|
||||||
|
|
||||||
def order_total(self, queryset, is_descending):
|
def order_total(self, queryset, is_descending):
|
||||||
# needed for rendering
|
# needed for rendering
|
||||||
|
|
|
@ -192,10 +192,9 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
// When we click on the validate button, the validation status is switched
|
// When a validate button is clicked, we switch the validation status
|
||||||
$(".validate").click(function(e) {
|
function de_validate(id, validated) {
|
||||||
let id = e.target.id.substring(9);
|
$("#validate_" + id).html("<strong style=\"font-size: 16pt;\">⟳ ...</strong>");
|
||||||
let validated = e.target.classList.contains("true");
|
|
||||||
|
|
||||||
// Perform a PATCH request to the API in order to update the transaction
|
// Perform a PATCH request to the API in order to update the transaction
|
||||||
// If the user has insuffisent rights, an error message will appear
|
// If the user has insuffisent rights, an error message will appear
|
||||||
|
@ -211,11 +210,14 @@
|
||||||
"resourcetype": "TemplateTransaction",
|
"resourcetype": "TemplateTransaction",
|
||||||
valid: !validated
|
valid: !validated
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function () {
|
||||||
refreshHistory();
|
refreshHistory();
|
||||||
refreshBalance();
|
refreshBalance();
|
||||||
|
|
||||||
|
// Refresh jQuery objects
|
||||||
|
$(".validate").click(de_validate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue