From a1f8ef721a2188ca8caa29069d6cd3d046daa030 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 13 Mar 2020 09:26:39 +0100 Subject: [PATCH] Minor fixes on consumptions page --- apps/note/tables.py | 4 ++-- apps/note/views.py | 2 +- static/js/consos.js | 10 +++++----- templates/base.html | 4 ++++ templates/note/conso_form.html | 20 ++++++++++++++++++-- templates/note/transaction_form.html | 12 +++++------- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/apps/note/tables.py b/apps/note/tables.py index 3306cb3b..cea2aa8e 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -17,8 +17,8 @@ class HistoryTable(tables.Table): 'table table-condensed table-striped table-hover' } model = Transaction - exclude = ("polymorphic_ctype", ) - order_by = ('-id', ) + exclude = ("id", "polymorphic_ctype", ) + order_by = ('-created_at', ) template_name = 'django_tables2/bootstrap4.html' sequence = ('...', 'total', 'valid') diff --git a/apps/note/views.py b/apps/note/views.py index e323a4fd..9b60a642 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -115,7 +115,7 @@ class ConsoView(LoginRequiredMixin, SingleTableView): # Transaction history table table_class = HistoryTable - table_pagination = {"per_page": 10} + table_pagination = {"per_page": 20} def get_context_data(self, **kwargs): """ diff --git a/static/js/consos.js b/static/js/consos.js index 7a38614c..df50bda2 100644 --- a/static/js/consos.js +++ b/static/js/consos.js @@ -23,14 +23,14 @@ $(document).ready(function() { }); }); -let notes = []; -let notes_display = []; -let buttons = []; +notes = []; +notes_display = []; +buttons = []; // When the user searches an alias, we update the auto-completion autoCompleteNote("note", "alias_matched", "note_list", notes, notes_display, "alias", "note", "user_note", "profile_pic", function() { - if (buttons.length > 0) { + if (buttons.length > 0 && $("#single_conso").is(":checked")) { consumeAll(); return false; } @@ -58,7 +58,7 @@ function addConso(dest, amount, type, category_id, category_name, template_id, t if (button == null) 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 = ""; buttons.forEach(function(button) { html += li("conso_button_" + button[6], button[7] diff --git a/templates/base.html b/templates/base.html index 6af81fe8..eefad7c8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -161,6 +161,10 @@ SPDX-License-Identifier: GPL-3.0-or-later + + {% block extrajavascript %} {% endblock extrajavascript %} diff --git a/templates/note/conso_form.html b/templates/note/conso_form.html index 6ae643b3..100f46c2 100644 --- a/templates/note/conso_form.html +++ b/templates/note/conso_form.html @@ -143,14 +143,18 @@ {% block extrajavascript %}