Initial commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
@model PowderCoating.Core.Entities.DashboardTip
|
||||
@{
|
||||
ViewData["Title"] = "Add Dashboard Tip";
|
||||
}
|
||||
|
||||
<div class="container py-4" style="max-width:700px">
|
||||
<div class="d-flex align-items-center mb-4">
|
||||
<a asp-action="Index" class="btn btn-sm btn-outline-secondary me-3">
|
||||
<i class="bi bi-arrow-left me-1"></i>Back
|
||||
</a>
|
||||
<h4 class="mb-0"><i class="bi bi-lightbulb me-2 text-warning"></i>Add Tip</h4>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form method="post" asp-action="Create">
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="mb-4">
|
||||
<label asp-for="TipText" class="form-label fw-semibold">Tip Text <span class="text-danger">*</span></label>
|
||||
<textarea asp-for="TipText" class="form-control" rows="4"
|
||||
placeholder="Enter the tip shown to users on the dashboard..."
|
||||
maxlength="500"></textarea>
|
||||
<div class="d-flex justify-content-between mt-1">
|
||||
<span asp-validation-for="TipText" class="text-danger small"></span>
|
||||
<span class="text-muted small" id="charCount">0 / 500</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" asp-for="IsActive" id="IsActive" checked />
|
||||
<label class="form-check-label fw-semibold" for="IsActive">Active</label>
|
||||
</div>
|
||||
<div class="form-text">Inactive tips are stored but never shown to users.</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>Add Tip
|
||||
</button>
|
||||
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
const ta = document.querySelector('textarea[name="TipText"]');
|
||||
const counter = document.getElementById('charCount');
|
||||
function updateCount() {
|
||||
const len = ta.value.length;
|
||||
counter.textContent = len + ' / 500';
|
||||
counter.className = 'text-' + (len > 450 ? (len >= 500 ? 'danger' : 'warning') : 'muted') + ' small';
|
||||
}
|
||||
ta.addEventListener('input', updateCount);
|
||||
updateCount();
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
@model PowderCoating.Core.Entities.DashboardTip
|
||||
@{
|
||||
ViewData["Title"] = "Edit Dashboard Tip";
|
||||
}
|
||||
|
||||
<div class="container py-4" style="max-width:700px">
|
||||
<div class="d-flex align-items-center mb-4">
|
||||
<a asp-action="Index" class="btn btn-sm btn-outline-secondary me-3">
|
||||
<i class="bi bi-arrow-left me-1"></i>Back
|
||||
</a>
|
||||
<h4 class="mb-0"><i class="bi bi-pencil me-2 text-primary"></i>Edit Tip</h4>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form method="post" asp-action="Edit" asp-route-id="@Model.Id">
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="mb-4">
|
||||
<label asp-for="TipText" class="form-label fw-semibold">Tip Text <span class="text-danger">*</span></label>
|
||||
<textarea asp-for="TipText" class="form-control" rows="4" maxlength="500">@Model.TipText</textarea>
|
||||
<div class="d-flex justify-content-between mt-1">
|
||||
<span asp-validation-for="TipText" class="text-danger small"></span>
|
||||
<span class="text-muted small" id="charCount">0 / 500</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" asp-for="IsActive" id="IsActive" />
|
||||
<label class="form-check-label fw-semibold" for="IsActive">Active</label>
|
||||
</div>
|
||||
<div class="form-text">Inactive tips are stored but never shown to users.</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-check-lg me-1"></i>Save Changes
|
||||
</button>
|
||||
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-muted small mt-3 ps-1">
|
||||
<i class="bi bi-clock me-1"></i>Added @Model.CreatedAt.ToString("MMMM d, yyyy")
|
||||
· ID #@Model.Id
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
const ta = document.querySelector('textarea[name="TipText"]');
|
||||
const counter = document.getElementById('charCount');
|
||||
function updateCount() {
|
||||
const len = ta.value.length;
|
||||
counter.textContent = len + ' / 500';
|
||||
counter.className = 'text-' + (len > 450 ? (len >= 500 ? 'danger' : 'warning') : 'muted') + ' small';
|
||||
}
|
||||
ta.addEventListener('input', updateCount);
|
||||
updateCount();
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
@model List<PowderCoating.Core.Entities.DashboardTip>
|
||||
@{
|
||||
ViewData["Title"] = "Dashboard Tips";
|
||||
int page = (int)ViewBag.Page;
|
||||
int totalPages = (int)ViewBag.TotalPages;
|
||||
int total = (int)ViewBag.Total;
|
||||
int activeCount = (int)ViewBag.ActiveCount;
|
||||
int totalCount = (int)ViewBag.TotalCount;
|
||||
string? search = ViewBag.Search as string;
|
||||
bool activeOnly = (bool)ViewBag.ActiveOnly;
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
<style>
|
||||
[data-bs-theme="dark"] a.text-dark { color: var(--bs-body-color) !important; }
|
||||
</style>
|
||||
}
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<div>
|
||||
<h4 class="mb-0"><i class="bi bi-lightbulb me-2 text-warning"></i>Dashboard Tips</h4>
|
||||
<p class="text-muted mb-0 small">Tips shown to users on the dashboard welcome section. Displayed randomly, one per session.</p>
|
||||
</div>
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>Add Tip
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if (TempData["Success"] != null)
|
||||
{
|
||||
<div class="alert alert-success alert-permanent mb-3">@TempData["Success"]</div>
|
||||
}
|
||||
|
||||
<!-- Stats row -->
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="card text-center shadow-sm h-100">
|
||||
<div class="card-body py-3">
|
||||
<div class="fs-3 fw-bold text-primary">@totalCount</div>
|
||||
<div class="small text-muted">Total Tips</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="card text-center shadow-sm h-100">
|
||||
<div class="card-body py-3">
|
||||
<div class="fs-3 fw-bold text-success">@activeCount</div>
|
||||
<div class="small text-muted">Active</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-3">
|
||||
<div class="card text-center shadow-sm h-100">
|
||||
<div class="card-body py-3">
|
||||
<div class="fs-3 fw-bold text-secondary">@(totalCount - activeCount)</div>
|
||||
<div class="small text-muted">Inactive</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filters -->
|
||||
<form method="get" class="card shadow-sm mb-3">
|
||||
<div class="card-body py-2">
|
||||
<div class="row g-2 align-items-end">
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="search" value="@search" class="form-control"
|
||||
placeholder="Search tip text..." />
|
||||
</div>
|
||||
<div class="col-md-3 d-flex align-items-center gap-2">
|
||||
<div class="form-check mb-0">
|
||||
<input class="form-check-input" type="checkbox" name="activeOnly" value="true"
|
||||
id="activeOnly" @(activeOnly ? "checked" : "") onchange="this.form.submit()" />
|
||||
<label class="form-check-label" for="activeOnly">Active only</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 d-flex gap-2">
|
||||
<button type="submit" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-search me-1"></i>Search
|
||||
</button>
|
||||
@if (!string.IsNullOrEmpty(search) || activeOnly)
|
||||
{
|
||||
<a asp-action="Index" class="btn btn-outline-danger btn-sm">
|
||||
<i class="bi bi-x-lg me-1"></i>Clear
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header d-flex justify-content-between align-items-center py-2">
|
||||
<span class="fw-semibold">
|
||||
@total tip@(total == 1 ? "" : "s") found
|
||||
@if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
<span class="text-muted fw-normal">for "@search"</span>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width:60px">#</th>
|
||||
<th>Tip Text</th>
|
||||
<th style="width:100px" class="text-center">Status</th>
|
||||
<th style="width:130px" class="text-muted small">Added</th>
|
||||
<th style="width:140px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (!Model.Any())
|
||||
{
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted py-4">
|
||||
<i class="bi bi-lightbulb fs-3 d-block mb-2 opacity-25"></i>
|
||||
No tips found.
|
||||
@if (string.IsNullOrEmpty(search) && !activeOnly)
|
||||
{
|
||||
<a asp-action="Create">Add the first one</a>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (var tip in Model)
|
||||
{
|
||||
<tr class="@(tip.IsActive ? "" : "table-secondary opacity-75")">
|
||||
<td class="text-muted small">@tip.Id</td>
|
||||
<td>
|
||||
<span class="@(tip.IsActive ? "" : "text-muted fst-italic")">
|
||||
@tip.TipText
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if (tip.IsActive)
|
||||
{
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">Inactive</span>
|
||||
}
|
||||
</td>
|
||||
<td class="text-muted small">@tip.CreatedAt.ToString("MMM d, yyyy")</td>
|
||||
<td class="text-end">
|
||||
<div class="d-flex gap-1 justify-content-end">
|
||||
<!-- Toggle Active -->
|
||||
<form method="post" asp-action="ToggleActive" asp-route-id="@tip.Id" class="d-inline">
|
||||
@Html.AntiForgeryToken()
|
||||
<button type="submit" class="btn btn-sm @(tip.IsActive ? "btn-outline-secondary" : "btn-outline-success")"
|
||||
title="@(tip.IsActive ? "Deactivate" : "Activate")">
|
||||
<i class="bi @(tip.IsActive ? "bi-toggle-on" : "bi-toggle-off")"></i>
|
||||
</button>
|
||||
</form>
|
||||
<a asp-action="Edit" asp-route-id="@tip.Id" class="btn btn-sm btn-outline-primary" title="Edit">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger" title="Delete"
|
||||
onclick="confirmDelete(@tip.Id, this)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- Mobile card view — shown on screens < 992px -->
|
||||
<div class="mobile-card-view">
|
||||
<div class="mobile-card-list">
|
||||
@if (!Model.Any())
|
||||
{
|
||||
<p class="text-center text-muted py-4">
|
||||
No tips found.
|
||||
@if (string.IsNullOrEmpty(search) && !activeOnly)
|
||||
{
|
||||
<a asp-action="Create">Add the first one</a>
|
||||
}
|
||||
</p>
|
||||
}
|
||||
@foreach (var tip in Model)
|
||||
{
|
||||
var tipPreview = tip.TipText.Length > 60 ? tip.TipText.Substring(0, 60) + "…" : tip.TipText;
|
||||
<div class="mobile-data-card">
|
||||
<div class="mobile-card-header">
|
||||
<div class="mobile-card-icon bg-warning"><i class="bi bi-lightbulb"></i></div>
|
||||
<div class="mobile-card-title">
|
||||
<h6>@tipPreview</h6>
|
||||
<small>Added @tip.CreatedAt.ToString("MMM d, yyyy")</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mobile-card-body">
|
||||
<div class="mobile-card-row">
|
||||
<span class="mobile-card-label">Status</span>
|
||||
<span class="mobile-card-value">
|
||||
@if (tip.IsActive)
|
||||
{
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle">Active</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-secondary-subtle text-secondary border border-secondary-subtle">Inactive</span>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mobile-card-row">
|
||||
<span class="mobile-card-label">ID</span>
|
||||
<span class="mobile-card-value text-muted">#@tip.Id</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mobile-card-footer">
|
||||
<a asp-action="Edit" asp-route-id="@tip.Id" class="btn btn-sm btn-outline-primary">Edit →</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger ms-1"
|
||||
onclick="confirmDelete(@tip.Id, this)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (totalPages > 1)
|
||||
{
|
||||
<div class="card-footer d-flex justify-content-between align-items-center py-2">
|
||||
<span class="small text-muted">
|
||||
Page @(page) of @(totalPages)
|
||||
</span>
|
||||
<div class="d-flex gap-1">
|
||||
@if (page > 1)
|
||||
{
|
||||
<a asp-action="Index" asp-route-page="@(page - 1)" asp-route-search="@search"
|
||||
asp-route-activeOnly="@activeOnly" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-chevron-left"></i>
|
||||
</a>
|
||||
}
|
||||
@if (page < totalPages)
|
||||
{
|
||||
<a asp-action="Index" asp-route-page="@(page + 1)" asp-route-search="@search"
|
||||
asp-route-activeOnly="@activeOnly" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden delete form -->
|
||||
<form id="deleteForm" method="post" style="display:none">
|
||||
@Html.AntiForgeryToken()
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function confirmDelete(id, btn) {
|
||||
if (!confirm('Delete this tip? This cannot be undone.')) return;
|
||||
var form = document.getElementById('deleteForm');
|
||||
form.action = '/DashboardTips/Delete/' + id;
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
}
|
||||
Reference in New Issue
Block a user