This repository was archived by the owner on Sep 18, 2025. It is now read-only.
Create TaskList View, ViewComponent and Model#41
Merged
Conversation
996b3ba to
b2a1c14
Compare
kevwhitt-hee
suggested changes
Mar 13, 2025
kevwhitt-hee
left a comment
There was a problem hiding this comment.
See comments in code for suggestions and questions.
| { | ||
| COMPLETED, | ||
| INCOMPLETE, | ||
| UNSTARTED |
There was a problem hiding this comment.
I see in the Razor partial that this is covered by "UNSTARTED". It still might be worth checking with Allan that we don't need more flexibility in terms of the styling of tags inside the div.
| @@ -0,0 +1,63 @@ | |||
| @using DotnetViewComponents.ViewModels | |||
| @model TaskListViewModel | |||
|
|
|||
There was a problem hiding this comment.
I would suggest simplifying the Razor markup by setting up some variables:
var hasLink = task.StateStyle != TaskStateStyle.UNSTARTED;
var statusClass = task.StateStyle switch
{
TaskStateStyle.COMPLETED => "nhsuk-task-list__status nhsuk-task-list__status--completed",
TaskStateStyle.INCOMPLETE => "nhsuk-task-list__status",
TaskStateStyle.UNSTARTED => "nhsuk-task-list__status nhsuk-task-list__status--cannot-start-yet",
_ => "nhsuk-task-list__status"
};
| <div>@task.Name</div> | ||
| @if (!String.IsNullOrWhiteSpace(task.HintText)) | ||
| { | ||
| <div id="your-health-3-hint" class="nhsuk-task-list__hint">@task.HintText</div> |
There was a problem hiding this comment.
We should probably use a different id - and a variable to name it:
var statusId = task.StateStyle == TaskStateStyle.UNSTARTED
? $"task-list-{task.Id}-status"
: task.Id;
| @model TaskListViewModel | ||
|
|
||
| <ul class="nhsuk-task-list"> | ||
| @foreach (var task in Model.ListItems) |
There was a problem hiding this comment.
If we parameterise some of the properties we can simplify this (to avoid repetition) markup to something like:
@foreach (var task in Model.ListItems)
{
<li class="nhsuk-task-list__item @(hasLink ? "nhsuk-task-list__item--with-link" : "")">
<div class="nhsuk-task-list__name-and-hint">
@if (hasLink)
{
<a class="nhsuk-link nhsuk-task-list__link" href="@task.Url" aria-describedby="@statusId">
@task.Name
</a>
}
else
{
<div>@task.Name</div>
}
@if (!String.IsNullOrWhiteSpace(task.HintText))
{
<div id="your-health-3-hint" class="nhsuk-task-list__hint">@task.HintText</div>
}
</div>
<div class="@statusClass" id="@statusId">
@if (task.StateStyle == TaskStateStyle.INCOMPLETE)
{
<strong class="nhsuk-tag nhsuk-tag--blue">@task.State</strong>
}
else
{
@task.State
}
</div>
</li>
}
kevwhitt-hee
approved these changes
Apr 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Create TaskList View, ViewComponent and Model
Screenshots
Paste screenshots for all views created or changed: mobile, tablet and desktop, wave analyser showing no errors.

Developer checks
(Leave tasks unticked if they haven't been appropriate for your ticket.)
I have:
Either:
Or: