generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from ministryofjustice/719-tasklist
(719) Add basic task list
- Loading branch information
Showing
13 changed files
with
215 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.moj-task-list__items { | ||
padding-left: 0; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import ReferralUtils from './referralUtils' | ||
import { referralFactory } from '../testutils/factories' | ||
|
||
describe('ReferralUtils', () => { | ||
describe('taskListSections', () => { | ||
it('returns task list sections for a given referral', () => { | ||
const referral = referralFactory.build() | ||
|
||
expect(ReferralUtils.taskListSections(referral)).toEqual([ | ||
{ | ||
heading: 'Personal details', | ||
items: [ | ||
{ | ||
statusTag: { classes: 'govuk-tag moj-task-list__task-completed', text: 'completed' }, | ||
text: 'Confirm personal details', | ||
}, | ||
], | ||
}, | ||
{ | ||
heading: 'Referral information', | ||
items: [ | ||
{ | ||
statusTag: { classes: 'govuk-tag govuk-tag--grey moj-task-list__task-completed', text: 'not started' }, | ||
text: 'Add Accredited Programme history', | ||
url: '#', | ||
}, | ||
{ | ||
statusTag: { classes: 'govuk-tag govuk-tag--grey moj-task-list__task-completed', text: 'not started' }, | ||
text: 'Confirm the OASys information', | ||
url: '#', | ||
}, | ||
{ | ||
statusTag: { classes: 'govuk-tag govuk-tag--grey moj-task-list__task-completed', text: 'not started' }, | ||
text: 'Add reason for referral and any additional information', | ||
url: '#', | ||
}, | ||
], | ||
}, | ||
{ | ||
heading: 'Check answers and submit', | ||
items: [ | ||
{ | ||
statusTag: { | ||
classes: 'govuk-tag govuk-tag--grey moj-task-list__task-completed', | ||
text: 'cannot start yet', | ||
}, | ||
text: 'Check answers and submit', | ||
url: '#', | ||
}, | ||
], | ||
}, | ||
]) | ||
}) | ||
}) | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { Referral } from '@accredited-programmes/models' | ||
import type { | ||
ReferralTaskListSection, | ||
ReferralTaskListStatusTag, | ||
ReferralTaskListStatusText, | ||
} from '@accredited-programmes/ui' | ||
|
||
export default class ReferralUtils { | ||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars | ||
static taskListSections(referral: Referral): Array<ReferralTaskListSection> { | ||
return [ | ||
{ | ||
heading: 'Personal details', | ||
items: [{ statusTag: ReferralUtils.taskListStatus('completed'), text: 'Confirm personal details' }], | ||
}, | ||
{ | ||
heading: 'Referral information', | ||
items: [ | ||
{ | ||
statusTag: ReferralUtils.taskListStatus('not started'), | ||
text: 'Add Accredited Programme history', | ||
url: '#', | ||
}, | ||
{ statusTag: ReferralUtils.taskListStatus('not started'), text: 'Confirm the OASys information', url: '#' }, | ||
{ | ||
statusTag: ReferralUtils.taskListStatus('not started'), | ||
text: 'Add reason for referral and any additional information', | ||
url: '#', | ||
}, | ||
], | ||
}, | ||
{ | ||
heading: 'Check answers and submit', | ||
items: [ | ||
{ statusTag: ReferralUtils.taskListStatus('cannot start yet'), text: 'Check answers and submit', url: '#' }, | ||
], | ||
}, | ||
] | ||
} | ||
|
||
private static taskListStatus(text: ReferralTaskListStatusText): ReferralTaskListStatusTag { | ||
const classes = | ||
text === 'completed' | ||
? 'govuk-tag moj-task-list__task-completed' | ||
: 'govuk-tag govuk-tag--grey moj-task-list__task-completed' | ||
|
||
return { classes, text } as ReferralTaskListStatusTag | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% from "govuk/components/tag/macro.njk" import govukTag %} | ||
|
||
{% macro taskListSection(section) %} | ||
<li> | ||
<h2 class="moj-task-list__section">{{ section.heading }}</h2> | ||
<ul class="moj-task-list__items"> | ||
{% for item in section.items %} | ||
<li class="moj-task-list__item"> | ||
{% if item.url %} | ||
<a class="moj-task-list__task-name" href="{{ item.url }}">{{ item.text }}</a> | ||
{% else %} | ||
<span class="moj-task-list__task-name">{{ item.text }}</span> | ||
{% endif %} | ||
{{ govukTag(item.statusTag) }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
{% endmacro %} |
This file contains 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