This commit is contained in:
Mateusz Gruszczyński
2025-07-24 23:30:51 +02:00
parent 04bc3773e1
commit 34205f0e65
6 changed files with 377 additions and 149 deletions

View File

@@ -131,11 +131,11 @@
{% endif %}
{% if not is_share %}
<button type="button" class="btn btn-outline-warning" {% if list.is_archived %}disabled{% else
<button type="button" class="btn btn-outline-light" {% if list.is_archived %}disabled{% else
%}onclick="editItem({{ item.id }}, '{{ item.name }}', {{ item.quantity or 1 }})" {% endif %}>
✏️
</button>
<button type="button" class="btn btn-outline-danger" {% if list.is_archived %}disabled{% else
<button type="button" class="btn btn-outline-light" {% if list.is_archived %}disabled{% else
%}onclick="deleteItem({{ item.id }})" {% endif %}>
🗑️
</button>

View File

@@ -10,12 +10,14 @@
<div class="card bg-dark text-white mb-5">
<div class="card-body">
<ul class="nav nav-tabs mb-3" id="expenseTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="table-tab" data-bs-toggle="tab" data-bs-target="#tableTab" type="button"
<button class="nav-link active" id="lists-tab" data-bs-toggle="tab" data-bs-target="#listsTab" type="button"
role="tab">
📄 Tabela
📚 Listy
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="chart-tab" data-bs-toggle="tab" data-bs-target="#chartTab" type="button"
role="tab">
@@ -25,32 +27,77 @@
</ul>
<div class="tab-content" id="expenseTabsContent">
<!-- Tabela -->
<div class="tab-pane fade show active" id="tableTab" role="tabpanel">
<!-- 📚 LISTY -->
<div class="tab-pane fade show active" id="listsTab" role="tabpanel">
<div class="card bg-dark text-white mb-4">
<div class="card-body">
{% if expense_table %}
<div class="row g-4">
{% for row in expense_table %}
<div class="col-12 col-sm-6 col-lg-4">
<div class="card bg-dark text-white border border-secondary h-100 shadow-sm">
<div class="card-body">
<h5 class="card-title text-truncate" title="{{ row.title }}">{{ row.title }}</h5>
<p class="mb-1">💸 <strong>{{ '%.2f'|format(row.amount) }} PLN</strong></p>
<p class="mb-0">📅 {{ row.added_at.strftime('%Y-%m-%d') }}</p>
</div>
</div>
</div>
{% endfor %}
<div class="d-flex flex-wrap gap-2 mb-3">
<button class="btn btn-outline-light btn-sm filter-btn active" data-range="all">Wszystko</button>
<button class="btn btn-outline-light btn-sm filter-btn" data-range="day">🗓️ Dzień</button>
<button class="btn btn-outline-light btn-sm filter-btn" data-range="week">📆 Tydzień</button>
<button class="btn btn-outline-light btn-sm filter-btn" data-range="month">📅 Miesiąc</button>
<button class="btn btn-outline-light btn-sm filter-btn" data-range="year">📈 Rok</button>
</div>
{% else %}
<div class="alert alert-info text-center mb-0">Brak wydatków do wyświetlenia.</div>
{% endif %}
<div class="row g-2 mb-3">
<div class="col-6 col-md-3">
<input type="date" id="customStart" class="form-control bg-dark text-white border-secondary rounded"
placeholder="Data od">
</div>
<div class="col-6 col-md-3">
<input type="date" id="customEnd" class="form-control bg-dark text-white border-secondary rounded"
placeholder="Data do">
</div>
<div class="col-12 col-md-3">
<button class="btn btn-outline-light w-100" id="applyCustomRange">📊 Zastosuj zakres</button>
</div>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="onlyWithExpenses">
<label class="form-check-label ms-2" for="onlyWithExpenses">Pokaż tylko listy z wydatkami</label>
</div>
<div class="table-responsive">
<table class="table table-dark table-striped align-middle">
<thead>
<tr>
<th></th>
<th>Nazwa listy</th>
<th>Data</th>
<th>Wydatki (PLN)</th>
</tr>
</thead>
<tbody id="listsTableBody">
{% for list in lists_data %}
<tr data-date="{{ list.created_at.strftime('%Y-%m-%d') }}"
data-week="{{ list.created_at.isocalendar()[0] }}-{{ '%02d' % list.created_at.isocalendar()[1] }}"
data-month="{{ list.created_at.strftime('%Y-%m') }}" data-year="{{ list.created_at.year }}">
<td>
<input type="checkbox" class="form-check-input list-checkbox"
data-amount="{{ '%.2f'|format(list.total_expense) }}">
</td>
<td>
<strong>{{ list.title }}</strong>
<br><small class="text-small">👤 {{ list.owner_username or '?' }}</small>
</td>
<td>{{ list.created_at.strftime('%Y-%m-%d') }}</td>
<td>{{ '%.2f'|format(list.total_expense) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<hr>
<h5 class="text-success mt-3">💰 Suma zaznaczonych: <span id="listsTotal">0.00 PLN</span></h5>
</div>
</div>
</div>
<!-- Wykres -->
<!-- 📊 WYKRES -->
<div class="tab-pane fade" id="chartTab" role="tabpanel">
<div class="card bg-dark text-white mb-4">
<div class="card-body">
@@ -78,6 +125,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
@@ -86,4 +134,5 @@
{% block scripts %}
<script src="{{ url_for('static_bp.serve_js_lib', filename='chart.js') }}"></script>
<script src="{{ url_for('static_bp.serve_js', filename='user_expenses.js') }}"></script>
<script src="{{ url_for('static_bp.serve_js', filename='user_expense_lists.js') }}"></script>
{% endblock %}