Convert balance assertions view to Tailwind CSS

This commit is contained in:
RunasSudo 2024-04-04 15:55:30 +11:00
parent d73535dc86
commit f7e03fdb7b
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 42 additions and 19 deletions

View File

@ -1,5 +1,5 @@
{# DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 2022–2023 Lee Yingtong Li (RunasSudo)
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@ -15,38 +15,61 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
{% extends 'base.html' %}
{% extends 'base_tailwind.html' %}
{% block title %}Balance assertions{% endblock %}
{% block content %}
<h1 class="h2 my-4">Balance assertions</h1>
<h1 class="text-3xl text-gray-900">
Balance assertions
</h1>
<div class="mb-2">
<a href="{{ url_for('balance_assertions_new') }}" class="btn btn-primary"><i class="bi bi-plus-lg"></i> New assertion</a>
<div class="my-4 flex gap-x-2">
<a href="{{ url_for('balance_assertions_new') }}" class="inline-flex items-center gap-x-1.5 bg-emerald-600 pl-2 pr-3 py-1 text-white shadow-sm hover:bg-emerald-700">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
New assertion
</a>
</div>
<table class="table">
<table class="min-w-full">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Account</th>
<th class="text-end">Balance</th>
<tr class="border-b border-gray-300">
<th class="py-0.5 text-gray-900 font-semibold text-start">Date</th>
<th class="py-0.5 text-gray-900 font-semibold text-start">Description</th>
<th class="py-0.5 text-gray-900 font-semibold text-start">Account</th>
<th class="py-0.5 text-gray-900 font-semibold text-end">Balance</th>
<th></th>
<th>Status</th>
<th class="py-0.5 text-gray-900 font-semibold text-start">Status</th>
<th></th>
</tr>
</thead>
<tbody>
{% for assertion in assertions %}
<tr>
<td>{{ assertion.dt.strftime('%Y-%m-%d') }}</td>
<td>{{ assertion.description }}</td>
<td>{{ assertion.account }}</td>
<td class="text-end">{{ (assertion.balance()|abs).format() }}</td>
<td>{{ 'Dr' if assertion.quantity >= 0 else 'Cr' }}</td>
<td>{% if assertion_status[assertion] %}<i class="bi bi-check-lg"></i>{% else %}<i class="bi bi-x-circle-fill text-danger"></i>{% endif %}</td>
<td><a href="{{ url_for('balance_assertions_edit', id=assertion.id) }}"><i class="bi bi-pencil"></i></a></td>
<td class="py-0.5 text-gray-900">{{ assertion.dt.strftime('%Y-%m-%d') }}</td>
<td class="py-0.5 text-gray-900">{{ assertion.description }}</td>
<td class="py-0.5 text-gray-900">{{ assertion.account }}</td>
<td class="py-0.5 text-gray-900 text-end">{{ (assertion.balance()|abs).format() }}</td>
<td class="py-0.5 pl-1 text-gray-900">{{ 'Dr' if assertion.quantity >= 0 else 'Cr' }}</td>
<td class="py-0.5 text-gray-900">
{% if assertion_status[assertion] %}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="w-4 h-4">
<path fill-rule="evenodd" d="M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.74a.75.75 0 0 1 1.04-.207Z" clip-rule="evenodd" />
</svg>
{% else %}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="w-4 h-4 text-red-500">
<path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm2.78-4.22a.75.75 0 0 1-1.06 0L8 9.06l-1.72 1.72a.75.75 0 1 1-1.06-1.06L6.94 8 5.22 6.28a.75.75 0 0 1 1.06-1.06L8 6.94l1.72-1.72a.75.75 0 1 1 1.06 1.06L9.06 8l1.72 1.72a.75.75 0 0 1 0 1.06Z" clip-rule="evenodd" />
</svg>
{% endif %}
</td>
<td class="py-0.5 text-gray-900 text-end">
<a href="{{ url_for('balance_assertions_edit', id=assertion.id) }}" class="text-gray-500 hover:text-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 inline align-middle -mt-0.5">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" />
</svg>
</a>
</td>
</tr>
{% endfor %}
</tbody>