Skip to content

Commit 0195851

Browse files
committedFeb 23, 2025
Ensure that previous exercises show failed/split weights
1 parent b565aa2 commit 0195851

12 files changed

+53
-68
lines changed
 

‎LiftLog.Ui/Pages/Feed/FeedUserPlanPage.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="flex flex-col gap-4">
1515
<CardList Items="plan">
1616
<SessionSummaryTitle Session="context.GetEmptySession()" IsFilled="false"/>
17-
<SessionSummary Session="context.GetEmptySession()" ShowSets="true" ShowWeight="false"/>
17+
<SessionSummary Session="context.GetEmptySession()" IsFilled="false" />
1818
</CardList>
1919
<div>
2020
<AppButton OnClick="() => importPlanDialog?.Open()" Icon="assignment">@UiStrings.ImportTheirPlan</AppButton>

‎LiftLog.Ui/Pages/History/HistoryPage.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ else
3838
<SessionSummaryTitle IsFilled="true" Session="context" ></SessionSummaryTitle>
3939
</TitleContent>
4040
<MainContent>
41-
<SessionSummary Session="context" ShowSets="true"></SessionSummary>
41+
<SessionSummary Session="context" ></SessionSummary>
4242
</MainContent>
4343

4444
</SplitCardControl>

‎LiftLog.Ui/Pages/Index.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ else
5050
<SessionSummaryTitle IsFilled="context.Item.IsStarted" Session="context.Item" />
5151
</TitleContent>
5252
<MainContent>
53-
<SessionSummary ShowSets=true Session="context.Item" IsFilled="false"></SessionSummary>
53+
<SessionSummary Session="context.Item" IsFilled="false"></SessionSummary>
5454
</MainContent>
5555
</SplitCardControl>
5656
</CardList>

‎LiftLog.Ui/Shared/Presentation/ExerciseSummary.razor

+15-50
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,37 @@
1-
@{
2-
var splitWeights = (Exercise.PerSetWeight
3-
&& Exercise.PotentialSets.DistinctBy(x=>x.Set?.RepsCompleted).Count() != 1);
4-
var numCompletedSets = Exercise.PotentialSets.Count(x => x.Set != null);
5-
var maxNumReps = Exercise.PotentialSets.Max(x => x.Set?.RepsCompleted ?? 0);
61

7-
var (numSets, numReps) = IsFilled switch
8-
{
9-
true => (numCompletedSets, maxNumReps),
10-
false => (Exercise.Blueprint.Sets, Exercise.Blueprint.RepsPerSet)
11-
};
12-
}
13-
<span class="flex items-center">
2+
<span class="flex items-center gap-2">
143
@if(ShowName)
154
{
165
<span>@Exercise.Blueprint.Name</span>
176
}
18-
@if(ShowSets || ShowWeight)
19-
{
20-
@if(!splitWeights)
7+
<span class="flex ml-auto overflow-x-auto gap-1">
8+
@if(IsFilled)
219
{
22-
<span class="flex justify-around ml-auto items-center gap-0.5 bg-surface-container-highest text-on-surface-variant rounded-md py-1 px-2">
23-
24-
@if (ShowSets)
10+
@foreach(var chip in GetWeightAndRepsChips())
2511
{
26-
<span>@(numSets)x@(numReps)
12+
<span class="flex items-center gap-0.5 bg-surface-container-highest text-on-surface-variant rounded-md py-1 px-2">
13+
<span>@(chip.RepsCompleted?.ToString() ?? "-")</span><span class="text-2xs">@@</span>
14+
<WeightFormat Weight="@chip.Weight"/>
2715
</span>
28-
@if(ShowWeight)
29-
{
30-
<span class="text-2xs">@@</span>
31-
}
3216
}
17+
} else
18+
{
3319

34-
@if (ShowWeight)
20+
@foreach(var chip in GetPlannedChipData())
3521
{
36-
<WeightFormat Weight="@Exercise.MaxWeight"/>
22+
<span class="flex items-center gap-0.5 bg-surface-container-highest text-on-surface-variant rounded-md py-1 px-2">
23+
<span>@(chip.NumSets)x@(chip.RepTarget)</span><span class="text-2xs">@@</span>
24+
<WeightFormat Weight="@chip.Weight"/>
25+
</span>
3726
}
38-
</span>
3927
}
40-
41-
@if (ShowWeight && splitWeights)
42-
{
43-
<span class="flex ml-auto flex-wrap justify-end gap-1">
44-
@foreach(var set in Exercise.PotentialSets)
45-
{
46-
if(set.Set?.RepsCompleted == null)
47-
{
48-
continue;
49-
}
50-
<span class="flex items-center gap-0.5 bg-surface-container-highest text-on-surface-variant rounded-md py-1 px-2">
51-
@if (ShowSets){
52-
<span>@(set.Set?.RepsCompleted ?? Exercise.Blueprint.RepsPerSet)</span><span class="text-2xs">@@</span>
53-
}
54-
<WeightFormat Weight="@set.Weight"/>
55-
</span>
56-
}
57-
</span>
58-
}
59-
}
28+
</span>
6029
</span>
6130

6231
@code
6332
{
6433
[EditorRequired] [Parameter] public RecordedExercise Exercise { get; set; } = null!;
6534

66-
[Parameter] public bool ShowSets { get; set; }
67-
68-
[Parameter] public bool ShowWeight { get; set; }
69-
7035
[Parameter] public bool ShowName { get; set; }
7136

7237
[Parameter] public bool IsFilled { get; set; } = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace LiftLog.Ui.Shared.Presentation;
2+
3+
public record WeightAndRepsChipData(int? RepsCompleted, int RepTarget, decimal Weight);
4+
5+
public record PotentialSetChipData(int RepTarget, int NumSets, decimal Weight);
6+
7+
public partial class ExerciseSummary
8+
{
9+
private IEnumerable<WeightAndRepsChipData> GetWeightAndRepsChips()
10+
{
11+
var chips = Exercise.PotentialSets.Select(set => new WeightAndRepsChipData(
12+
set.Set?.RepsCompleted,
13+
Exercise.Blueprint.RepsPerSet,
14+
set.Weight
15+
));
16+
17+
return chips;
18+
}
19+
20+
private IEnumerable<PotentialSetChipData> GetPlannedChipData()
21+
{
22+
return Exercise
23+
.PotentialSets.GroupBy(x => x.Weight)
24+
.Select(x => new PotentialSetChipData(
25+
Exercise.Blueprint.RepsPerSet,
26+
x.Count(),
27+
x.First().Weight
28+
));
29+
}
30+
}

‎LiftLog.Ui/Shared/Presentation/FeedItemCardContent.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<SessionSummaryTitle IsFilled="true" Session="sessionFeedItem.Session" />
66
</TitleContent>
77
<MainContent>
8-
<SessionSummary ShowSets=true Session="sessionFeedItem.Session"></SessionSummary>
8+
<SessionSummary Session="sessionFeedItem.Session"></SessionSummary>
99
<span class="text-start mt-2"><LimitedHtml Value="@UiStrings.FeedUserCompletedAWorkout(User.DisplayName)" /></span>
1010
</MainContent>
1111
</SplitCardControl>

‎LiftLog.Ui/Shared/Presentation/ManageWorkoutCardContent.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</Menu>
1313
</Actions>
1414
<MainContent>
15-
<SessionSummary Session="SessionBlueprint.GetEmptySession()" ShowSets="true" ShowWeight="false"/>
15+
<SessionSummary Session="SessionBlueprint.GetEmptySession()" IsFilled="false"/>
1616
</MainContent>
1717
</SplitCardControl>
1818

‎LiftLog.Ui/Shared/Presentation/PreviousExerciseViewer.razor

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
<span>@exercise.DateTime.Date.ToShortDateString()</span>
66
<ExerciseSummary
77
Exercise=exercise.RecordedExercise
8-
ShowSets=true
9-
ShowWeight=true
108
ShowName=false />
119
</div>
1210
<md-divider class="last:hidden"></md-divider>

‎LiftLog.Ui/Shared/Presentation/SessionSummary.razor

-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
{
55
<ExerciseSummary
66
Exercise=exercise
7-
ShowSets=ShowSets
8-
ShowWeight=ShowWeight
97
IsFilled=IsFilled
108
ShowName=true />
119
<md-divider class="last:hidden"></md-divider>
@@ -16,9 +14,6 @@
1614
{
1715
[EditorRequired] [Parameter] public Session Session { get; set; } = null!;
1816

19-
[Parameter] public bool ShowSets { get; set; }
20-
21-
[Parameter] public bool ShowWeight { get; set; } = true;
2217

2318
[Parameter] public bool IsFilled { get; set; } = true;
2419
}

‎LiftLog.Ui/Shared/Smart/SharedProgramBlueprintComponent.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<SessionSummaryTitle Session="context.GetEmptySession()" />
1010
</TitleContent>
1111
<MainContent>
12-
<SessionSummary Session="context.GetEmptySession()" ShowSets="true" ShowWeight="false"/>
12+
<SessionSummary Session="context.GetEmptySession()" IsFilled="false"/>
1313
</MainContent>
1414
</SplitCardControl>
1515
</CardList>
-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.
3-
41
[assembly: System.Runtime.Versioning.SupportedOSPlatform("browser")]

‎LiftLog.Web/Properties/launchSettings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"LiftLog.Web": {
44
"commandName": "Project",
55
"launchBrowser": false,
6-
"launchUrl": "https://0.0.0.0:5001",
6+
"launchUrl": "https://0.0.0.0:5002",
77
"environmentVariables": {
88
"ASPNETCORE_ENVIRONMENT": "Development"
99
},
10-
"applicationUrl": "https://0.0.0.0:5001;http://0.0.0.0:5000",
10+
"applicationUrl": "https://0.0.0.0:5002;http://0.0.0.0:5001",
1111
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/debug?browser={browserInspectUri}"
1212
}
1313
}

0 commit comments

Comments
 (0)