templates, handlers, CSS, JS: special cakes UI, HTMX nav, dashboard overhaul
Special cakes UI: overlay drawer, basket integration, catalogue tag filter, form parsing, JS save/edit/remove. HTMX navigation: MainContent component, nav links with hx-get, handlers return partial on HX-Request. Dashboard: metrics grid, CakeBreakdown, OrderRow with status select, CakeCounts/OrderCounts, torty filter, tort badge, results-pane. Collapsible sidebar: toggle button, localStorage, CSS transitions. Location field: dropdown replaced with pill toggle. Inline style cleanup: moved to CSS classes (tag-grid, grow, icon.sm, header-actions, toggle-group, success-icon, etc.). Dead CSS removal: pagination, status-chip, badge-pill, login-page. Helpers: exported CakeTitle/OrderTitle, added tagNames, tagIDsComma, orderItemsDesc, specialCakeDetail, removed unused helpers.
This commit is contained in:
parent
17b92a706a
commit
5a5372b831
18 changed files with 1153 additions and 422 deletions
|
|
@ -42,6 +42,10 @@
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.basket-actions .action-btn .material-symbols-outlined {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.remove {
|
||||
color: var(--error);
|
||||
cursor: pointer;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
/* ========== METRICS GRID ========== */
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 0.75rem;
|
||||
|
||||
> div {
|
||||
|
|
@ -128,21 +128,21 @@
|
|||
gap: 1rem;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
> div:first-child {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
min-width: 0;
|
||||
}
|
||||
.order-left {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
> aside {
|
||||
width: 20rem;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.order-aside {
|
||||
width: 20rem;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
@media (max-width: 64em) {
|
||||
|
|
@ -150,7 +150,7 @@
|
|||
flex-direction: column;
|
||||
}
|
||||
|
||||
.split-pane > aside {
|
||||
.order-aside {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
|
@ -237,5 +237,6 @@
|
|||
|
||||
.text-muted {
|
||||
color: var(--on-surface-variant);
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,61 +60,31 @@
|
|||
}
|
||||
}
|
||||
|
||||
/* ========== STATUS CHIPS ========== */
|
||||
.status-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: var(--border-radius-full);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
|
||||
&.ready,
|
||||
&.done {
|
||||
background: var(--success-bg);
|
||||
color: var(--success-text);
|
||||
}
|
||||
|
||||
&.decorating {
|
||||
background: var(--warning-bg);
|
||||
color: var(--warning-text);
|
||||
}
|
||||
|
||||
&.baking {
|
||||
background: var(--danger-bg);
|
||||
color: var(--danger-text);
|
||||
}
|
||||
|
||||
&.queued {
|
||||
background: var(--info-bg);
|
||||
color: var(--info-text);
|
||||
}
|
||||
|
||||
&.accepted {
|
||||
background: #fff3e0;
|
||||
color: #e65100;
|
||||
}
|
||||
}
|
||||
|
||||
/* ========== BADGE PILLS ========== */
|
||||
.badge-pill {
|
||||
/* ========== TAG CHIPS ========== */
|
||||
.tag-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: var(--border-radius-full);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: var(--on-surface-variant);
|
||||
background: var(--surface-container-high);
|
||||
border: 1px solid var(--outline-variant);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition: all var(--transition);
|
||||
|
||||
&.signature {
|
||||
background: var(--primary-container);
|
||||
color: var(--primary);
|
||||
&.sm {
|
||||
font-size: 0.625rem;
|
||||
padding: 0.125rem 0.375rem;
|
||||
}
|
||||
|
||||
&.seasonal {
|
||||
background: var(--surface-container-high);
|
||||
color: var(--on-surface);
|
||||
&:hover,
|
||||
&.active {
|
||||
color: var(--primary);
|
||||
border-color: var(--primary);
|
||||
background: var(--primary-container);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,46 +108,154 @@
|
|||
}
|
||||
}
|
||||
|
||||
/* ========== PAGINATION ========== */
|
||||
.pagination {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
align-items: center;
|
||||
|
||||
.btn {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: var(--border-radius-sm);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
color: var(--on-surface-variant);
|
||||
transition: all var(--transition);
|
||||
font-size: 0.75rem;
|
||||
|
||||
&:hover {
|
||||
background: var(--surface-container-low);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--primary);
|
||||
color: var(--on-primary);
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
.material-symbols-outlined {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
/* ========== OVERLAY / DRAWER ========== */
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
display: none;
|
||||
}
|
||||
.overlay.open {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.overlay-backdrop {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.overlay-panel {
|
||||
position: relative;
|
||||
width: 22rem;
|
||||
max-width: 100vw;
|
||||
height: 100%;
|
||||
background: var(--surface);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: -0.25rem 0 1.5rem rgba(0, 0, 0, 0.15);
|
||||
animation: slideIn 0.2s ease;
|
||||
}
|
||||
@keyframes slideIn {
|
||||
from { transform: translateX(100%); }
|
||||
to { transform: translateX(0); }
|
||||
}
|
||||
.overlay-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1rem 1.25rem;
|
||||
border-bottom: 1px solid var(--outline-variant);
|
||||
}
|
||||
.overlay-header h2 {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.overlay-header .close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: var(--on-surface-variant);
|
||||
padding: 0.25rem;
|
||||
border-radius: var(--border-radius-sm);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.overlay-header .close-btn:hover {
|
||||
background: var(--surface-container-high);
|
||||
color: var(--on-surface);
|
||||
}
|
||||
.overlay-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.25rem;
|
||||
}
|
||||
.overlay-footer {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
justify-content: flex-end;
|
||||
padding: 1rem 1.25rem;
|
||||
border-top: 1px solid var(--outline-variant);
|
||||
}
|
||||
|
||||
/* ========== CARD HEADER ACTIONS ========== */
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
/* ========== TORT BADGE ========== */
|
||||
.tort-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
border-radius: var(--border-radius-full);
|
||||
background: var(--primary-container);
|
||||
color: var(--primary);
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
.tort-badge .material-symbols-outlined {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
/* ========== SEARCH INPUT UTILITY ========== */
|
||||
.search-wrapper { position: relative; width: 11.25rem; }
|
||||
.search-icon { position: absolute; left: 0.5rem; top: 50%; transform: translateY(-50%); font-size: 1rem; color: var(--on-surface-variant); pointer-events: none; }
|
||||
.search-input { height: 1.75rem; padding-left: 1.75rem; padding-right: 0.5rem; font-size: 0.75rem; border: 1px solid var(--outline-variant); border-radius: var(--border-radius-sm); background: var(--surface-container-lowest); color: var(--on-surface); outline: none; width: 100%; }
|
||||
|
||||
/* ========== STATUS SELECT ========== */
|
||||
.status-select { font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.375rem; border: 1px solid var(--outline-variant); border-radius: var(--border-radius-sm); background: var(--surface); color: var(--on-surface); cursor: pointer; }
|
||||
|
||||
/* ========== FONT UTILITIES ========== */
|
||||
.font-bold { font-weight: 700; }
|
||||
|
||||
/* ========== CAKE BREAKDOWN LIST ========== */
|
||||
.breakdown-list { list-style: none; padding: 0; margin: 0; }
|
||||
.breakdown-item { display: flex; justify-content: space-between; padding: 0.375rem 0; border-bottom: 1px solid var(--outline-variant); }
|
||||
.breakdown-amount { font-weight: 600; }
|
||||
.breakdown-empty { color: var(--on-surface-variant); font-size: 0.75rem; }
|
||||
|
||||
/* ========== FILTER BAR (catalogue/cakes page) ========== */
|
||||
.filter-bar { padding: 0.5rem 1rem; border-bottom: 1px solid var(--outline-variant); display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
|
||||
.filter-bar .filter-label { font-size: 0.75rem; font-weight: 600; color: var(--on-surface-variant); align-self: center; margin-right: 0.25rem; }
|
||||
|
||||
/* ========== CATALOGUE TAG ROW ========== */
|
||||
.tag-row { padding: 0.5rem 1rem 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
|
||||
|
||||
/* ========== CATALOGUE SCROLL ========== */
|
||||
.catalogue-scroll { overflow-y: auto; padding: 1rem; }
|
||||
|
||||
/* ========== BASKET ACTIONS ========== */
|
||||
.basket-actions { display: flex; flex-direction: column; gap: 0.125rem; }
|
||||
|
||||
/* ========== TAG GROUP ========== */
|
||||
.tag-group { margin-top: 0.25rem; display: flex; flex-wrap: wrap; gap: 0.125rem; }
|
||||
|
||||
/* ========== OVERLAY FORM ========== */
|
||||
.overlay-form { display: flex; flex-direction: column; gap: 0.75rem; }
|
||||
|
||||
/* ========== TAG CONTAINER ========== */
|
||||
.tag-grid { display: flex; flex-wrap: wrap; gap: 0.25rem; }
|
||||
|
||||
/* ========== FONT UTILITIES ========== */
|
||||
.font-medium { font-weight: 500; }
|
||||
|
||||
/* ========== FLEX UTILITIES ========== */
|
||||
.grow { flex: 1; }
|
||||
|
||||
.icon.sm { width: 1.75rem; height: 1.75rem; }
|
||||
.icon.sm .material-symbols-outlined { font-size: 1rem; }
|
||||
|
||||
/* ========== RESULTS PANE ========== */
|
||||
#results-pane { display: flex; flex-direction: column; gap: 1rem; }
|
||||
|
||||
/* ========== CONFIRMATION ========== */
|
||||
section.confirmation {
|
||||
|
|
@ -189,109 +267,14 @@ section.confirmation {
|
|||
gap: 0.5rem;
|
||||
text-align: center;
|
||||
|
||||
.success-icon {
|
||||
font-size: 3rem;
|
||||
color: var(--success-text);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: var(--on-surface);
|
||||
}
|
||||
}
|
||||
|
||||
/* ========== LOGIN PAGE ========== */
|
||||
.login-page {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100dvh;
|
||||
background-color: var(--surface-container-low);
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background-color: var(--surface);
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: var(--border-radius-md);
|
||||
padding: 2.5rem;
|
||||
box-shadow: 0 0.25rem 1.5rem rgba(0, 0, 0, 0.1);
|
||||
width: 100%;
|
||||
max-width: 25rem;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 0.25rem;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
var(--primary),
|
||||
var(--primary-container)
|
||||
);
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 1.5rem;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 1.5rem;
|
||||
color: var(--on-background);
|
||||
text-align: center;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: var(--on-surface-variant);
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: var(--border-radius-sm);
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
background-color: var(--surface);
|
||||
color: var(--on-surface);
|
||||
transition: border-color var(--transition);
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 0.5rem 2rem;
|
||||
background-color: var(--primary);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: var(--border-radius-md);
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition: opacity var(--transition);
|
||||
margin-top: 0.5rem;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,40 @@ form {
|
|||
}
|
||||
}
|
||||
|
||||
/* ========== TOGGLE GROUP ========== */
|
||||
.toggle-group {
|
||||
display: flex;
|
||||
height: 2rem;
|
||||
border-radius: var(--border-radius-sm);
|
||||
border: 1px solid var(--outline-variant);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.toggle-btn {
|
||||
flex: 1;
|
||||
border: none;
|
||||
background: var(--surface-container-lowest);
|
||||
color: var(--on-surface-variant);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
.toggle-btn:not(:last-child) {
|
||||
border-right: 1px solid var(--outline-variant);
|
||||
}
|
||||
|
||||
.toggle-btn.active {
|
||||
background: var(--primary);
|
||||
color: var(--on-primary);
|
||||
}
|
||||
|
||||
.toggle-btn:not(.active):hover {
|
||||
background: var(--surface-container-high);
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
|
|
|||
|
|
@ -11,23 +11,54 @@ aside.sidebar {
|
|||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
z-index: 40;
|
||||
transition: width 0.2s ease, padding 0.2s ease;
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
padding: 0 0.5rem;
|
||||
|
||||
h1 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
letter-spacing: -0.01em;
|
||||
line-height: 1.3;
|
||||
.collapse-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: var(--on-surface-variant);
|
||||
padding: 0.25rem;
|
||||
border-radius: var(--border-radius-sm);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:hover {
|
||||
background: var(--surface-container-high);
|
||||
color: var(--on-surface);
|
||||
}
|
||||
|
||||
.material-symbols-outlined {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 0.75rem;
|
||||
color: var(--on-surface-variant);
|
||||
margin-top: 0.25rem;
|
||||
.brand-text {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
|
||||
h1 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
letter-spacing: -0.01em;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 0.75rem;
|
||||
color: var(--on-surface-variant);
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +171,47 @@ aside.sidebar {
|
|||
}
|
||||
}
|
||||
|
||||
/* ---------- COLLAPSED ---------- */
|
||||
body.sidebar-collapsed aside.sidebar {
|
||||
width: 3.5rem;
|
||||
padding: 0.5rem;
|
||||
|
||||
.brand .brand-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cta {
|
||||
padding: 0;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
border-radius: 50%;
|
||||
|
||||
span:not(.material-symbols-outlined) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
nav a.link {
|
||||
justify-content: center;
|
||||
padding: 0.75rem 0.5rem;
|
||||
|
||||
span:not(.material-symbols-outlined) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
footer .user .info {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
body.sidebar-collapsed main {
|
||||
margin-left: 3.5rem;
|
||||
width: calc(100% - 3.5rem);
|
||||
}
|
||||
|
||||
/* ========== MAIN LAYOUT ========== */
|
||||
main {
|
||||
margin-left: var(--sidebar-width);
|
||||
|
|
@ -147,6 +219,7 @@ main {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100dvh;
|
||||
transition: margin-left 0.2s ease, width 0.2s ease;
|
||||
}
|
||||
|
||||
/* ========== TOP NAVBAR ========== */
|
||||
|
|
@ -228,14 +301,13 @@ header.topnav {
|
|||
}
|
||||
|
||||
@media (max-width: 48em) {
|
||||
aside.sidebar {
|
||||
body:not(.sidebar-collapsed) aside.sidebar {
|
||||
width: 3.5rem;
|
||||
padding: 0.5rem;
|
||||
|
||||
.brand h1,
|
||||
.brand p,
|
||||
nav a.link span:not(.material-symbols-outlined),
|
||||
.brand .brand-text,
|
||||
.cta span:not(.material-symbols-outlined),
|
||||
nav a.link span:not(.material-symbols-outlined),
|
||||
.user .info {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -258,6 +330,18 @@ header.topnav {
|
|||
}
|
||||
}
|
||||
|
||||
body.sidebar-collapsed aside.sidebar {
|
||||
width: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
body.sidebar-collapsed main {
|
||||
margin-left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
main {
|
||||
margin-left: 3.5rem;
|
||||
width: calc(100% - 3.5rem);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,144 @@
|
|||
var editingSpecialId = null;
|
||||
|
||||
function openSpecialCakeOverlay() {
|
||||
editingSpecialId = null;
|
||||
document.getElementById("sc-overlay-title").textContent = "Dodaj tort specjalny";
|
||||
document.getElementById("sc-name").value = "";
|
||||
document.getElementById("sc-price").value = "";
|
||||
document.getElementById("sc-size").value = "";
|
||||
document.getElementById("sc-shape").value = "";
|
||||
document.getElementById("sc-flavour").value = "";
|
||||
document.getElementById("sc-notes").value = "";
|
||||
document.getElementById("sc-new-tag").value = "";
|
||||
var cbs = document.querySelectorAll(".sc-tag-cb");
|
||||
for (var i = 0; i < cbs.length; i++) cbs[i].checked = false;
|
||||
document.getElementById("sc-overlay").classList.add("open");
|
||||
document.getElementById("sc-name").focus();
|
||||
}
|
||||
|
||||
function closeSpecialCakeOverlay() {
|
||||
document.getElementById("sc-overlay").classList.remove("open");
|
||||
editingSpecialId = null;
|
||||
}
|
||||
|
||||
function getOverlayFormData() {
|
||||
return {
|
||||
name: document.getElementById("sc-name").value.trim(),
|
||||
price: document.getElementById("sc-price").value,
|
||||
size: document.getElementById("sc-size").value.trim(),
|
||||
shape: document.getElementById("sc-shape").value,
|
||||
flavour: document.getElementById("sc-flavour").value.trim(),
|
||||
notes: document.getElementById("sc-notes").value.trim(),
|
||||
tagIds: (function() {
|
||||
var ids = [];
|
||||
var cbs = document.querySelectorAll(".sc-tag-cb:checked");
|
||||
for (var i = 0; i < cbs.length; i++) ids.push(cbs[i].value);
|
||||
return ids;
|
||||
})(),
|
||||
tagNames: (function() {
|
||||
var names = [];
|
||||
var cbs = document.querySelectorAll(".sc-tag-cb:checked");
|
||||
for (var i = 0; i < cbs.length; i++)
|
||||
names.push(cbs[i].closest(".tag-chip").textContent.trim());
|
||||
return names;
|
||||
})(),
|
||||
newTag: document.getElementById("sc-new-tag").value.trim()
|
||||
};
|
||||
}
|
||||
|
||||
function buildSpecialCakeHTML(d) {
|
||||
var parts = [];
|
||||
if (d.size) parts.push(d.size);
|
||||
if (d.flavour) parts.push(d.flavour);
|
||||
if (d.shape === "round") parts.push("okragly");
|
||||
else if (d.shape === "square") parts.push("kwadrat");
|
||||
if (d.notes) parts.push("notatka: " + d.notes);
|
||||
var detail = parts.length ? parts.join(", ") : "";
|
||||
var tagHtml = d.tagNames.length > 0 || d.newTag ? '<div style="margin-top:0.25rem;display:flex;flex-wrap:wrap;gap:0.125rem">' : "";
|
||||
for (var i = 0; i < d.tagNames.length; i++)
|
||||
tagHtml += '<span class="tag-chip" style="font-size:0.625rem;padding:0.125rem 0.375rem">' + d.tagNames[i] + "</span>";
|
||||
if (d.newTag)
|
||||
tagHtml += '<span class="tag-chip" style="font-size:0.625rem;padding:0.125rem 0.375rem">' + d.newTag + "</span>";
|
||||
if (d.tagNames.length > 0 || d.newTag) tagHtml += "</div>";
|
||||
var priceVal = Number(d.price).toFixed(2);
|
||||
var tagIdsStr = d.tagIds.join(",");
|
||||
var html =
|
||||
'<div style="flex:1;min-width:0;padding-right:0.5rem">' +
|
||||
'<div class="name">' + d.name + '</div>' +
|
||||
'<div class="detail">' + detail + '</div>' +
|
||||
tagHtml +
|
||||
'</div>' +
|
||||
'<div class="price">' + priceVal + ' PLN</div>' +
|
||||
'<div style="display:flex;flex-direction:column;gap:0.125rem">' +
|
||||
'<button type="button" class="action-btn" onclick="editSpecialCake(this)" title="Edytuj">' +
|
||||
'<span class="material-symbols-outlined" style="font-size:1rem">edit</span></button>' +
|
||||
'<button type="button" class="remove" onclick="removeSpecialCake(this)" title="Usuń">' +
|
||||
'<span class="material-symbols-outlined" style="font-size:1rem">close</span></button>' +
|
||||
'</div>' +
|
||||
'<input type="hidden" name="special_name[]" value="' + d.name + '">' +
|
||||
'<input type="hidden" name="special_price[]" value="' + d.price + '">' +
|
||||
'<input type="hidden" name="special_size[]" value="' + d.size + '">' +
|
||||
'<input type="hidden" name="special_shape[]" value="' + d.shape + '">' +
|
||||
'<input type="hidden" name="special_flavour[]" value="' + d.flavour + '">' +
|
||||
'<input type="hidden" name="special_notes[]" value="' + d.notes + '">' +
|
||||
'<input type="hidden" name="special_tags[]" value="' + tagIdsStr + '">';
|
||||
if (d.newTag)
|
||||
html += '<input type="hidden" name="special_new_tag[]" value="' + d.newTag + '">';
|
||||
return html;
|
||||
}
|
||||
|
||||
function saveSpecialCake() {
|
||||
var d = getOverlayFormData();
|
||||
if (!d.name) return;
|
||||
if (editingSpecialId) {
|
||||
var item = document.querySelector('#basket-items li[data-special-id="' + editingSpecialId + '"]');
|
||||
if (item) {
|
||||
item.innerHTML = buildSpecialCakeHTML(d);
|
||||
}
|
||||
} else {
|
||||
d.id = Date.now();
|
||||
var item = document.createElement("li");
|
||||
item.setAttribute("data-special-id", d.id);
|
||||
item.innerHTML = buildSpecialCakeHTML(d);
|
||||
document.getElementById("basket-items").appendChild(item);
|
||||
}
|
||||
closeSpecialCakeOverlay();
|
||||
updateTotals();
|
||||
}
|
||||
|
||||
function editSpecialCake(btn) {
|
||||
var item = btn.closest("li");
|
||||
var id = item.getAttribute("data-special-id");
|
||||
editingSpecialId = id;
|
||||
document.getElementById("sc-overlay-title").textContent = "Edytuj tort specjalny";
|
||||
var hidden = item.querySelectorAll('input[type="hidden"]');
|
||||
var vals = {};
|
||||
for (var i = 0; i < hidden.length; i++) {
|
||||
var name = hidden[i].getAttribute("name");
|
||||
vals[name] = hidden[i].value;
|
||||
}
|
||||
document.getElementById("sc-name").value = vals["special_name[]"] || "";
|
||||
document.getElementById("sc-price").value = vals["special_price[]"] || "";
|
||||
document.getElementById("sc-size").value = vals["special_size[]"] || "";
|
||||
document.getElementById("sc-shape").value = vals["special_shape[]"] || "";
|
||||
document.getElementById("sc-flavour").value = vals["special_flavour[]"] || "";
|
||||
document.getElementById("sc-notes").value = vals["special_notes[]"] || "";
|
||||
var currentTagIds = (vals["special_tags[]"] || "").split(",").filter(function(x) { return x; });
|
||||
document.getElementById("sc-new-tag").value = "";
|
||||
var cbs = document.querySelectorAll(".sc-tag-cb");
|
||||
for (var i = 0; i < cbs.length; i++) {
|
||||
cbs[i].checked = currentTagIds.indexOf(cbs[i].value) >= 0;
|
||||
}
|
||||
document.getElementById("sc-overlay").classList.add("open");
|
||||
document.getElementById("sc-name").focus();
|
||||
}
|
||||
|
||||
function removeSpecialCake(btn) {
|
||||
var item = btn.closest("li");
|
||||
item.remove();
|
||||
updateTotals();
|
||||
}
|
||||
|
||||
function changeCake(id, name, price, delta) {
|
||||
var input = document.querySelector('[name="cake[' + id + ']"]');
|
||||
if (input != null) {
|
||||
|
|
@ -55,20 +196,24 @@ var subtotal = 0;
|
|||
|
||||
function updatePrepaid() {
|
||||
var paid = Number(document.querySelector('[name="paid"]')?.value || 0);
|
||||
document.getElementById("paid-amount").innerText = paid + " PLN";
|
||||
document.getElementById("total-price").innerText = subtotal - paid + " PLN";
|
||||
document.getElementById("paid-amount").innerText = paid.toFixed(2) + " PLN";
|
||||
document.getElementById("total-price").innerText = (subtotal - paid).toFixed(2) + " PLN";
|
||||
}
|
||||
|
||||
function updateTotals() {
|
||||
subtotal = 0;
|
||||
var items = document.querySelectorAll("#basket-items li");
|
||||
items.forEach(function (item) {
|
||||
var priceText = item.querySelector(".detail").innerText;
|
||||
var priceText = item.querySelector(".price").innerText;
|
||||
var price = Number(priceText.split(" ")[0]);
|
||||
var qty = Number(item.querySelector(".qty").innerText);
|
||||
subtotal += price * qty;
|
||||
if (item.hasAttribute("data-special-id")) {
|
||||
subtotal += price;
|
||||
} else {
|
||||
var qty = Number(item.querySelector(".qty").innerText);
|
||||
subtotal += price * qty;
|
||||
}
|
||||
});
|
||||
document.getElementById("subtotal-price").innerText = subtotal + " PLN";
|
||||
document.getElementById("subtotal-price").innerText = subtotal.toFixed(2) + " PLN";
|
||||
updatePrepaid();
|
||||
}
|
||||
|
||||
|
|
@ -77,11 +222,48 @@ function updateCatalogueQty(id, qty) {
|
|||
if (el) el.innerText = qty;
|
||||
}
|
||||
|
||||
function filterCatalogue(input) {
|
||||
var query = input.value.toLowerCase();
|
||||
var activeCatalogueTags = [];
|
||||
|
||||
function toggleCatalogueTagFilter(btn) {
|
||||
var tag = btn.getAttribute("data-tag");
|
||||
var idx = activeCatalogueTags.indexOf(tag);
|
||||
if (idx >= 0) {
|
||||
activeCatalogueTags.splice(idx, 1);
|
||||
btn.classList.remove("active");
|
||||
} else {
|
||||
activeCatalogueTags.push(tag);
|
||||
btn.classList.add("active");
|
||||
}
|
||||
applyCatalogueFilters();
|
||||
}
|
||||
|
||||
function getCatalogueTextQuery() {
|
||||
var input = document.querySelector(
|
||||
'#catalogue-grid').closest('.card').querySelector('input[type="text"]'
|
||||
);
|
||||
return input ? input.value.toLowerCase() : "";
|
||||
}
|
||||
|
||||
function applyCatalogueFilters() {
|
||||
var query = getCatalogueTextQuery();
|
||||
var items = document.querySelectorAll("#catalogue-grid > li");
|
||||
items.forEach(function (item) {
|
||||
var name = item.getAttribute("data-name").toLowerCase();
|
||||
item.style.display = name.includes(query) ? "" : "none";
|
||||
var matchesText = name.includes(query);
|
||||
var matchesTags = true;
|
||||
if (activeCatalogueTags.length > 0) {
|
||||
var itemTags = (item.getAttribute("data-tags") || "").split(",");
|
||||
for (var i = 0; i < activeCatalogueTags.length; i++) {
|
||||
if (itemTags.indexOf(activeCatalogueTags[i]) < 0) {
|
||||
matchesTags = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
item.style.display = matchesText && matchesTags ? "" : "none";
|
||||
});
|
||||
}
|
||||
|
||||
function filterCatalogue(input) {
|
||||
applyCatalogueFilters();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue