desing pruning
This commit is contained in:
parent
b8cf13b7d5
commit
be80307bde
7 changed files with 159 additions and 367 deletions
|
|
@ -3,13 +3,6 @@ var editingSpecialId = null;
|
|||
var activeCatalogueTags = [];
|
||||
var activeCakeTags = [];
|
||||
|
||||
// ====== Sidebar ======
|
||||
function toggleSidebar() {
|
||||
document.body.classList.toggle('sidebar-collapsed');
|
||||
localStorage.setItem('sidebarCollapsed', document.body.classList.contains('sidebar-collapsed'));
|
||||
}
|
||||
|
||||
// ====== Overlay ======
|
||||
function openSpecialCakeOverlay() {
|
||||
editingSpecialId = null;
|
||||
document.getElementById('sc-overlay-title').textContent = 'Dodaj tort specjalny';
|
||||
|
|
@ -148,7 +141,6 @@ function removeSpecialCake(btn) {
|
|||
updateTotals();
|
||||
}
|
||||
|
||||
// ====== Basket ======
|
||||
function changeCake(id, name, price, delta) {
|
||||
var input = document.querySelector('[name="cake[' + id + ']"]');
|
||||
if (input != null) {
|
||||
|
|
@ -193,7 +185,6 @@ function removeCake(btn) {
|
|||
updateCatalogueQty(id, 0);
|
||||
}
|
||||
|
||||
// ====== Totals ======
|
||||
function updatePrepaid() {
|
||||
var paid = Number(document.querySelector('[name="paid"]')?.value || 0);
|
||||
document.getElementById('paid-amount').innerText = paid.toFixed(2) + ' PLN';
|
||||
|
|
@ -222,7 +213,6 @@ function updateCatalogueQty(id, qty) {
|
|||
if (el) el.innerText = qty;
|
||||
}
|
||||
|
||||
// ====== Catalogue Filters ======
|
||||
function toggleCatalogueTagFilter(btn) {
|
||||
var tag = btn.getAttribute('data-tag');
|
||||
var idx = activeCatalogueTags.indexOf(tag);
|
||||
|
|
@ -257,7 +247,7 @@ function applyCatalogueFilters() {
|
|||
}
|
||||
}
|
||||
}
|
||||
item.style.display = matchesText && matchesTags ? '' : 'none';
|
||||
item.classList.toggle('hide', !(matchesText && matchesTags));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +255,6 @@ function filterCatalogue(input) {
|
|||
applyCatalogueFilters();
|
||||
}
|
||||
|
||||
// ====== Cakes Table Filters ======
|
||||
function toggleCakeTagFilter(btn) {
|
||||
var tag = btn.getAttribute('data-tag');
|
||||
var idx = activeCakeTags.indexOf(tag);
|
||||
|
|
@ -278,17 +267,16 @@ function toggleCakeTagFilter(btn) {
|
|||
}
|
||||
var rows = document.querySelectorAll('#cakes-table tbody tr');
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
if (activeCakeTags.length === 0) { rows[i].style.display = ''; continue; }
|
||||
if (activeCakeTags.length === 0) { rows[i].classList.remove('hide'); continue; }
|
||||
var rowTags = (rows[i].getAttribute('data-tags') || '').split(',');
|
||||
var match = false;
|
||||
for (var j = 0; j < activeCakeTags.length; j++) {
|
||||
if (rowTags.indexOf(activeCakeTags[j]) >= 0) { match = true; break; }
|
||||
}
|
||||
rows[i].style.display = match ? '' : 'none';
|
||||
rows[i].classList.toggle('hide', !match);
|
||||
}
|
||||
}
|
||||
|
||||
// ====== Order Table Filters ======
|
||||
function filterOrders(input) {
|
||||
var q = input.value.toLowerCase();
|
||||
var table = input.closest('.card').querySelector('.data-table');
|
||||
|
|
@ -297,11 +285,10 @@ function filterOrders(input) {
|
|||
for (var i = 0; i < rows.length; i++) {
|
||||
var id = rows[i].children[0].textContent.toLowerCase();
|
||||
var customer = rows[i].children[1].textContent.toLowerCase();
|
||||
rows[i].style.display = id.includes(q) || customer.includes(q) ? '' : 'none';
|
||||
rows[i].classList.toggle('hide', !(id.includes(q) || customer.includes(q)));
|
||||
}
|
||||
}
|
||||
|
||||
// ====== Location Toggle ======
|
||||
function setLocation(btn, value) {
|
||||
var group = btn.closest('.toggle-group');
|
||||
group.querySelectorAll('.toggle-btn').forEach(function(b) { b.classList.remove('active'); });
|
||||
|
|
@ -309,7 +296,6 @@ function setLocation(btn, value) {
|
|||
group.querySelector('input[type="hidden"]').value = value;
|
||||
}
|
||||
|
||||
// ====== Blocked Date Confirmation ======
|
||||
function confirmBlockedDate(form) {
|
||||
var date = form.querySelector('[name="date"]').value;
|
||||
var blocked = JSON.parse(form.getAttribute('data-blocked-dates') || '[]');
|
||||
|
|
@ -320,7 +306,6 @@ function confirmBlockedDate(form) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// ====== Init ======
|
||||
function initOrderPage() {
|
||||
var form = document.querySelector('.order-form');
|
||||
if (!form) return;
|
||||
|
|
@ -338,19 +323,13 @@ function initOrderPage() {
|
|||
|
||||
function setActiveLink() {
|
||||
var path = window.location.pathname;
|
||||
var links = document.querySelectorAll('.link');
|
||||
var links = document.querySelectorAll('nav > a');
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
links[i].classList.toggle('active', links[i].getAttribute('href') === path);
|
||||
}
|
||||
}
|
||||
|
||||
function setSidebarState() {
|
||||
var collapsed = localStorage.getItem('sidebarCollapsed') === 'true';
|
||||
document.body.classList.toggle('sidebar-collapsed', collapsed);
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
setSidebarState();
|
||||
setActiveLink();
|
||||
initOrderPage();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue