legenda bez 0 w wykresach

This commit is contained in:
Mateusz Gruszczyński
2025-07-31 21:57:39 +02:00
parent 1ab52556f1
commit 5ddbd2b1ed
11 changed files with 14 additions and 29 deletions

View File

@@ -6,7 +6,6 @@ document.addEventListener("DOMContentLoaded", () => {
const row = e.target.closest('.clickable-item');
if (!row || !itemsContainer.contains(row)) return;
// Ignoruj kliknięcia w przyciski i inputy
if (e.target.closest('button') || e.target.tagName.toLowerCase() === 'input') {
return;
}

View File

@@ -1,5 +1,4 @@
document.addEventListener("DOMContentLoaded", function () {
// Odśwież eventy
document.querySelectorAll('.sync-btn').forEach(btn => {
btn.replaceWith(btn.cloneNode(true));
});
@@ -7,7 +6,6 @@ document.addEventListener("DOMContentLoaded", function () {
btn.replaceWith(btn.cloneNode(true));
});
// Synchronizacja sugestii
document.querySelectorAll('.sync-btn').forEach(btn => {
btn.addEventListener('click', function (e) {
e.preventDefault();
@@ -41,7 +39,6 @@ document.addEventListener("DOMContentLoaded", function () {
});
});
// Usuwanie sugestii
document.querySelectorAll('.delete-suggestion-btn').forEach(btn => {
btn.addEventListener('click', function (e) {
e.preventDefault();

View File

@@ -17,8 +17,8 @@ if (!window.receiptUploaderInitialized) {
const isDesktop = window.matchMedia("(pointer: fine)").matches;
if (isDesktop) {
if (cameraBtn) cameraBtn.remove(); // całkowicie usuń przycisk
if (inputCamera) inputCamera.remove(); // oraz input
if (cameraBtn) cameraBtn.remove();
if (inputCamera) inputCamera.remove();
if (galleryBtnText) galleryBtnText.textContent = " Dodaj paragon";
}
@@ -79,7 +79,6 @@ if (!window.receiptUploaderInitialized) {
}
lightbox = GLightbox({ selector: ".glightbox" });
// Pokaż sekcję OCR jeśli była ukryta
const analysisBlock = document.getElementById("receiptAnalysisBlock");
if (analysisBlock) {
analysisBlock.classList.remove("d-none");

View File

@@ -1,7 +1,7 @@
document.addEventListener("DOMContentLoaded", function () {
new TomSelect("#categories", {
plugins: ['remove_button'],
maxItems: 3, // limit wyboru
maxItems: 4,
placeholder: 'Wybierz kategorie...',
create: false,
sortField: {

View File

@@ -82,13 +82,11 @@ socket.on('receipt_added', function (data) {
const gallery = document.getElementById("receiptGallery");
if (!gallery) return;
// Usuń placeholder, jeśli istnieje
const alert = gallery.querySelector(".alert");
if (alert) {
alert.remove();
}
// Sprawdź, czy już istnieje obraz z tym URL
const existing = Array.from(gallery.querySelectorAll("img")).find(img => img.src === data.url);
if (!existing) {
const col = document.createElement("div");

View File

@@ -11,12 +11,10 @@ function enableSortMode() {
const listId = window.LIST_ID;
if (!itemsContainer || !listId) return;
// Odśwież widok listy z uchwytami (☰)
if (window.currentItems) {
updateListSmoothly(window.currentItems);
}
// Poczekaj na DOM po odświeżeniu listy
setTimeout(() => {
if (sortable) sortable.destroy();

View File

@@ -1,11 +1,8 @@
document.addEventListener("DOMContentLoaded", function () {
const toggleBtn = document.getElementById("tempToggle");
const hiddenInput = document.getElementById("temporaryHidden");
// Inicjalizacja tooltipa
const tooltip = new bootstrap.Tooltip(toggleBtn);
// Funkcja aktualizująca wygląd
function updateToggle(isActive) {
if (isActive) {
toggleBtn.classList.remove("btn-outline-secondary");
@@ -18,11 +15,9 @@ document.addEventListener("DOMContentLoaded", function () {
}
}
// Inicjalizacja stanu
let active = toggleBtn.getAttribute("data-active") === "1";
updateToggle(active);
// Obsługa kliknięcia
toggleBtn.addEventListener("click", function () {
active = !active;
toggleBtn.setAttribute("data-active", active ? "1" : "0");

View File

@@ -6,7 +6,6 @@ document.addEventListener("DOMContentLoaded", function () {
btn.addEventListener("click", function () {
const selectedCat = this.dataset.category;
// Zmiana stylu przycisku aktywnego
categoryButtons.forEach(b => b.classList.remove("active"));
this.classList.add("active");

View File

@@ -8,7 +8,6 @@ document.addEventListener('DOMContentLoaded', () => {
const customStart = document.getElementById('customStart');
const customEnd = document.getElementById('customEnd');
// Przywróć zapisane daty
if (localStorage.getItem('customStart')) {
customStart.value = localStorage.getItem('customStart');
}
@@ -40,7 +39,6 @@ document.addEventListener('DOMContentLoaded', () => {
btn.classList.add('active');
const range = btn.dataset.range;
// Czyść lokalne daty przy kliknięciu zakresu
localStorage.removeItem('customStart');
localStorage.removeItem('customEnd');

View File

@@ -1,7 +1,7 @@
document.addEventListener("DOMContentLoaded", function () {
let expensesChart = null;
let selectedCategoryId = "";
let categorySplit = false; // <-- nowy tryb
let categorySplit = false;
const rangeLabel = document.getElementById("chartRangeLabel");
function loadExpenses(range = "monthly", startDate = null, endDate = null) {
@@ -35,13 +35,21 @@ document.addEventListener("DOMContentLoaded", function () {
type: 'bar',
data: {
labels: data.labels,
datasets: data.datasets // <-- gotowe z backendu
datasets: data.datasets
},
options: {
responsive: true,
plugins: {
tooltip: { mode: 'index', intersect: false },
legend: { position: 'top' }
legend: {
position: 'top',
labels: {
filter: function(legendItem, chart) {
const data = chart.chart.data.datasets[legendItem.datasetIndex].data;
return data.some(value => value !== 0);
}
}
}
},
scales: {
x: { stacked: true },
@@ -99,7 +107,6 @@ document.addEventListener("DOMContentLoaded", function () {
loadExpenses(); // przeładuj wykres
});
// Reszta Twojego kodu bez zmian...
const startDateInput = document.getElementById("startDate");
const endDateInput = document.getElementById("endDate");
const today = new Date();

View File

@@ -7,7 +7,6 @@
<a href="{{ url_for('main_page') }}" class="btn btn-outline-secondary">← Powrót</a>
</div>
<div class="d-flex justify-content-center mb-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="showAllLists" {% if show_all %}checked{% endif %}>
@@ -30,7 +29,6 @@
{% endfor %}
</div>
<div class="card bg-dark text-white mb-5">
<div class="card-body">
<ul class="nav nav-tabs mb-3" id="expenseTabs" role="tablist">
@@ -125,14 +123,12 @@
</tbody>
</table>
</div>
<hr>
<h5 class="text-success mt-3">💰 Suma zaznaczonych: <span id="listsTotal">0.00 PLN</span></h5>
</div>
</div>
</div>
<!-- WYKRES -->
<div class="tab-pane fade" id="chartTab" role="tabpanel">
<div class="card bg-dark text-white mb-4">
@@ -148,7 +144,6 @@
</div>
</div>
<div class="d-flex flex-wrap gap-2 mb-3 justify-content-center">
<button class="btn btn-outline-light btn-sm range-btn active" data-range="monthly">📅 Miesięczne</button>
<button class="btn btn-outline-light btn-sm range-btn" data-range="quarterly">📊 Kwartalne</button>