This commit is contained in:
Ondur
2026-10-30 14:46:17 +01:00
parent 5aa554e0a6
commit e73b373e46
5 changed files with 1163 additions and 214 deletions

View File

@@ -17,76 +17,89 @@
<AuthorizeView Context="authContext"> <AuthorizeView Context="authContext">
<PageTitle>@(Id is null ? "Nová kategorie" : "Upravit kategorii")</PageTitle> <PageTitle>@(Id is null ? "Nová kategorie" : "Upravit kategorii")</PageTitle>
<div class="container-fluid py-3"> <div class="wj-admin-page container-fluid py-3">
<div class="mb-4"> <div class="wj-page-back">
<div class="text-muted small mb-1">ADMINISTRACE / KATEGORIE</div> <a href="/admin" class="wj-back-admin">
<h2 class="fw-bold mb-1">@(Id is null ? "Nová kategorie" : "Upravit kategorii")</h2> <span>←</span> Zpět na administraci
<p class="text-muted mb-0">Vyplňte základní informace o kategorii.</p> </a>
</div>
<div class="wj-heading mb-4">
<div class="wj-eyebrow">ADMINISTRACE / KATEGORIE</div>
<h2>@(Id is null ? "Nová kategorie" : "Upravit kategorii")</h2>
<p>Vyplňte základní informace o kategorii.</p>
</div> </div>
@if (notFound) @if (notFound)
{ {
<div class="alert alert-warning rounded-3"> <div class="wj-panel">
Kategorie nebyla nalezena. <div class="alert alert-warning rounded-4 mb-3">
Kategorie nebyla nalezena.
</div>
<a class="wj-button wj-button-secondary" href="/admin/kategorie">
Zpět na seznam
</a>
</div> </div>
<a class="btn btn-outline-secondary rounded-3" href="/admin/kategorie">Zpět na seznam</a>
} }
else else
{ {
<div class="card border-0 shadow-sm rounded-4" style="max-width: 720px;"> <div class="wj-form-card">
<div class="card-body p-4 p-md-5"> <div class="wj-form-header">
<div class="d-flex align-items-center gap-3 mb-4"> <div class="wj-form-icon">📁</div>
<div class="rounded-3 bg-primary bg-opacity-10 p-3 fs-3">📁</div> <div>
<div> <h4>Informace o kategorii</h4>
<h5 class="fw-bold mb-1">Informace o kategorii</h5> <p>Název a adresa kategorie</p>
<div class="text-muted small">Název a adresa kategorie</div> </div>
</div> </div>
<EditForm Model="form" OnValidSubmit="Save" FormName="categoryForm">
<DataAnnotationsValidator />
<ValidationSummary class="text-danger mb-3" />
@if (!string.IsNullOrEmpty(error))
{
<div class="alert alert-danger rounded-4">@error</div>
}
<div class="wj-field">
<label for="name">Název kategorie</label>
<InputText id="name"
class="form-control wj-input"
placeholder="Např. Cukroví"
@bind-Value="form.Name" />
<ValidationMessage For="@(() => form.Name)" class="text-danger small" />
</div> </div>
<EditForm Model="form" OnValidSubmit="Save" FormName="categoryForm"> <div class="wj-field">
<DataAnnotationsValidator /> <label for="slug">Adresa kategorie (slug)</label>
<ValidationSummary class="text-danger mb-3" /> <InputText id="slug"
class="form-control wj-input"
placeholder="napr-cukrovi"
@bind-Value="form.Slug" />
<small>Pokud pole necháte prázdné, adresa se vytvoří automaticky z názvu.</small>
</div>
@if (!string.IsNullOrEmpty(error)) <div class="wj-switch-card">
{ <div class="form-check form-switch">
<div class="alert alert-danger rounded-3">@error</div> <InputCheckbox id="active"
} class="form-check-input"
@bind-Value="form.IsActive" />
<div class="mb-4"> <label class="form-check-label fw-semibold" for="active">
<label class="form-label fw-semibold" for="name">Název kategorie</label> Aktivní kategorie
<InputText id="name" class="form-control form-control-lg rounded-3" </label>
placeholder="Např. Cukroví"
@bind-Value="form.Name" />
<ValidationMessage For="@(() => form.Name)" class="text-danger small" />
</div> </div>
<small>Aktivní kategorie může být nabízena zákazníkům.</small>
</div>
<div class="mb-4"> <div class="wj-form-actions">
<label class="form-label fw-semibold" for="slug">Adresa kategorie (slug)</label> <button type="submit" class="wj-button wj-button-primary">
<InputText id="slug" class="form-control rounded-3" Uložit kategorii
placeholder="napr-cukrovi" </button>
@bind-Value="form.Slug" /> <a class="wj-button wj-button-secondary" href="/admin/kategorie">
<div class="form-text">Pokud pole necháte prázdné, adresa se vytvoří automaticky z názvu.</div> Zrušit
</div> </a>
</div>
<div class="bg-light rounded-3 p-3 mb-4"> </EditForm>
<div class="form-check form-switch">
<InputCheckbox id="active" class="form-check-input"
@bind-Value="form.IsActive" />
<label class="form-check-label fw-semibold" for="active">Aktivní kategorie</label>
<div class="form-text">Aktivní kategorie může být nabízena zákazníkům.</div>
</div>
</div>
<div class="d-flex flex-wrap gap-2 pt-2">
<button type="submit" class="btn btn-primary rounded-3 px-4">
Uložit kategorii
</button>
<a class="btn btn-light border rounded-3 px-4" href="/admin/kategorie">
Zrušit
</a>
</div>
</EditForm>
</div>
</div> </div>
} }
</div> </div>
@@ -106,14 +119,22 @@
if (Id is null) return; if (Id is null) return;
var cat = await Db.Set<Category>().AsNoTracking().FirstOrDefaultAsync(c => c.Id == Id); var cat = await Db.Set<Category>()
.AsNoTracking()
.FirstOrDefaultAsync(c => c.Id == Id);
if (cat is null) if (cat is null)
{ {
notFound = true; notFound = true;
return; return;
} }
form = new CategoryForm { Name = cat.Name, Slug = cat.Slug, IsActive = cat.IsActive }; form = new CategoryForm
{
Name = cat.Name,
Slug = cat.Slug,
IsActive = cat.IsActive
};
} }
private async Task Save() private async Task Save()
@@ -129,7 +150,9 @@
return; return;
} }
var slugTaken = await Db.Set<Category>().AnyAsync(c => c.Slug == slug && c.Id != (Id ?? 0)); var slugTaken = await Db.Set<Category>()
.AnyAsync(c => c.Slug == slug && c.Id != (Id ?? 0));
if (slugTaken) if (slugTaken)
{ {
error = $"Slug „{slug}“ už používá jiná kategorie."; error = $"Slug „{slug}“ už používá jiná kategorie.";
@@ -138,11 +161,17 @@
if (Id is null) if (Id is null)
{ {
Db.Set<Category>().Add(new Category { Name = name, Slug = slug, IsActive = form.IsActive }); Db.Set<Category>().Add(new Category
{
Name = name,
Slug = slug,
IsActive = form.IsActive
});
} }
else else
{ {
var cat = await Db.Set<Category>().FindAsync(Id); var cat = await Db.Set<Category>().FindAsync(Id);
if (cat is null) if (cat is null)
{ {
notFound = true; notFound = true;
@@ -160,7 +189,10 @@
private static string Slugify(string text) private static string Slugify(string text)
{ {
var normalized = text.Trim().ToLowerInvariant().Normalize(NormalizationForm.FormD); var normalized = text.Trim()
.ToLowerInvariant()
.Normalize(NormalizationForm.FormD);
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var ch in normalized) foreach (var ch in normalized)

View File

@@ -3,16 +3,22 @@
@using Microsoft.EntityFrameworkCore @using Microsoft.EntityFrameworkCore
@using Web_Jarmark.Data @using Web_Jarmark.Data
@using Web_Jarmark.Data.Models @using Web_Jarmark.Data.Models
@using Microsoft.AspNetCore.Authorization
@inject ApplicationDbContext Db @inject ApplicationDbContext Db
@inject NavigationManager Nav @inject NavigationManager Nav
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize] @attribute [Authorize]
<AuthorizeView> <AuthorizeView>
<PageTitle>Kategorie</PageTitle> <PageTitle>Kategorie</PageTitle>
<div class="container-fluid py-3"> <div class="wj-admin-page container-fluid py-3">
<div class="wj-page-back">
<a href="/admin" class="wj-back-admin">
<span aria-hidden="true">←</span>
Zpět na administraci
</a>
</div>
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4"> <div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4">
<div> <div>

View File

@@ -14,120 +14,145 @@
<AuthorizeView Context="authContext1"> <AuthorizeView Context="authContext1">
<PageTitle>@(Id is null ? "Nové zboží" : "Upravit zboží")</PageTitle> <PageTitle>@(Id is null ? "Nové zboží" : "Upravit zboží")</PageTitle>
<div class="container-fluid py-3"> <div class="wj-admin-page container-fluid py-3">
<div class="mb-4"> <div class="wj-page-back">
<div class="text-muted small mb-1">ADMINISTRACE / ZBOŽÍ</div> <a href="/admin" class="wj-back-admin">
<h2 class="fw-bold mb-1">@(Id is null ? "Nové zboží" : "Upravit zboží")</h2> <span>←</span> Zpět na administraci
<p class="text-muted mb-0">Vyplňte informace o produktu.</p> </a>
</div>
<div class="wj-heading mb-4">
<div class="wj-eyebrow">ADMINISTRACE / ZBOŽÍ</div>
<h2>@(Id is null ? "Nové zboží" : "Upravit zboží")</h2>
<p>Vyplňte informace o produktu.</p>
</div> </div>
@if (notFound) @if (notFound)
{ {
<div class="alert alert-warning rounded-3">Zboží nebylo nalezeno.</div> <div class="wj-panel">
<a class="btn btn-outline-secondary rounded-3" href="/admin/zbozi">Zpět na seznam</a> <div class="alert alert-warning rounded-4">Zboží nebylo nalezeno.</div>
<a class="wj-button wj-button-secondary" href="/admin/zbozi">
Zpět na seznam
</a>
</div>
} }
else if (categories is null) else if (categories is null)
{ {
<div class="card border-0 shadow-sm rounded-4 p-4"> <div class="wj-panel p-4">
<span class="text-muted">Načítám…</span> <span class="text-muted">Načítám…</span>
</div> </div>
} }
else if (categories.Count == 0) else if (categories.Count == 0)
{ {
<div class="alert alert-warning rounded-3"> <div class="wj-panel">
Nejdříve musíš vytvořit alespoň jednu kategorii. <div class="alert alert-warning rounded-4">
<a href="/admin/kategorie/edit" class="alert-link">Přidat kategorii</a> Nejdříve musíš vytvořit alespoň jednu kategorii.
<a href="/admin/kategorie/edit" class="alert-link">Přidat kategorii</a>
</div>
</div> </div>
} }
else else
{ {
<div class="card border-0 shadow-sm rounded-4" style="max-width: 850px;"> <div class="wj-form-card wj-product-form">
<div class="card-body p-4 p-md-5"> <div class="wj-form-header">
<div class="d-flex align-items-center gap-3 mb-4"> <div class="wj-form-icon">📦</div>
<div class="rounded-3 bg-primary bg-opacity-10 p-3 fs-3">📦</div> <div>
<div> <h4>Informace o produktu</h4>
<h5 class="fw-bold mb-1">Informace o produktu</h5> <p>Základní údaje, cena a sklad</p>
<div class="text-muted small">Základní údaje, cena a sklad</div> </div>
</div> </div>
<EditForm Model="form" OnValidSubmit="Save" FormName="productForm">
<DataAnnotationsValidator />
<ValidationSummary class="text-danger mb-3" />
@if (!string.IsNullOrEmpty(error))
{
<div class="alert alert-danger rounded-4">@error</div>
}
<div class="wj-field">
<label for="name">Název zboží</label>
<InputText id="name"
class="form-control wj-input"
placeholder="Např. Domácí cukroví"
@bind-Value="form.Name" />
<ValidationMessage For="@(() => form.Name)" class="text-danger small" />
</div> </div>
<EditForm Model="form" OnValidSubmit="Save" FormName="productForm"> <div class="wj-field">
<DataAnnotationsValidator /> <label for="cat">Kategorie</label>
<ValidationSummary class="text-danger mb-3" /> <InputSelect id="cat"
class="form-select wj-input"
@bind-Value="form.CategoryId">
<option value="0">– Vyber kategorii –</option>
@foreach (var c in categories)
{
<option value="@c.Id">@c.Name@(c.IsActive ? "" : " (neaktivní)")</option>
}
</InputSelect>
</div>
@if (!string.IsNullOrEmpty(error)) <div class="wj-field">
{ <label for="desc">Popis produktu</label>
<div class="alert alert-danger rounded-3">@error</div> <InputTextArea id="desc"
} class="form-control wj-input"
rows="4"
placeholder="Popište produkt…"
@bind-Value="form.Description" />
</div>
<div class="mb-4"> <div class="row g-3">
<label class="form-label fw-semibold" for="name">Název zboží</label> <div class="col-md-6">
<InputText id="name" class="form-control form-control-lg rounded-3" <div class="wj-field">
placeholder="Např. Domácí cukroví" <label for="price">Cena (Kč)</label>
@bind-Value="form.Name" /> <InputNumber id="price"
<ValidationMessage For="@(() => form.Name)" class="text-danger small" /> class="form-control wj-input"
</div>
<div class="mb-4">
<label class="form-label fw-semibold" for="cat">Kategorie</label>
<InputSelect id="cat" class="form-select rounded-3" @bind-Value="form.CategoryId">
<option value="0">– Vyber kategorii –</option>
@foreach (var c in categories)
{
<option value="@c.Id">@c.Name@(c.IsActive ? "" : " (neaktivní)")</option>
}
</InputSelect>
</div>
<div class="mb-4">
<label class="form-label fw-semibold" for="desc">Popis produktu</label>
<InputTextArea id="desc" class="form-control rounded-3" rows="4"
placeholder="Popište produkt…"
@bind-Value="form.Description" />
</div>
<div class="row g-3 mb-4">
<div class="col-md-6">
<label class="form-label fw-semibold" for="price">Cena (Kč)</label>
<InputNumber id="price" class="form-control rounded-3"
@bind-Value="form.Price" /> @bind-Value="form.Price" />
<ValidationMessage For="@(() => form.Price)" class="text-danger small" /> <ValidationMessage For="@(() => form.Price)" class="text-danger small" />
</div> </div>
<div class="col-md-6"> </div>
<label class="form-label fw-semibold" for="stock">Skladem (ks)</label> <div class="col-md-6">
<InputNumber id="stock" class="form-control rounded-3" <div class="wj-field">
<label for="stock">Skladem (ks)</label>
<InputNumber id="stock"
class="form-control wj-input"
@bind-Value="form.StockQuantity" /> @bind-Value="form.StockQuantity" />
<ValidationMessage For="@(() => form.StockQuantity)" class="text-danger small" /> <ValidationMessage For="@(() => form.StockQuantity)" class="text-danger small" />
</div> </div>
</div> </div>
</div>
<div class="mb-4"> <div class="wj-field">
<label class="form-label fw-semibold" for="img">Adresa obrázku</label> <label for="img">Adresa obrázku</label>
<InputText id="img" class="form-control rounded-3" <InputText id="img"
placeholder="/images/produkt.jpg" class="form-control wj-input"
@bind-Value="form.ImageUrl" /> placeholder="/images/produkt.jpg"
<div class="form-text">Např. /images/cukrovi.jpg (soubor v wwwroot) nebo celá internetová adresa.</div> @bind-Value="form.ImageUrl" />
</div> <small>Např. /images/cukrovi.jpg (soubor v wwwroot) nebo celá internetová adresa.</small>
</div>
<div class="bg-light rounded-3 p-3 mb-4"> <div class="wj-switch-card">
<div class="form-check form-switch"> <div class="form-check form-switch">
<InputCheckbox id="visible" class="form-check-input" <InputCheckbox id="visible"
@bind-Value="form.IsVisible" /> class="form-check-input"
<label class="form-check-label fw-semibold" for="visible">Viditelné v katalogu</label> @bind-Value="form.IsVisible" />
<div class="form-text">Pokud je zapnuto, zákazníci produkt uvidí v e-shopu.</div> <label class="form-check-label fw-semibold" for="visible">
</div> Viditelné v katalogu
</label>
</div> </div>
<small>Pokud je zapnuto, zákazníci produkt uvidí v e-shopu.</small>
</div>
<div class="d-flex flex-wrap gap-2 pt-2"> <div class="wj-form-actions">
<button type="submit" class="btn btn-primary rounded-3 px-4"> <button type="submit" class="wj-button wj-button-primary">
Uložit zboží Uložit zboží
</button> </button>
<a class="btn btn-light border rounded-3 px-4" href="/admin/zbozi"> <a class="wj-button wj-button-secondary" href="/admin/zbozi">
Zrušit Zrušit
</a> </a>
</div> </div>
</EditForm> </EditForm>
</div>
</div> </div>
} }
</div> </div>
@@ -146,11 +171,17 @@
notFound = false; notFound = false;
error = null; error = null;
categories = await Db.Set<Category>().AsNoTracking().OrderBy(c => c.Name).ToListAsync(); categories = await Db.Set<Category>()
.AsNoTracking()
.OrderBy(c => c.Name)
.ToListAsync();
if (Id is null) return; if (Id is null) return;
var p = await Db.Set<Product>().AsNoTracking().FirstOrDefaultAsync(x => x.Id == Id); var p = await Db.Set<Product>()
.AsNoTracking()
.FirstOrDefaultAsync(x => x.Id == Id);
if (p is null) if (p is null)
{ {
notFound = true; notFound = true;
@@ -188,6 +219,7 @@
else else
{ {
var p = await Db.Set<Product>().FindAsync(Id); var p = await Db.Set<Product>().FindAsync(Id);
if (p is null) if (p is null)
{ {
notFound = true; notFound = true;

View File

@@ -11,26 +11,32 @@
<AuthorizeView> <AuthorizeView>
<PageTitle>Zboží</PageTitle> <PageTitle>Zboží</PageTitle>
<div class="container-fluid py-3"> <div class="wj-admin-page container-fluid py-3">
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4"> <div class="wj-page-back">
<a href="/admin" class="wj-back-admin">
<span>←</span> Zpět na administraci
</a>
</div>
<div class="wj-heading d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4">
<div> <div>
<div class="text-muted small mb-1">ADMINISTRACE / SPRÁVA OBCHODU</div> <div class="wj-eyebrow">ADMINISTRACE / SPRÁVA OBCHODU</div>
<h2 class="fw-bold mb-1">Zboží</h2> <h2>Zboží</h2>
<p class="text-muted mb-0">Přehled a správa produktů v obchodě.</p> <p>Přehled a správa produktů v obchodě.</p>
</div> </div>
<a class="btn btn-primary rounded-3 px-4 py-2 shadow-sm" href="/admin/zbozi/edit"> <a class="wj-button wj-button-primary" href="/admin/zbozi/edit">
+ Nové zboží + Nové zboží
</a> </a>
</div> </div>
@if (!string.IsNullOrEmpty(error)) @if (!string.IsNullOrEmpty(error))
{ {
<div class="alert alert-danger rounded-3">@error</div> <div class="alert alert-danger rounded-4">@error</div>
} }
@if (products is null) @if (products is null)
{ {
<div class="card border-0 shadow-sm rounded-4 p-4"> <div class="wj-panel p-4">
<span class="text-muted">Načítám zboží…</span> <span class="text-muted">Načítám zboží…</span>
</div> </div>
} }
@@ -38,53 +44,43 @@
{ {
<div class="row g-3 mb-4"> <div class="row g-3 mb-4">
<div class="col-sm-6 col-xl-4"> <div class="col-sm-6 col-xl-4">
<div class="card border-0 shadow-sm rounded-4 h-100"> <div class="wj-stat-card">
<div class="card-body p-4 d-flex align-items-center gap-3"> <div class="wj-stat-icon">📦</div>
<div class="rounded-3 bg-primary bg-opacity-10 p-3 fs-3">📦</div> <div class="wj-stat-label">Celkem produktů</div>
<div> <div class="wj-stat-value">@products.Count</div>
<div class="text-muted small">Celkem produktů</div>
<div class="fs-3 fw-bold">@products.Count</div>
</div>
</div>
</div> </div>
</div> </div>
<div class="col-sm-6 col-xl-4"> <div class="col-sm-6 col-xl-4">
<div class="card border-0 shadow-sm rounded-4 h-100"> <div class="wj-stat-card">
<div class="card-body p-4 d-flex align-items-center gap-3"> <div class="wj-stat-icon">✓</div>
<div class="rounded-3 bg-success bg-opacity-10 p-3 fs-3">✓</div> <div class="wj-stat-label">Viditelné produkty</div>
<div> <div class="wj-stat-value">@products.Count(p => p.IsVisible)</div>
<div class="text-muted small">Viditelné produkty</div>
<div class="fs-3 fw-bold">@products.Count(p => p.IsVisible)</div>
</div>
</div>
</div> </div>
</div> </div>
<div class="col-sm-6 col-xl-4"> <div class="col-sm-6 col-xl-4">
<div class="card border-0 shadow-sm rounded-4 h-100"> <div class="wj-stat-card">
<div class="card-body p-4 d-flex align-items-center gap-3"> <div class="wj-stat-icon">📉</div>
<div class="rounded-3 bg-warning bg-opacity-10 p-3 fs-3">📉</div> <div class="wj-stat-label">Dochází skladem (5 a méně)</div>
<div> <div class="wj-stat-value">@products.Count(p => p.StockQuantity <= 5)</div>
<div class="text-muted small">Dochází skladem (5 a méně)</div>
<div class="fs-3 fw-bold">@products.Count(p => p.StockQuantity <= 5)</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="card border-0 shadow-sm rounded-4 overflow-hidden"> <div class="wj-panel p-0 overflow-hidden">
<div class="card-header bg-white border-0 p-4"> <div class="p-4 d-flex flex-wrap justify-content-between align-items-center gap-3">
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3"> <div>
<div> <h4 class="fw-bold mb-1">Přehled produktů</h4>
<h5 class="fw-bold mb-1">Přehled produktů</h5> <p class="text-muted mb-0 small">Všechny produkty v e-shopu</p>
<div class="text-muted small">Všechny produkty v e-shopu</div> </div>
</div>
<div style="width: min(100%, 320px);"> <div class="wj-search">
<input class="form-control rounded-3" <span>⌕</span>
placeholder="Hledat zboží nebo kategorii…" <input class="form-control"
@bind="searchTerm" placeholder="Hledat zboží nebo kategorii…"
@bind:event="oninput" /> @bind="searchTerm"
</div> @bind:event="oninput" />
</div> </div>
</div> </div>
@@ -99,37 +95,40 @@
else else
{ {
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover align-middle mb-0"> <table class="table wj-table align-middle mb-0">
<thead class="table-light"> <thead>
<tr> <tr>
<th class="ps-4 py-3">Název zboží</th> <th class="ps-4">Název zboží</th>
<th class="py-3">Kategorie</th> <th>Kategorie</th>
<th class="text-end py-3">Cena</th> <th class="text-end">Cena</th>
<th class="text-center py-3">Skladem</th> <th class="text-center">Skladem</th>
<th class="text-center py-3">Viditelnost</th> <th class="text-center">Viditelnost</th>
<th class="text-end pe-4 py-3">Akce</th> <th class="text-end pe-4">Akce</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var p in FilteredProducts) @foreach (var p in FilteredProducts)
{ {
<tr> <tr>
<td class="ps-4 py-3 fw-semibold">@p.Name</td> <td class="ps-4 fw-semibold">@p.Name</td>
<td><span class="badge bg-light text-dark rounded-pill px-3 py-2">@p.CategoryName</span></td> <td>
<span class="wj-tag">@p.CategoryName</span>
</td>
<td class="text-end fw-semibold">@p.Price.ToString("N2") Kč</td> <td class="text-end fw-semibold">@p.Price.ToString("N2") Kč</td>
<td class="text-center"> <td class="text-center">
@if (p.StockQuantity <= 5) @if (p.StockQuantity <= 5)
{ {
<span class="badge bg-warning bg-opacity-10 text-dark rounded-pill px-3 py-2">@p.StockQuantity ks</span> <span class="wj-stock-low">@p.StockQuantity ks</span>
} }
else else
{ {
<span class="badge bg-light text-dark rounded-pill px-3 py-2">@p.StockQuantity ks</span> <span class="wj-tag">@p.StockQuantity ks</span>
} }
</td> </td>
<td class="text-center"> <td class="text-center">
<div class="form-check form-switch d-flex justify-content-center"> <div class="form-check form-switch d-flex justify-content-center">
<input type="checkbox" class="form-check-input" <input type="checkbox"
class="form-check-input"
checked="@p.IsVisible" checked="@p.IsVisible"
title="Změnit viditelnost" title="Změnit viditelnost"
@onchange="() => ToggleVisible(p.Id)" /> @onchange="() => ToggleVisible(p.Id)" />
@@ -138,9 +137,10 @@
</td> </td>
<td class="text-end pe-4"> <td class="text-end pe-4">
<div class="d-flex justify-content-end gap-2"> <div class="d-flex justify-content-end gap-2">
<a class="btn btn-sm btn-outline-primary rounded-3 px-3" <a class="wj-small-button" href="/admin/zbozi/edit/@p.Id">
href="/admin/zbozi/edit/@p.Id">Upravit</a> Upravit
<button class="btn btn-sm btn-outline-danger rounded-3 px-3" </a>
<button class="wj-small-button wj-danger-button"
@onclick="() => Delete(p.Id)"> @onclick="() => Delete(p.Id)">
Smazat Smazat
</button> </button>
@@ -153,8 +153,10 @@
</div> </div>
} }
<div class="card-footer bg-white border-0 px-4 py-3"> <div class="border-top px-4 py-3">
<small class="text-muted">Zobrazeno: @FilteredProducts.Count z @products.Count produktů</small> <small class="text-muted">
Zobrazeno: @FilteredProducts.Count z @products.Count produktů
</small>
</div> </div>
</div> </div>
} }
@@ -180,7 +182,13 @@
products = await Db.Set<Product>() products = await Db.Set<Product>()
.AsNoTracking() .AsNoTracking()
.OrderBy(p => p.Name) .OrderBy(p => p.Name)
.Select(p => new ProductRow(p.Id, p.Name, p.Category.Name, p.Price, p.StockQuantity, p.IsVisible)) .Select(p => new ProductRow(
p.Id,
p.Name,
p.Category.Name,
p.Price,
p.StockQuantity,
p.IsVisible))
.ToListAsync(); .ToListAsync();
} }
@@ -216,5 +224,11 @@
await Load(); await Load();
} }
private record ProductRow(int Id, string Name, string CategoryName, decimal Price, int StockQuantity, bool IsVisible); private record ProductRow(
int Id,
string Name,
string CategoryName,
decimal Price,
int StockQuantity,
bool IsVisible);
} }

View File

@@ -1244,3 +1244,868 @@ body {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
} }
/* =========================================
WEB-JARMARK – JEDNOTNÝ ADMIN DESIGN
Jemný, èernobílý, zaoblený a responzivní
========================================= */
.wj-admin-page {
--wj-bg: #f6f6f7;
--wj-white: #fff;
--wj-text: #191919;
--wj-muted: #85858d;
--wj-border: #ededee;
color: var(--wj-text);
font-family: Inter, "Segoe UI", Arial, sans-serif;
animation: wj-page-enter .45s ease both;
}
@keyframes wj-page-enter {
from {
opacity: 0;
transform: translateY(9px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.wj-admin-page *,
.wj-admin-page *::before,
.wj-admin-page *::after {
box-sizing: border-box;
}
/* Návrat na dashboard */
.wj-page-back {
margin-bottom: 25px;
}
.wj-back-admin {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 11px 17px;
color: #292929;
background: #fff;
border: 1px solid var(--wj-border);
border-radius: 15px;
text-decoration: none;
font-size: 13px;
font-weight: 650;
box-shadow: 0 3px 12px rgba(0, 0, 0, .035);
transition: all .25s ease;
}
.wj-back-admin span {
font-size: 19px;
transition: transform .25s ease;
}
.wj-back-admin:hover {
background: #171717;
color: #fff;
border-color: #171717;
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
}
.wj-back-admin:hover span {
transform: translateX(-4px);
}
/* Nadpisy */
.wj-heading h2 {
margin: 0;
color: #171717;
font-size: clamp(25px, 3vw, 33px);
font-weight: 780;
letter-spacing: -1px;
}
.wj-heading p {
color: var(--wj-muted);
margin: 8px 0 0;
font-size: 14px;
}
.wj-eyebrow {
color: #99999f;
font-size: 10px;
letter-spacing: 1.4px;
font-weight: 750;
margin-bottom: 9px;
}
/* Panely a karty */
.wj-panel,
.wj-form-card,
.wj-stat-card {
background: #fff;
border: 1px solid var(--wj-border);
border-radius: 22px;
box-shadow: 0 5px 20px rgba(0, 0, 0, .035);
transition: transform .25s ease, box-shadow .25s ease;
}
.wj-panel:hover,
.wj-stat-card:hover {
box-shadow: 0 12px 28px rgba(0, 0, 0, .065);
}
.wj-stat-card {
height: 100%;
min-height: 145px;
padding: 23px;
}
.wj-stat-icon {
display: grid;
place-items: center;
width: 42px;
height: 42px;
margin-bottom: 17px;
border-radius: 14px;
background: #f1f1f2;
font-size: 20px;
}
.wj-stat-label {
color: #85858d;
font-size: 12px;
}
.wj-stat-value {
margin-top: 5px;
color: #171717;
font-size: 30px;
font-weight: 780;
letter-spacing: -1px;
}
/* Tlaèítka */
.wj-button {
display: inline-flex;
justify-content: center;
align-items: center;
gap: 8px;
min-height: 43px;
padding: 11px 19px;
border: 1px solid transparent;
border-radius: 14px;
font-size: 13px;
font-weight: 650;
text-decoration: none;
cursor: pointer;
transition: all .23s ease;
}
.wj-button-primary {
color: #fff;
background: #171717;
border-color: #171717;
box-shadow: 0 4px 12px rgba(0, 0, 0, .10);
}
.wj-button-primary:hover {
color: #fff;
background: #383838;
border-color: #383838;
transform: translateY(-2px);
box-shadow: 0 8px 18px rgba(0, 0, 0, .15);
}
.wj-button-secondary {
color: #333;
background: #fff;
border-color: #e7e7e9;
}
.wj-button-secondary:hover {
color: #111;
background: #f3f3f4;
border-color: #d8d8da;
transform: translateY(-2px);
}
.wj-small-button {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 7px 12px;
border: 1px solid #e5e5e7;
border-radius: 10px;
background: #fff;
color: #222;
text-decoration: none;
font-size: 11px;
font-weight: 650;
cursor: pointer;
transition: all .2s ease;
}
.wj-small-button:hover {
color: #fff;
background: #171717;
border-color: #171717;
}
.wj-danger-button {
color: #a33b3b;
border-color: #f0dddd;
}
.wj-danger-button:hover {
color: #fff;
background: #a33b3b;
border-color: #a33b3b;
}
/* Tabulky */
.wj-table {
border-collapse: separate;
border-spacing: 0;
}
.wj-table thead th {
padding: 15px 12px;
color: #92929a;
background: #f8f8f9;
border-top: 1px solid #f0f0f1;
border-bottom: 1px solid #ededee;
font-size: 10px;
font-weight: 750;
letter-spacing: .5px;
white-space: nowrap;
}
.wj-table tbody td {
padding: 16px 12px;
color: #55555d;
border-bottom: 1px solid #f0f0f1;
font-size: 12px;
}
.wj-table tbody tr {
transition: background .2s ease;
}
.wj-table tbody tr:hover {
background: #fafafa;
}
.wj-table tbody tr:last-child td {
border-bottom: 0;
}
.wj-table .fw-semibold {
color: #222;
}
.wj-tag {
display: inline-block;
padding: 6px 11px;
border-radius: 30px;
background: #f0f0f1;
color: #424248;
font-size: 10px;
font-weight: 650;
}
.wj-stock-low {
display: inline-block;
padding: 6px 11px;
border-radius: 30px;
background: #fff0dc;
color: #85520a;
font-size: 10px;
font-weight: 700;
}
/* Vyhledávání */
.wj-search {
display: flex;
align-items: center;
gap: 9px;
width: min(100%, 340px);
padding: 0 13px;
border: 1px solid #e8e8ea;
border-radius: 14px;
background: #fafafa;
transition: border-color .2s ease, box-shadow .2s ease;
}
.wj-search:focus-within {
border-color: #a8a8ad;
box-shadow: 0 0 0 4px rgba(0, 0, 0, .045);
}
.wj-search > span {
color: #777;
font-size: 21px;
}
.wj-search .form-control {
min-width: 0;
padding: 12px 0;
border: 0;
outline: 0;
box-shadow: none;
background: transparent;
font-size: 12px;
}
/* Formuláøe */
.wj-form-card {
max-width: 850px;
padding: 30px;
}
.wj-form-header {
display: flex;
align-items: center;
gap: 15px;
margin-bottom: 29px;
padding-bottom: 22px;
border-bottom: 1px solid #eeeeef;
}
.wj-form-icon {
display: grid;
place-items: center;
width: 51px;
height: 51px;
flex-shrink: 0;
border-radius: 17px;
background: #f1f1f2;
font-size: 23px;
}
.wj-form-header h4 {
margin: 0;
color: #171717;
font-size: 17px;
font-weight: 750;
}
.wj-form-header p {
margin: 5px 0 0;
color: #92929a;
font-size: 12px;
}
.wj-field {
margin-bottom: 23px;
}
.wj-field label {
display: block;
margin-bottom: 9px;
color: #292929;
font-size: 12px;
font-weight: 700;
}
.wj-field small {
display: block;
margin-top: 8px;
color: #92929a;
font-size: 11px;
line-height: 1.5;
}
.wj-input {
min-height: 48px;
padding: 12px 15px;
border: 1px solid #e6e6e8;
border-radius: 14px;
background: #fafafa;
color: #222;
font-size: 13px;
box-shadow: none;
transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
textarea.wj-input {
min-height: 115px;
resize: vertical;
}
.wj-input:focus {
border-color: #99999f;
background: #fff;
box-shadow: 0 0 0 4px rgba(0, 0, 0, .045);
}
.wj-switch-card {
margin: 24px 0;
padding: 17px;
border: 1px solid #ededee;
border-radius: 16px;
background: #fafafa;
}
.wj-switch-card small {
display: block;
margin: 7px 0 0 31px;
color: #92929a;
font-size: 11px;
}
.wj-switch-card .form-check-input {
cursor: pointer;
}
.wj-form-actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
padding-top: 9px;
margin-top: 25px;
border-top: 1px solid #eeeeef;
}
.wj-admin-page .form-check-input {
cursor: pointer;
}
.wj-admin-page .alert {
border: 0;
border-radius: 15px;
}
/* Responzivní zobrazení */
@media (max-width: 700px) {
.wj-form-card {
padding: 21px 17px;
border-radius: 18px;
}
.wj-stat-card {
min-height: 130px;
padding: 17px;
border-radius: 17px;
}
.wj-stat-value {
font-size: 25px;
}
.wj-heading h2 {
font-size: 26px;
}
.wj-search {
width: 100%;
}
.wj-table tbody td {
padding: 13px 10px;
}
.wj-page-back {
margin-bottom: 19px;
}
}
@media (prefers-reduced-motion: reduce) {
.wj-admin-page,
.wj-admin-page *,
.wj-admin-page *::before,
.wj-admin-page *::after {
animation-duration: .01ms !important;
transition-duration: .01ms !important;
scroll-behavior: auto !important;
}
}
/* ==========================================
WEB-JARMARK – PREMIUM ADMIN DESIGN
Jemný, elegantní, moderní a smooth
========================================== */
.wj-admin-page {
--wj-black: #171717;
--wj-white: #ffffff;
--wj-muted: #85858d;
--wj-line: #eeeeef;
--wj-soft: #f7f7f8;
padding: 30px !important;
color: var(--wj-black);
background: radial-gradient(ellipse at 10% 0%, rgba(0,0,0,.025), transparent 35%), #f7f7f8;
min-height: 100vh;
}
/* Plynulé naètení */
.wj-admin-page {
animation: wj-premium-enter .55s cubic-bezier(.2,.8,.2,1);
}
@keyframes wj-premium-enter {
from {
opacity: 0;
transform: translateY(14px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Nadpisy */
.wj-heading {
padding: 8px 2px 20px;
}
.wj-heading h2 {
font-size: clamp(29px, 3vw, 37px);
font-weight: 800;
letter-spacing: -1.5px;
}
.wj-heading p {
font-size: 14px;
color: #92929a;
}
.wj-eyebrow {
font-size: 9px;
letter-spacing: 1.8px;
color: #a0a0a6;
}
/* Návratové tlaèítko */
.wj-back-admin {
border-radius: 50px;
padding: 12px 19px;
background: rgba(255,255,255,.85);
backdrop-filter: blur(12px);
box-shadow: 0 4px 15px rgba(0,0,0,.035);
}
.wj-back-admin:hover {
transform: translateY(-3px);
box-shadow: 0 10px 25px rgba(0,0,0,.12);
}
/* Karty */
.wj-panel,
.wj-form-card,
.wj-stat-card {
border: 1px solid rgba(230,230,233,.9);
border-radius: 25px !important;
background: rgba(255,255,255,.96);
box-shadow: 0 2px 5px rgba(0,0,0,.015), 0 12px 35px rgba(0,0,0,.035);
transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s ease, border-color .3s ease;
}
.wj-panel:hover,
.wj-stat-card:hover {
transform: translateY(-4px);
border-color: #dedee1;
box-shadow: 0 18px 42px rgba(0,0,0,.065);
}
.wj-stat-card {
padding: 25px;
position: relative;
overflow: hidden;
}
.wj-stat-card::after {
content: "";
position: absolute;
width: 100px;
height: 100px;
right: -35px;
top: -35px;
border-radius: 50%;
background: rgba(0,0,0,.025);
transition: transform .35s ease;
}
.wj-stat-card:hover::after {
transform: scale(1.5);
}
.wj-stat-icon {
width: 47px;
height: 47px;
border-radius: 16px;
background: #f1f1f2;
color: #171717;
font-size: 21px;
}
.wj-stat-value {
font-size: 34px;
letter-spacing: -1.7px;
font-weight: 800;
}
/* Tlaèítka */
.wj-button {
min-height: 47px;
padding: 12px 23px;
border-radius: 15px;
font-size: 13px;
letter-spacing: .1px;
transition: all .25s cubic-bezier(.2,.8,.2,1);
}
.wj-button-primary {
background: #171717;
border-color: #171717;
box-shadow: 0 5px 14px rgba(0,0,0,.12);
}
.wj-button-primary:hover {
background: #353535;
transform: translateY(-3px);
box-shadow: 0 11px 23px rgba(0,0,0,.17);
}
.wj-button-secondary {
background: #fff;
border: 1px solid #e6e6e8;
border-radius: 15px;
}
.wj-button-secondary:hover {
background: #f4f4f5;
transform: translateY(-2px);
}
/* Tabulky */
.wj-panel .table-responsive {
border-radius: 0 0 25px 25px;
}
.wj-table {
border-collapse: separate;
border-spacing: 0;
}
.wj-table thead th {
padding-top: 18px;
padding-bottom: 18px;
background: #f8f8f9;
color: #9999a0;
font-size: 9px;
text-transform: uppercase;
letter-spacing: 1px;
border-color: #eeeeef;
}
.wj-table tbody td {
padding-top: 19px;
padding-bottom: 19px;
font-size: 12px;
border-color: #f0f0f1;
}
.wj-table tbody tr {
transition: background .2s ease;
}
.wj-table tbody tr:hover {
background: #f8f8f9;
}
.wj-small-button {
padding: 9px 15px;
border-radius: 12px;
font-size: 11px;
}
.wj-tag {
border-radius: 50px;
padding: 7px 13px;
}
/* Vyhledávání */
.wj-search {
border-radius: 16px;
padding-left: 16px;
background: #f8f8f9;
border-color: #ebebed;
}
.wj-search .form-control {
font-size: 13px;
}
.wj-search:focus-within {
background: white;
border-color: #b5b5ba;
box-shadow: 0 0 0 5px rgba(0,0,0,.035);
}
/* Formuláøe */
.wj-form-card {
max-width: 900px;
padding: 34px;
}
.wj-form-header {
gap: 17px;
padding-bottom: 25px;
margin-bottom: 30px;
}
.wj-form-icon {
width: 57px;
height: 57px;
border-radius: 19px;
background: #f1f1f2;
}
.wj-form-header h4 {
font-size: 19px;
letter-spacing: -.4px;
}
.wj-field {
margin-bottom: 26px;
}
.wj-field label {
font-size: 12px;
margin-bottom: 10px;
font-weight: 750;
}
.wj-input {
min-height: 53px;
padding: 14px 17px;
border-radius: 15px;
border: 1px solid #e8e8ea;
background: #fafafa;
font-size: 13px;
transition: all .25s ease;
}
.wj-input:hover {
border-color: #d1d1d4;
}
.wj-input:focus {
background: #fff;
border-color: #77777e;
box-shadow: 0 0 0 5px rgba(0,0,0,.045);
}
textarea.wj-input {
min-height: 140px;
line-height: 1.6;
}
.wj-switch-card {
padding: 21px;
border-radius: 17px;
background: #f8f8f9;
border-color: #eeeeef;
transition: background .2s ease;
}
.wj-switch-card:hover {
background: #f1f1f2;
}
.wj-form-actions {
padding-top: 24px;
margin-top: 30px;
}
/* Pøepínaèe */
.wj-admin-page .form-check-input {
width: 2.6em;
height: 1.35em;
cursor: pointer;
box-shadow: none;
transition: background-color .2s ease;
}
.wj-admin-page .form-check-input:checked {
background-color: #171717;
border-color: #171717;
}
/* Znaèky stavu */
.wj-stock-low {
border-radius: 50px;
padding: 8px 13px;
}
.wj-admin-page .badge {
border-radius: 50px;
font-weight: 650;
}
/* Chybové a informaèní hlášky */
.wj-admin-page .alert {
padding: 16px 19px;
border-radius: 16px;
}
/* Mobilní zobrazení */
@media (max-width: 768px) {
.wj-admin-page {
padding: 18px 12px !important;
}
.wj-form-card {
padding: 22px 17px;
border-radius: 20px !important;
}
.wj-stat-card {
padding: 18px;
border-radius: 19px !important;
}
.wj-heading h2 {
font-size: 28px;
}
.wj-form-actions .wj-button {
flex: 1 1 100%;
}
}
/* Respektování nastavení omezení animací */
@media (prefers-reduced-motion: reduce) {
.wj-admin-page,
.wj-admin-page *,
.wj-admin-page *::before,
.wj-admin-page *::after {
animation: none !important;
transition: none !important;
scroll-behavior: auto !important;
}
}