Skip to content

Commit

Permalink
Quotes dedicated views
Browse files Browse the repository at this point in the history
  • Loading branch information
spech66 committed Jul 24, 2024
1 parent 554162b commit ff2d217
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 69 deletions.
31 changes: 31 additions & 0 deletions LifelogBb/Controllers/QuotesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,37 @@ public async Task<IActionResult> Index(string sortOrder, string currentFilter, s
return View(await PaginatedList<Quote>.CreateAsync(quotes.AsNoTracking(), pageNumber ?? 1, pageSize));
}

// GET: Quotes/Table/
public async Task<IActionResult> Table(string sortOrder, string currentFilter, string searchString, int? pageNumber)
{
ViewData["CurrentSort"] = sortOrder;

if (searchString != null)
{
pageNumber = 1;
}
else
{
searchString = currentFilter;
}

ViewData["CurrentFilter"] = searchString;

var quotes = from s in _context.Quotes select s;
quotes = quotes.SortByName(sortOrder, $"{nameof(Quote.CreatedAt)}_desc");

int pageSize = 20;
return View(await PaginatedList<Quote>.CreateAsync(quotes.AsNoTracking(), pageNumber ?? 1, pageSize));
}

// GET: Quotes/Random/
public async Task<IActionResult> Random()
{
var quotes = from s in _context.Quotes select s;
var randomQuote = await quotes.OrderBy(r => EF.Functions.Random()).Take(1).FirstOrDefaultAsync();
return View(randomQuote);
}

// GET: Quotes/Details/5
public async Task<IActionResult> Details(long? id)
{
Expand Down
2 changes: 1 addition & 1 deletion LifelogBb/Views/BucketLists/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "CreatedAt")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "CreatedAt")" style="display: inline">Date</a>,
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Title")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Title")" style="display: inline">Title</a>,
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Status")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Status")" style="display: inline">Status</a>,
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Category")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Category")" style="display: inline">Category</a> .
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Category")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Category")" style="display: inline">Category</a>.
</div>
</div>
</div>
Expand Down
97 changes: 40 additions & 57 deletions LifelogBb/Views/Quotes/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,48 @@
}

<div class="container-xl">
<div class="row row-cards">
<div class="col-12">
<div class="row row-cards mb-3">
<div class="col">
<div class="card">
<div class="table-responsive">
<table class="table card-table table-vcenter text-nowrap datatable">
<thead>
<tr>
<th class="w-1">
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "CreatedAt")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "CreatedAt")">Date</a>
</th>
<th>
Text
</th>
<th>
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Author")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Author")">Author</a>
</th>
<th>
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Category")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Category")">Category</a>
</th>
<th>
Tags
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<th scope="row">
<a asp-action="Details" asp-route-id="@item.Id">@Html.DisplayFor(modelItem => item.CreatedAt)</a>
</th>
<td>
@Html.DisplayFor(modelItem => item.Text)
</td>
<td>
@Html.DisplayFor(modelItem => item.Author)
</td>
<td>
@Html.DisplayFor(modelItem => item.Category, "Category")
</td>
<td>
@Html.DisplayFor(modelItem => item.Tags, "Tags")
</td>
<td class="text-end">
<div class="dropdown">
<button class="btn dropdown-toggle align-text-top" data-bs-boundary="viewport" data-bs-toggle="dropdown">Actions</button>
<div class="dropdown-menu dropdown-menu-end">
<a class="dropdown-item" asp-action="Edit" asp-route-id="@item.Id">Edit</a>
<a class="dropdown-item text-danger" asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</div>
</div>
</td>
</tr>
}
</tbody>
</table>
<div class="card-body">
Sort by
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "CreatedAt")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "CreatedAt")" style="display: inline">Date</a>,
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Text")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Text")" style="display: inline">Text</a>,
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Author")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Author")" style="display: inline">Author</a>,
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Status")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Status")" style="display: inline">Status</a>,
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Category")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Category")" style="display: inline">Category</a>.
</div>
<div class="card-footer d-flex align-items-center">
</div>
</div>
</div>
<div class="row row-cards">
@foreach (var item in Model)
{
<div class="col-sm-6 col-lg-4">
<div class="card card-sm h-100">
<div class="card-body">
<div>
<blockquote class="blockquote">
<p>@item.Text</p>
<footer class="blockquote-footer"><cite>@item.Author</cite></footer>
</blockquote>
</div>
<div class="ms-auto">
@Html.DisplayFor(modelItem => item.Category, "Category")
@Html.DisplayFor(modelItem => item.Tags, "Tags")
</div>
</div>
<div class="card-footer">
<a asp-action="Details" asp-route-id="@item.Id">Details</a>
</div>
</div>
</div>
}
</div>
<div class="row row-cards mt-3">
<div class="col">
<div class="card">
<div class="card-body d-flex align-items-center">
@await Component.InvokeAsync("Pagination", Model)
</div>
</div>
Expand Down
31 changes: 31 additions & 0 deletions LifelogBb/Views/Quotes/Random.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@using LifelogBb.Utilities;
@model LifelogBb.Models.Entities.Quote

@{
ViewData["Title"] = "Random Quote";
ViewData["PrimaryAction"] = "create";
}

<div class="container-xl">
<div class="row row-cards">
<div class="col-12">
<div class="card">
<div class="card-body">
<div>
<blockquote class="blockquote">
<p>@Model.Text</p>
<footer class="blockquote-footer"><cite>@Model.Author</cite></footer>
</blockquote>
</div>
<div class="ms-auto">
@Html.DisplayFor(modelItem => Model.Category, "Category")
@Html.DisplayFor(modelItem => Model.Tags, "Tags")
</div>
</div>
<div class="card-footer">
<a asp-action="Details" asp-route-id="@Model.Id">Details</a>
</div>
</div>
</div>
</div>
</div>
74 changes: 74 additions & 0 deletions LifelogBb/Views/Quotes/Table.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@using LifelogBb.Utilities;
@model PaginatedList<LifelogBb.Models.Entities.Quote>

@{
ViewData["Title"] = "Quotes";
ViewData["PrimaryAction"] = "create";
}

<div class="container-xl">
<div class="row row-cards">
<div class="col-12">
<div class="card">
<div class="table-responsive">
<table class="table card-table table-vcenter text-nowrap datatable">
<thead>
<tr>
<th class="w-1">
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "CreatedAt")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "CreatedAt")">Date</a>
</th>
<th>
Text
</th>
<th>
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Author")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Author")">Author</a>
</th>
<th>
<a asp-action="Index" asp-route-sortOrder="@RazorPageExtensions.GetSortRoute(ViewData, "Category")" asp-route-currentFilter="@ViewData["CurrentFilter"]" class="table-sort @RazorPageExtensions.GetSortOrder(ViewData, "Category")">Category</a>
</th>
<th>
Tags
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<th scope="row">
<a asp-action="Details" asp-route-id="@item.Id">@Html.DisplayFor(modelItem => item.CreatedAt)</a>
</th>
<td>
@Html.DisplayFor(modelItem => item.Text)
</td>
<td>
@Html.DisplayFor(modelItem => item.Author)
</td>
<td>
@Html.DisplayFor(modelItem => item.Category, "Category")
</td>
<td>
@Html.DisplayFor(modelItem => item.Tags, "Tags")
</td>
<td class="text-end">
<div class="dropdown">
<button class="btn dropdown-toggle align-text-top" data-bs-boundary="viewport" data-bs-toggle="dropdown">Actions</button>
<div class="dropdown-menu dropdown-menu-end">
<a class="dropdown-item" asp-action="Edit" asp-route-id="@item.Id">Edit</a>
<a class="dropdown-item text-danger" asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</div>
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="card-footer d-flex align-items-center">
@await Component.InvokeAsync("Pagination", Model)
</div>
</div>
</div>
</div>
</div>
2 changes: 2 additions & 0 deletions LifelogBb/Views/Shared/Components/Navigation/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public async Task<IViewComponentResult> InvokeAsync()
new NavItem("Quotes", "fas fa-quote-right", new List<NavItem>
{
new NavItem("Quotes", "Index", "Quotes", "fas fa-quote-right"),
new NavItem("Quotes", "Random", "Random", "fas fa-shuffle"),
new NavItem("Quotes", "Table", "Table", "fas fa-table"),
}),
};

Expand Down
23 changes: 12 additions & 11 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ ToDos and Features for LifelogBB.

### In Progress :construction:

- [ ] Dedicated views and filters (as primary view, keep table as overview for everything)
- [Tasks/Todos](https://tabler.io/preview) List: Progress
- [Todos/Tasks](https://preview.tabler.io/tasks.html#) Kanban: Upcoming today, next 7 days, ...
- Habits: Timeline
- [Journal date grid](https://github.com/usememos/memos)
- Weights
- Goals
- Bucket list
- Strength training
- Endurance workout
- Quotes
Dedicated views and filters (as primary view, keep table as overview for everything)

- [ ] [Tasks/Todos](https://tabler.io/preview) List: Progress
- [ ] [Todos/Tasks](https://preview.tabler.io/tasks.html#) Kanban: Upcoming today, next 7 days, ...
- [ ] Habits: Timeline
- [ ] [Journal date grid](https://github.com/usememos/memos)
- [ ] Weights
- [ ] Goals
- [ ] Bucket list
- [ ] Strength training
- [ ] Endurance workout
- [x] Quotes

### Done :heavy_check_mark:

Expand Down

0 comments on commit ff2d217

Please sign in to comment.