Skip to content

Commit

Permalink
Calendar styling, add todo and goals
Browse files Browse the repository at this point in the history
  • Loading branch information
spech66 committed Jul 25, 2024
1 parent d0f04b9 commit cd73be6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions LifelogBb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public async Task<IActionResult> Calendar(DateTime? date)
var habits = calculateHabits(allHabits, forDay, forDay.AddDays(1).Date.AddTicks(-1));
model.Events.AddRange(habits.ConvertAll(h => new CalendarViewModelEvent { Type = EntityType.Habit, Text = h.Name, StartDate = h.StartDate, EndDate = h.EndDate }).OrderBy(s => s.StartDate));

// Add Due date for todos on forDay (Set start date and end date to due date to show as block)
var todos = await _context.Todos.Where(t => !t.IsCompleted && t.DueDate != null && t.DueDate.Value.Date == forDay).ToListAsync();
model.Events.AddRange(todos.ConvertAll(t => new CalendarViewModelEvent { Type = EntityType.Todo, Text = t.Title, StartDate = t.DueDate.Value, EndDate = t.DueDate.Value }));

// Add End date for goals on forDay (Set start date to end date to show as block)
var goals = await _context.Goals.Where(t => !t.IsCompleted && t.EndDate != null && t.EndDate.Value.Date == forDay).ToListAsync();
model.Events.AddRange(goals.ConvertAll(g => new CalendarViewModelEvent { Type = EntityType.Goal, Text = g.Name, StartDate = g.EndDate.Value, EndDate = g.EndDate.Value }));

return View(model);
}

Expand Down
6 changes: 4 additions & 2 deletions LifelogBb/Views/Home/Calendar.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
{
return type switch
{
EntityType.Habit => "text-bg-danger",
EntityType.Habit => "text-bg-info",
EntityType.Todo => "text-bg-danger",
EntityType.Goal => "text-bg-warning",
_ => "text-bg-secondary"
};
}
Expand Down Expand Up @@ -41,7 +43,7 @@
<div class="col">
<div class="card">
<div class="card-body">
<table border="0" cellpadding="0" cellspacing="0">
<table class="table">
@for (var timeSegment = DateTime.Now.Date; timeSegment < DateTime.Now.AddDays(1).Date.AddTicks(-1); timeSegment = timeSegment.AddHours(1))
{
<tr>
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Dedicated views and filters (as primary view, keep table as overview for everyth
### Done :heavy_check_mark:

- [x] Dashboard
- [x] Calendar
- [x] [iCal](https://github.com/rianjs/ical.net) feed
- VTODO for Goals/Todos
- VEVENT for Habits (Time Boxing/Blocking)
Expand Down

0 comments on commit cd73be6

Please sign in to comment.