From 993b2f45030a2edf3a8be9e749e5e6610be06cf6 Mon Sep 17 00:00:00 2001 From: Dom Smith Date: Wed, 7 Aug 2019 16:55:31 +0100 Subject: [PATCH] Update organisation switcher link logic Only display the organisation switcher link if a link object is passed to the component. This prevents an empty link tag being output to the source if there is no link destination. This change still supports the fallback text as long as a link `href` is supplied. It also updates the example to show how the component will look without a change link and with the fallback link text. --- .../components/organisation-switcher/index.html | 12 +++++++++--- .../components/organisation-switcher/template.njk | 14 +++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/views/components/organisation-switcher/index.html b/app/views/components/organisation-switcher/index.html index 284dc4d50..2baf9511a 100644 --- a/app/views/components/organisation-switcher/index.html +++ b/app/views/components/organisation-switcher/index.html @@ -23,18 +23,24 @@

Example 1

href: '#' } }) }} - +
- +

Example 2

{{ mojOrganisationSwitcher({ text: 'HMP Brixton, HMP/YOI Feltham, HMP/YOI Isis, HMP Pentonville, HMP Thameside, HMP Wandsworth, HMP Wormwood Scrubs', link: { - text: "Change prisons", href: '#' } }) }} +
+ +

Example 3

+ {{ mojOrganisationSwitcher({ + text: 'HMP Brixton' + }) }} + diff --git a/src/moj/components/organisation-switcher/template.njk b/src/moj/components/organisation-switcher/template.njk index a8d531d42..3158c12a3 100644 --- a/src/moj/components/organisation-switcher/template.njk +++ b/src/moj/components/organisation-switcher/template.njk @@ -1,8 +1,12 @@ -
+ \ No newline at end of file + + {% if params.link %} + {%- set linkText = params.link.text | default('Change organisation') -%} + + {{- linkText -}} + + {% endif %} +