Minor fixes on consumptions page

This commit is contained in:
Yohann D'ANELLO 2020-03-13 09:26:39 +01:00
parent 56a2d482c9
commit a1f8ef721a
6 changed files with 35 additions and 17 deletions

View File

@ -17,8 +17,8 @@ class HistoryTable(tables.Table):
'table table-condensed table-striped table-hover' 'table table-condensed table-striped table-hover'
} }
model = Transaction model = Transaction
exclude = ("polymorphic_ctype", ) exclude = ("id", "polymorphic_ctype", )
order_by = ('-id', ) order_by = ('-created_at', )
template_name = 'django_tables2/bootstrap4.html' template_name = 'django_tables2/bootstrap4.html'
sequence = ('...', 'total', 'valid') sequence = ('...', 'total', 'valid')

View File

@ -115,7 +115,7 @@ class ConsoView(LoginRequiredMixin, SingleTableView):
# Transaction history table # Transaction history table
table_class = HistoryTable table_class = HistoryTable
table_pagination = {"per_page": 10} table_pagination = {"per_page": 20}
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
""" """

View File

@ -23,14 +23,14 @@ $(document).ready(function() {
}); });
}); });
let notes = []; notes = [];
let notes_display = []; notes_display = [];
let buttons = []; buttons = [];
// When the user searches an alias, we update the auto-completion // When the user searches an alias, we update the auto-completion
autoCompleteNote("note", "alias_matched", "note_list", notes, notes_display, autoCompleteNote("note", "alias_matched", "note_list", notes, notes_display,
"alias", "note", "user_note", "profile_pic", function() { "alias", "note", "user_note", "profile_pic", function() {
if (buttons.length > 0) { if (buttons.length > 0 && $("#single_conso").is(":checked")) {
consumeAll(); consumeAll();
return false; return false;
} }
@ -58,7 +58,7 @@ function addConso(dest, amount, type, category_id, category_name, template_id, t
if (button == null) if (button == null)
buttons.push([dest, 1, amount, type, category_id, category_name, template_id, template_name]); buttons.push([dest, 1, amount, type, category_id, category_name, template_id, template_name]);
if ($("#double_conso:checked").length > 0) { if ($("#double_conso").is(":checked")) {
let html = ""; let html = "";
buttons.forEach(function(button) { buttons.forEach(function(button) {
html += li("conso_button_" + button[6], button[7] html += li("conso_button_" + button[6], button[7]

View File

@ -161,6 +161,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
</div> </div>
</footer> </footer>
<script>
CSRF_TOKEN = "{{ csrf_token }}";
</script>
{% block extrajavascript %} {% block extrajavascript %}
{% endblock extrajavascript %} {% endblock extrajavascript %}
</body> </body>

View File

@ -143,14 +143,18 @@
{% block extrajavascript %} {% block extrajavascript %}
<script type="text/javascript" src="/static/js/consos.js"></script> <script type="text/javascript" src="/static/js/consos.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var CSRF_TOKEN = "{{ csrf_token }}";
$("#double_conso").click(function() { $("#double_conso").click(function() {
$("#consos_list_div").show(); $("#consos_list_div").show();
$("#infos_div").attr('class', 'col-sm-5 col-xl-6'); $("#infos_div").attr('class', 'col-sm-5 col-xl-6');
$("#note_infos_div").attr('class', 'col-xl-3'); $("#note_infos_div").attr('class', 'col-xl-3');
$("#user_select_div").attr('class', 'col-xl-4'); $("#user_select_div").attr('class', 'col-xl-4');
$("#buttons_div").attr('class', 'col-sm-7 col-xl-6'); $("#buttons_div").attr('class', 'col-sm-7 col-xl-6');
if (buttons.length > 0) {
let note_list_obj = $("#note_list");
$("#consos_list").html(note_list_obj.html());
note_list_obj.html("");
}
}); });
$("#single_conso").click(function() { $("#single_conso").click(function() {
@ -159,6 +163,18 @@
$("#note_infos_div").attr('class', 'col-xl-5'); $("#note_infos_div").attr('class', 'col-xl-5');
$("#user_select_div").attr('class', 'col-xl-7'); $("#user_select_div").attr('class', 'col-xl-7');
$("#buttons_div").attr('class', 'col-sm-7 col-md-8'); $("#buttons_div").attr('class', 'col-sm-7 col-md-8');
if (buttons.length > 0) {
if (notes_display.length === 0) {
let consos_list_obj = $("#consos_list");
$("#note_list").html(consos_list_obj.html());
consos_list_obj.html("");
}
else {
buttons.length = 0;
$("#consos_list").html("");
}
}
}); });
$("#consos_list_div").hide(); $("#consos_list_div").hide();

View File

@ -71,13 +71,11 @@ SPDX-License-Identifier: GPL-2.0-or-later
{% block extrajavascript %} {% block extrajavascript %}
<script> <script>
var CSRF_TOKEN = "{{ csrf_token }}"; sources = [];
sources_notes_display = [];
var sources = []; dests = [];
var sources_notes_display = []; dests_notes_display = [];
var dests = []; transfer_mode = false;
var dests_notes_display = [];
var transfer_mode = false;
$(document).ready(function() { $(document).ready(function() {
autoCompleteNote("source_note", "source_alias_matched", "source_note_list", sources, sources_notes_display, autoCompleteNote("source_note", "source_alias_matched", "source_note_list", sources, sources_notes_display,