Skip to content

Commit

Permalink
feat(view): 💄 add subtitle to subtotal results with project/client name
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNZL committed May 17, 2023
1 parent 8bd7bd9 commit be8b068
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/TogglTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,14 @@ internal async ValueTask<List<Result>> RequestViewReports(CancellationToken toke
}

var project = me.projects?.Find(project => project.id == selectedProjectGroup.id);
var client = me.clients?.Find(client => client.id == project?.client_id);

string clientName = (client is not null)
? $"{client.name}"
: string.Empty;
string projectName = (project is not null)
? $"{project.name}{clientName}"
: "No Project";

var subResults = selectedProjectGroup.sub_groups.ConvertAll(subGroup =>
{
Expand All @@ -1646,6 +1654,7 @@ internal async ValueTask<List<Result>> RequestViewReports(CancellationToken toke
? new ColourIcon(this._context, project.color, "view.png").GetColourIcon()
: "view.png",
AutoCompleteText = $"{query.ActionKeyword} {Settings.ViewCommand} {spanConfiguration.Argument} {groupingConfiguration.Argument} {((string.IsNullOrEmpty(subGroup.title)) ? "(no description)" : subGroup.title)}",
// TODO: + x so this takes priroity if only 1 result
Score = (int)elapsed.TotalSeconds,
Action = c =>
{
Expand All @@ -1660,6 +1669,7 @@ internal async ValueTask<List<Result>> RequestViewReports(CancellationToken toke
subResults.Add(new Result
{
Title = $"{subTotal.Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Hour)} tracked {spanConfiguration.Interpolation} ({(int)subTotal.TotalHours}:{subTotal.ToString(@"mm\:ss")})",
SubTitle = projectName,
IcoPath = "view.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} ",
Score = (int)subTotal.TotalSeconds,
Expand Down Expand Up @@ -1808,6 +1818,7 @@ internal async ValueTask<List<Result>> RequestViewReports(CancellationToken toke
subResults.Add(new Result
{
Title = $"{subTotal.Humanize(maxUnit: Humanizer.Localisation.TimeUnit.Hour)} tracked {spanConfiguration.Interpolation} ({(int)subTotal.TotalHours}:{subTotal.ToString(@"mm\:ss")})",
SubTitle = client?.name ?? "No Client",
IcoPath = "view.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} ",
Score = (int)subTotal.TotalSeconds,
Expand Down

0 comments on commit be8b068

Please sign in to comment.