1+ {# app/views/_includes/event-active-tabs.njk #}
2+
3+ {# Tracking of status #}
4+ {% set identityStageCompleted = true if data .event .workflowStatus [' identity' ] == ' completed' else false %}
5+ {% set medicalInformationStageCompleted = true if data .event .workflowStatus [' record-medical-information' ] == ' completed' else false %}
6+ {% set awaitingImagesStageCompleted = true if data .event .workflowStatus [' awaiting-images' ] == ' completed' else false %}
7+ {% set imagesStageCompleted = true if data .event .workflowStatus [' images' ] == ' completed' else false %}
8+
9+ {# Build secondary nav #}
10+ {% set secondaryNavItems = [] %}
11+
12+ {# { id: 'appointment', label: 'Appointment' }, #}
13+
14+ {% for item in [
15+ { id : ' identity' , label : ' Participant' },
16+
17+ { id : ' record-medical-information' , label : ' Medical information' },
18+ { id : ' images' , label : ' Images' },
19+ { id : ' review' , label : ' Review' }
20+ ] %}
21+ {% set href -%}
22+ /clinics/{{ clinicId }} /events/{{ event .id }}{{ (" /" + item .id ) if item .id != = ' all' }}
23+ {% endset %}
24+
25+ {# { id: 'eligibility', label: 'Eligibility' }, #}
26+
27+ {# SVG copied from https://service-manual.nhs.uk/design-system/components/do-and-dont-lists #}
28+ {% set tickSvg %}
29+ <svg class =" app-icon app-icon--tick" xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 24 24" aria-hidden =" true" >
30+ <path stroke-linecap =" round" d =" M18.4 7.8l-8.5 8.4L5.6 12" ></path >
31+ </svg >
32+ {% endset %}
33+
34+ {% set isCompleted = data .event .workflowStatus [item .id ] == ' completed' %}
35+
36+
37+
38+ {% set isDisabled = false %}
39+ {# Todo: refactor this be easier to check status #}
40+
41+ {% if item .id == ' record-medical-information' %}
42+ {% set isDisabled = true %}
43+ {% if identityStageCompleted %}
44+ {% set isDisabled = false %}
45+ {% endif %}
46+ {% endif %}
47+
48+ {# Disable images tab until other stages are completed #}
49+ {% if item .id == ' images' %}
50+ {% set isDisabled = true %}
51+ {% if identityStageCompleted and medicalInformationStageCompleted %}
52+ {% set isDisabled = false %}
53+ {% endif %}
54+ {% endif %}
55+
56+ {% if item .id == ' review' %}
57+ {% set isDisabled = true %}
58+ {% if identityStageCompleted and medicalInformationStageCompleted and awaitingImagesStageCompleted and imagesStageCompleted %}
59+ {% set isDisabled = false %}
60+ {% endif %}
61+ {% endif %}
62+
63+ {% set linkHtml %}
64+ {% if isDisabled %}
65+ <span class =" app-secondary-navigation__link app-secondary-navigation__link--disabled" >
66+ {{ item .label | safe }}
67+ </span >
68+ {% else %}
69+ {{ (tickSvg | safe ) if isCompleted }}
70+ <a class =" app-secondary-navigation__link" href =" {{ href }}" {{ " aria-current=page" if item.id == activeTab }} >
71+ {{ item .label | safe }}
72+ </a >
73+ {% endif %}
74+ {% endset %}
75+
76+ {% set secondaryNavItems = secondaryNavItems | push ({
77+ html : linkHtml ,
78+ current : true if item .id == activeTab
79+ }) %}
80+
81+ {# text: (tickSvg if isCompleted) + item.label,
82+ href: href | trim,
83+ current: true if item.id == activeTab,
84+ disabled: isDisabled #}
85+
86+ {% endfor %}
87+
88+ {{ appSecondaryNavigation ({
89+ visuallyHiddenTitle : " Secondary menu" ,
90+ items : secondaryNavItems
91+ }) }}
0 commit comments