From 9927cbbab415e713766e461f22c6ed51dec2cf98 Mon Sep 17 00:00:00 2001
From: "Edgar P. Burkhart" <git@edgarpierre.fr>
Date: Wed, 3 Jan 2024 14:25:25 +0100
Subject: [PATCH] Move new and more links to tables

---
 nummi/main/static/main/css/table.css          | 12 +++++---
 .../templates/statement/statement_table.html  | 26 ++++++++++-------
 .../transaction/transaction_table.html        | 28 +++++++++++--------
 3 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/nummi/main/static/main/css/table.css b/nummi/main/static/main/css/table.css
index 0092937..155a75d 100644
--- a/nummi/main/static/main/css/table.css
+++ b/nummi/main/static/main/css/table.css
@@ -5,9 +5,6 @@ form {
 table {
   border-collapse: collapse;
 
-  &.more tbody:last-child tr:last-child {
-    border-bottom: 1px dashed var(--gray);
-  }
   &.full-width {
     width: 100%;
 
@@ -18,7 +15,7 @@ table {
   col.icon {
     width: 1ch;
   }
-  thead {
+  thead tr:not(.new) {
     background: var(--bg-01);
   }
   tr {
@@ -29,6 +26,13 @@ table {
     tbody &:where(:nth-of-type(even)) {
       background: #eeeeff;
     }
+    tfoot &.more,
+    thead &.new {
+      text-align: center;
+    }
+    tfoot &.more {
+      border-style: dashed;
+    }
   }
   td,
   th {
diff --git a/nummi/statement/templates/statement/statement_table.html b/nummi/statement/templates/statement/statement_table.html
index 322653a..34c87a6 100644
--- a/nummi/statement/templates/statement/statement_table.html
+++ b/nummi/statement/templates/statement/statement_table.html
@@ -1,10 +1,5 @@
 {% load main_extras %}
 {% load i18n %}
-{% if new_statement_url %}
-    <p>
-        <a href="{{ new_statement_url }}">{% translate "Create statement" %}</a>
-    </p>
-{% endif %}
 <div id="statements" class="table">
     <table class="full-width {% if statements_url %}more{% endif %}">
         <colgroup>
@@ -28,6 +23,13 @@
                 <th>{% translate "Difference" %}</th>
                 <th>{% translate "Transactions" %}</th>
             </tr>
+            {% if new_statement_url %}
+                <tr class="new">
+                    <td colspan="{% if account %}6{% else %}8{% endif %}">
+                        <a href="{{ new_statement_url }}">{% translate "Create statement" %}</a>
+                    </td>
+                </tr>
+            {% endif %}
         </thead>
         <tbody>
             {% for snap in statements %}
@@ -61,10 +63,14 @@
                 </tr>
             {% endfor %}
         </tbody>
+        {% if statements_url %}
+            <tfoot>
+                <tr class="more">
+                    <td colspan="{% if account %}6{% else %}8{% endif %}">
+                        <a href="{{ statements_url }}">{% translate "View all statements" %}</a>
+                    </td>
+                </tr>
+            </tfoot>
+        {% endif %}
     </table>
 </div>
-{% if statements_url %}
-    <p>
-        <a href="{{ statements_url }}">{% translate "View all statements" %}</a>
-    </p>
-{% endif %}
diff --git a/nummi/transaction/templates/transaction/transaction_table.html b/nummi/transaction/templates/transaction/transaction_table.html
index fb89dbf..ff31a73 100644
--- a/nummi/transaction/templates/transaction/transaction_table.html
+++ b/nummi/transaction/templates/transaction/transaction_table.html
@@ -1,12 +1,7 @@
 {% load main_extras %}
 {% load i18n %}
-{% if new_transaction_url %}
-    <p>
-        <a href="{{ new_transaction_url }}">{% translate "Create transaction" %}</a>
-    </p>
-{% endif %}
 <div id="transactions" class="table">
-    <table class="full-width {% if transactions_url %}more{% endif %}">
+    <table class="full-width">
         <colgroup>
             <col class="icon">
             <col class="date">
@@ -36,6 +31,13 @@
                     <th colspan="2">{% translate "Account" %}</th>
                 {% endif %}
             </tr>
+            {% if new_transaction_url %}
+                <tr class="new">
+                    <td colspan="{% if category and account %}5{% elif category or account %}7{% else %}9{% endif %}">
+                        <a href="{{ new_transaction_url }}">{% translate "Create transaction" %}</a>
+                    </td>
+                </tr>
+            {% endif %}
         </thead>
         <tbody>
             {% for trans in transactions %}
@@ -77,10 +79,14 @@
                 </tr>
             {% endfor %}
         </tbody>
+        {% if transactions_url %}
+            <tfoot>
+                <tr class="more">
+                    <td colspan="{% if category and account %}5{% elif category or account %}7{% else %}9{% endif %}">
+                        <a href="{{ transactions_url }}">{% translate "View all transactions" %}</a>
+                    </td>
+                </tr>
+            </tfoot>
+        {% endif %}
     </table>
 </div>
-{% if transactions_url %}
-    <p>
-        <a href="{{ transactions_url }}">{% translate "View all transactions" %}</a>
-    </p>
-{% endif %}
