Skip to content

Commit 2725a3c

Browse files
Change medication dose header to use asterisk
1 parent 576a1bb commit 2725a3c

File tree

2 files changed

+60
-68
lines changed

2 files changed

+60
-68
lines changed

JournalApp.Tests/DataPointViewTests.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@
462462

463463
// If we specify a dose in the point it should show up in the header where the category's would have been.
464464
point.MedicationDose = 20;
465-
DataPointView.GetHeaderText(point).Should().Be("Hi 20oz:");
465+
DataPointView.GetHeaderText(point).Should().Be("Hi 20oz*:");
466466
}
467467

468468
[Fact]

JournalApp/Components/DataPointView.razor

Lines changed: 59 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,94 +5,94 @@
55

66
@if (Point.Type == PointType.Mood)
77
{
8-
<MudMenu Dense>
9-
<ActivatorContent>
10-
<MudButton aria-label="Choose emoji for day's mood'">
11-
<Emoji>@(Point.Mood ?? "🤔")</Emoji>
12-
</MudButton>
13-
</ActivatorContent>
14-
15-
<ChildContent>
8+
<MudMenu Dense>
9+
<ActivatorContent>
10+
<MudButton aria-label="Choose emoji for day's mood'">
11+
<Emoji>@(Point.Mood ?? "🤔")</Emoji>
12+
</MudButton>
13+
</ActivatorContent>
14+
15+
<ChildContent>
1616
@foreach (var mood in DataPoint.Moods)
1717
{
18-
<MudMenuItem OnClick="@(() => Point.Mood = mood)">
19-
<Emoji>@mood</Emoji>
20-
</MudMenuItem>
18+
<MudMenuItem OnClick="@(() => Point.Mood = mood)">
19+
<Emoji>@mood</Emoji>
20+
</MudMenuItem>
2121
}
22-
</ChildContent>
23-
</MudMenu>
22+
</ChildContent>
23+
</MudMenu>
2424
}
2525
else if (Point.Type == PointType.Sleep)
2626
{
27-
<div class="d-flex align-center flex-grow-1" style="gap: 0.5em">
28-
<MudText Class="sleep-hours" Typo="Typo.caption">@((Point.SleepHours ?? 0).ToString("00.0"))</MudText>
29-
<MudIconButton Class="less-sleep" Icon="@Icons.Material.Rounded.Remove" aria-label="Less sleep" OnClick="DecrementSleep" Disabled="@(Point.SleepHours <= 0)" Size="Size.Small" />
30-
<MudSlider T="decimal" @bind-NullableValue="Point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" />
31-
<MudIconButton Class="more-sleep" Icon="@Icons.Material.Rounded.Add" aria-label="More sleep" OnClick="IncrementSleep" Disabled="@(Point.SleepHours >= 24)" Size="Size.Small" />
32-
</div>
27+
<div class="d-flex align-center flex-grow-1" style="gap: 0.5em">
28+
<MudText Class="sleep-hours" Typo="Typo.caption">@((Point.SleepHours ?? 0).ToString("00.0"))</MudText>
29+
<MudIconButton Class="less-sleep" Icon="@Icons.Material.Rounded.Remove" aria-label="Less sleep" OnClick="DecrementSleep" Disabled="@(Point.SleepHours <= 0)" Size="Size.Small" />
30+
<MudSlider T="decimal" @bind-NullableValue="Point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" />
31+
<MudIconButton Class="more-sleep" Icon="@Icons.Material.Rounded.Add" aria-label="More sleep" OnClick="IncrementSleep" Disabled="@(Point.SleepHours >= 24)" Size="Size.Small" />
32+
</div>
3333
}
3434
else if (Point.Type == PointType.Scale)
3535
{
36-
<MudRating @bind-SelectedValue="ScaleIndexForMudRating" FullIcon="@Icons.Material.Rounded.Circle" EmptyIcon="@Icons.Material.Rounded.Circle" Color="Color.Primary" />
36+
<MudRating @bind-SelectedValue="ScaleIndexForMudRating" FullIcon="@Icons.Material.Rounded.Circle" EmptyIcon="@Icons.Material.Rounded.Circle" Color="Color.Primary" />
3737
}
3838
else if (Point.Type == PointType.LowToHigh)
3939
{
40-
<MudToggleGroup T="int?" @bind-Value="Point.ScaleIndex" SelectionMode="SelectionMode.ToggleSelection">
41-
<MudToggleItem T="int?" Value="0">None</MudToggleItem>
42-
<MudToggleItem T="int?" Value="1">Low</MudToggleItem>
43-
<MudToggleItem T="int?" Value="3">Medium</MudToggleItem>
44-
<MudToggleItem T="int?" Value="5">High</MudToggleItem>
45-
</MudToggleGroup>
40+
<MudToggleGroup T="int?" @bind-Value="Point.ScaleIndex" SelectionMode="SelectionMode.ToggleSelection">
41+
<MudToggleItem T="int?" Value="0">None</MudToggleItem>
42+
<MudToggleItem T="int?" Value="1">Low</MudToggleItem>
43+
<MudToggleItem T="int?" Value="3">Medium</MudToggleItem>
44+
<MudToggleItem T="int?" Value="5">High</MudToggleItem>
45+
</MudToggleGroup>
4646
}
4747
else if (Point.Type == PointType.MildToSevere)
4848
{
49-
<MudToggleGroup T="int?" @bind-Value="Point.ScaleIndex" SelectionMode="SelectionMode.ToggleSelection">
50-
<MudToggleItem T="int?" Value="0">None</MudToggleItem>
51-
<MudToggleItem T="int?" Value="1">Mild</MudToggleItem>
52-
<MudToggleItem T="int?" Value="3">Moderate</MudToggleItem>
53-
<MudToggleItem T="int?" Value="5">Severe</MudToggleItem>
54-
</MudToggleGroup>
49+
<MudToggleGroup T="int?" @bind-Value="Point.ScaleIndex" SelectionMode="SelectionMode.ToggleSelection">
50+
<MudToggleItem T="int?" Value="0">None</MudToggleItem>
51+
<MudToggleItem T="int?" Value="1">Mild</MudToggleItem>
52+
<MudToggleItem T="int?" Value="3">Moderate</MudToggleItem>
53+
<MudToggleItem T="int?" Value="5">Severe</MudToggleItem>
54+
</MudToggleGroup>
5555
}
5656
else if (Point.Type == PointType.Bool)
5757
{
58-
<MudToggleGroup T="bool?" @bind-Value="Point.Bool" SelectionMode="SelectionMode.ToggleSelection">
59-
<MudToggleItem T="bool?" Value="false">No</MudToggleItem>
60-
<MudToggleItem T="bool?" Value="true">Yes</MudToggleItem>
61-
</MudToggleGroup>
58+
<MudToggleGroup T="bool?" @bind-Value="Point.Bool" SelectionMode="SelectionMode.ToggleSelection">
59+
<MudToggleItem T="bool?" Value="false">No</MudToggleItem>
60+
<MudToggleItem T="bool?" Value="true">Yes</MudToggleItem>
61+
</MudToggleGroup>
6262
}
6363
else if (Point.Type == PointType.Number)
6464
{
65-
<MudNumericField @bind-Value="Point.Number" Immediate MaxLength="9" />
65+
<MudNumericField @bind-Value="Point.Number" Immediate MaxLength="9" />
6666
}
6767
else if (Point.Type == PointType.Text)
6868
{
69-
<MudTextField @bind-Value="Point.Text" Immediate />
69+
<MudTextField @bind-Value="Point.Text" Immediate />
7070
}
7171
else if (Point.Type == PointType.Note)
7272
{
73-
<div class="d-flex flex-column flex-grow-1">
73+
<div class="d-flex flex-column flex-grow-1">
7474
@if (!string.IsNullOrWhiteSpace(Point.Text))
7575
{
76-
<MudTextField @bind-Value="Point.Text"
77-
Placeholder="@(Point.IsTimestampedNote ? "What's on your mind?" : null)"
78-
Label="@(NoteLabel)" Typo="Typo.body2"
79-
Immediate ReadOnly Underline="false"
80-
AutoGrow Lines="1" MaxLines="10" />
76+
<MudTextField @bind-Value="Point.Text"
77+
Placeholder="@(Point.IsTimestampedNote ? "What's on your mind?" : null)"
78+
Label="@(NoteLabel)" Typo="Typo.body2"
79+
Immediate ReadOnly Underline="false"
80+
AutoGrow Lines="1" MaxLines="10" />
8181
}
8282
83-
<MudLink OnClick="EditTextInDialog">Edit note</MudLink>
84-
</div>
83+
<MudLink OnClick="EditTextInDialog">Edit note</MudLink>
84+
</div>
8585
}
8686
else if (Point.Type == PointType.Medication)
8787
{
88-
<div class="d-flex flex-grow-1 justify-space-between align-center" style="gap: 0.5em">
89-
<MudToggleGroup T="bool?" @bind-Value="Point.Bool" @bind-Value:after="OnMedicationTakenChanged" SelectionMode="SelectionMode.ToggleSelection">
90-
<MudToggleItem T="bool?" Value="false">No</MudToggleItem>
91-
<MudToggleItem T="bool?" Value="true">Yes</MudToggleItem>
92-
</MudToggleGroup>
93-
94-
<MudLink OnClick="EditDose" Disabled="@(string.IsNullOrWhiteSpace(Point.Category.MedicationUnit))">Edit dose</MudLink>
95-
</div>
88+
<div class="d-flex flex-grow-1 justify-space-between align-center" style="gap: 0.5em">
89+
<MudToggleGroup T="bool?" @bind-Value="Point.Bool" @bind-Value:after="OnMedicationTakenChanged" SelectionMode="SelectionMode.ToggleSelection">
90+
<MudToggleItem T="bool?" Value="false">No</MudToggleItem>
91+
<MudToggleItem T="bool?" Value="true">Yes</MudToggleItem>
92+
</MudToggleGroup>
93+
94+
<MudLink OnClick="EditDose" Disabled="@(string.IsNullOrWhiteSpace(Point.Category.MedicationUnit))">Edit dose</MudLink>
95+
</div>
9696
}
9797
9898
@code {
@@ -176,23 +176,15 @@ else if (Point.Type == PointType.Medication)
176176

177177
if (point.Type == PointType.Medication && !string.IsNullOrWhiteSpace(category.MedicationUnit))
178178
{
179-
var parts = new List<string>();
180-
181-
// The default dose and unit.
182-
if (category.MedicationDose.HasValue)
183-
{
184-
parts.Add($"{category.MedicationDose:0.##}{category.MedicationUnit}");
185-
}
186-
187-
// Show the dose if it's different from the category default.
179+
// Different dose from the category default.
188180
if (point.MedicationDose.HasValue && point.MedicationDose != category.MedicationDose)
189181
{
190-
parts.Add($"{point.MedicationDose:0.##}{category.MedicationUnit}");
182+
sb.Append(' ').Append($"{point.MedicationDose:0.##}{category.MedicationUnit}*");
191183
}
192-
193-
if (parts.Count > 0)
184+
// The default dose and unit.
185+
else if (category.MedicationDose.HasValue)
194186
{
195-
sb.Append(' ').Append(string.Join(" - ", parts));
187+
sb.Append(' ').Append($"{category.MedicationDose:0.##}{category.MedicationUnit}");
196188
}
197189
}
198190

0 commit comments

Comments
 (0)