Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Create TaskList View, ViewComponent and Model#41

Merged
akdalin-hee merged 5 commits into
mainfrom
feature/TD-5215-Create-tasklist-view-component
May 1, 2025
Merged

Create TaskList View, ViewComponent and Model#41
akdalin-hee merged 5 commits into
mainfrom
feature/TD-5215-Create-tasklist-view-component

Conversation

@akdalin-hee
Copy link
Copy Markdown

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.
image


Developer checks

(Leave tasks unticked if they haven't been appropriate for your ticket.)

I have:

  • Run the IDE auto formatter on all files I’ve worked on and made sure there are no IDE errors relating to them
  • Written or updated tests for the changes and made sure all tests are passing
  • Manually tested my work with and without JavaScript (adding notes where functionality requires JavaScript)
  • Tested with Wave Chrome plugin. Addressed any valid accessibility issues and documented any invalid errors
  • Scanned over my pull request in GitHub and addressed any warnings from the GitHub Build and Test checks in the GitHub PR ‘Files Changed’ tab
    Either:
  • Documented my work in Confluence, updating any business rules applied or modified. Updated GitHub readme/documentation for the repository if appropriate. List of documentation links added/changed:
  • Confirmed that none of the work that I have undertaken requires any updates to documentation
  • CHANGELOG entry

@akdalin-hee akdalin-hee force-pushed the feature/TD-5215-Create-tasklist-view-component branch from 996b3ba to b2a1c14 Compare March 5, 2025 09:55
Copy link
Copy Markdown

@kevwhitt-hee kevwhitt-hee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments in code for suggestions and questions.

{
COMPLETED,
INCOMPLETE,
UNSTARTED
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a cannot start yet state too:
image
This is rendered in a div of class="nhsuk-task-list__status nhsuk-task-list__status--cannot-start-yet"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
}

@akdalin-hee akdalin-hee merged commit 981788c into main May 1, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants