Anniversary categories (wedding, jubilee, own) and month grouping
- Birthday becomes "anniversary" with a category: birthday, wedding
anniversary (with Silver/Gold/... names), jubilee, memorial day
- Own categories: Settings > Categories (icon, color, text with {0}/{o})
- Sidebar "Categories" lists anniversaries across folders with counts
- Group by month (any view), groups fold with a click
- Folders named Hochzeit/Wedding migrate yearly tasks once
- Old files keep working (JSON "IsBirthday" maps to IsAnniversary)
- 74 tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
@@ -28,9 +28,23 @@ namespace ReminderOrganizer.Core
|
||||
};
|
||||
}
|
||||
|
||||
public static bool Matches(ReminderTask t, string? search, TaskFilterMode mode, bool hideDone, DateTime now)
|
||||
/// <summary>Category filter value for "appointments only" (everything that is not an anniversary).</summary>
|
||||
public const string AppointmentsFilter = "_appointments";
|
||||
|
||||
public static bool MatchesCategory(ReminderTask t, string? categoryFilter) => categoryFilter switch
|
||||
{
|
||||
null or "" => true,
|
||||
AppointmentsFilter => !t.IsAnniversary,
|
||||
_ => t.IsAnniversary && (t.CategoryId ?? Category.BirthdayId) == categoryFilter
|
||||
};
|
||||
|
||||
/// <summary>Group key for month grouping: first day of the month.</summary>
|
||||
public static DateTime MonthKey(ReminderTask t) => new(t.ReminderDate.Year, t.ReminderDate.Month, 1);
|
||||
|
||||
public static bool Matches(ReminderTask t, string? search, TaskFilterMode mode, bool hideDone, DateTime now, string? categoryFilter = null)
|
||||
{
|
||||
if (hideDone && t.IsNotified) return false;
|
||||
if (!MatchesCategory(t, categoryFilter)) return false;
|
||||
switch (mode)
|
||||
{
|
||||
case TaskFilterMode.Today when t.ReminderDate.Date != now.Date: return false;
|
||||
@@ -38,7 +52,7 @@ namespace ReminderOrganizer.Core
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(search)) return true;
|
||||
var s = search.Trim();
|
||||
return Contains(t.Name, s) || Contains(t.Description, s) || Contains(t.FolderName, s);
|
||||
return Contains(t.Name, s) || Contains(t.Description, s) || Contains(t.FolderName, s) || Contains(t.Category?.Name, s);
|
||||
}
|
||||
|
||||
private static bool Contains(string? text, string s) =>
|
||||
@@ -48,11 +62,22 @@ namespace ReminderOrganizer.Core
|
||||
public sealed class Comparer : IComparer
|
||||
{
|
||||
private readonly Func<DateTime> _now;
|
||||
public Comparer(Func<DateTime>? now = null) => _now = now ?? (() => DateTime.Now);
|
||||
private readonly bool _chronological;
|
||||
/// <param name="chronological">true = plain date order (month grouping), false = overdue/today/…/done.</param>
|
||||
public Comparer(Func<DateTime>? now = null, bool chronological = false)
|
||||
{
|
||||
_now = now ?? (() => DateTime.Now);
|
||||
_chronological = chronological;
|
||||
}
|
||||
|
||||
public int Compare(object? x, object? y)
|
||||
{
|
||||
if (x is not ReminderTask a || y is not ReminderTask b) return 0;
|
||||
if (_chronological)
|
||||
{
|
||||
int d = a.ReminderDate.CompareTo(b.ReminderDate);
|
||||
return d != 0 ? d : string.Compare(a.Name, b.Name, StringComparison.CurrentCultureIgnoreCase);
|
||||
}
|
||||
var now = _now();
|
||||
int c = Bucket(a, now).CompareTo(Bucket(b, now));
|
||||
if (c != 0) return c;
|
||||
|
||||
Reference in New Issue
Block a user