Skip to content

Commit

Permalink
Fix summary values condition for jinja2 (#356)
Browse files Browse the repository at this point in the history
* Fix condition for jinja2

* Change summary values key to non reserved word for jinja2
  • Loading branch information
bameyrick authored May 9, 2019
1 parent 55b5299 commit 840db14
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 52 deletions.
12 changes: 6 additions & 6 deletions src/components/summary/_macro-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

## SummaryRowItem

| Name | Type | Required | Description |
| ------- | -------------------- | -------- | ---------------------------------------------------------------------- |
| icon | string | false | Name of the icon to be placed next to the title |
| title | string | false | Label for the row item |
| values | Array<SummaryValue> | false | The value(s) to the row item |
| actions | Array<SummaryAction> | false | Configurations for action links. If not specified no links will render |
| Name | Type | Required | Description |
| --------- | -------------------- | -------- | ---------------------------------------------------------------------- |
| icon | string | false | Name of the icon to be placed next to the title |
| title | string | false | Label for the row item |
| valueList | Array<SummaryValue> | false | The value(s) to the row item |
| actions | Array<SummaryAction> | false | Configurations for action links. If not specified no links will render |

## SummaryValue

Expand Down
18 changes: 9 additions & 9 deletions src/components/summary/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% endif %}

{% for rowItem in row.rowItems %}
<tr class="summary__row{{ " summary__row--has-values" if rowItem.values else "" }}">
<tr class="summary__row{{ " summary__row--has-values" if rowItem.valueList else "" }}">
<td
class="summary__item-title{{ " summary__item-title--has-icon" if rowItem.icon else "" }}"
{% if rowItem.titleAttributes %}{% for attribute, value in (rowItem.titleAttributes.items() if rowItem.titleAttributes is mapping and rowItem.titleAttributes.items else rowItem.titleAttributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
Expand All @@ -30,26 +30,26 @@
{{ rowItem.title | default(row.title) }} {{ hasIcons }}

{# Render section status for mobile if is hub #}
{% if params.hub and rowItem.values %}
<span class="u-d-no@s u-fs-r"> — {{ rowItem.values[0].text | safe }}</span>
{% if params.hub and rowItem.valueList %}
<span class="u-d-no@s u-fs-r"> — {{ rowItem.valueList[0].text | safe }}</span>
{% endif %}
</td>
{% if rowItem.values %}
{% if rowItem.valueList %}
<td
class="summary__values"
{% if rowItem.actions == null %} colspan="2"{% endif %}
{% if rowItem.attributes %}{% for attribute, value in (rowItem.attributes.items() if rowItem.attributes is mapping and rowItem.attributes.items else rowItem.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
>
{% if rowItem.values | length == 1 %}
{{ rowItem.values[0].text | safe }}
{% if rowItem.values[0].other %}
{% if rowItem.valueList | length == 1 %}
{{ rowItem.valueList[0].text | safe }}
{% if rowItem.valueList[0].other %}
<ul class="u-mb-no">
<li>{{ rowItem.values[0].other | safe }}</li>
<li>{{ rowItem.valueList[0].other | safe }}</li>
</ul>
{% endif %}
{% else %}
<ul class="u-mb-no">
{% for value in (rowItem.values if rowItem.values is iterable else rowItem.values.items()) %}
{% for value in (rowItem.valueList if rowItem.valueList is iterable else rowItem.valueList.items()) %}
<li>
{{ value.text | safe }}
{% if value.other %}
Expand Down
16 changes: 8 additions & 8 deletions src/components/summary/examples/hub/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"rowItems": [
{
"icon": "check-green",
"values": [
"valueList": [
{
"text": "Completed"
}
Expand All @@ -28,7 +28,7 @@
"rowItems": [
{
"icon": "check-green",
"values": [
"valueList": [
{
"text": "Completed"
}
Expand All @@ -48,7 +48,7 @@
"rowItems": [
{
"icon": "check-green",
"values": [
"valueList": [
{
"text": "Completed"
}
Expand All @@ -67,7 +67,7 @@
"title": "John Smith",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Partially completed"
}
Expand All @@ -86,7 +86,7 @@
"title": "Billy Smith",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand All @@ -105,7 +105,7 @@
"title": "Sally Smith",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand All @@ -124,7 +124,7 @@
"title": "Wilhelmina Susannah Clementine-Smith (Visitor)",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand All @@ -143,7 +143,7 @@
"title": "Vera Jones (Visitor)",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"title": "Total value of acquisitions for transport assets and equipment",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£9,000.00"
}
Expand All @@ -26,7 +26,7 @@
"title": "Total value of acquisitions for computers and peripheral devices (hardware)",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£225,000.00"
}
Expand All @@ -46,7 +46,7 @@
"total": true,
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£234,000.00"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"title": "For the period 1 May 2017 to 31 May 2017, what was the total turnover of Essential Enterprise Ltd.?",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£600.00"
}
Expand All @@ -28,7 +28,7 @@
"error": true,
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£123.00"
}
Expand All @@ -48,7 +48,7 @@
"error": true,
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£200.00"
}
Expand All @@ -68,7 +68,7 @@
"error": true,
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£50.00"
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/summary/examples/summary-grouped/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"title": "What are the dates of the sales period you are reporting for?",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "1 January 2015 to 2 February 2017"
}
Expand All @@ -27,7 +27,7 @@
"title": "For the period 1 January 2015 to 2 February 2017, what was the value of your total turnover, excluding VAT?",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£180,440"
}
Expand All @@ -46,7 +46,7 @@
"title": "Please indicate the reasons for any changes in the total turnover",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Change in level of business activity"
},
Expand All @@ -69,7 +69,7 @@
"title": "Please describe the changes in total turnover in more detail",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/summary/examples/summary-multiple/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"rowItems": [
{
"title": "Food",
"values": [
"valueList": [
{
"text": "£50.00"
}
Expand All @@ -23,7 +23,7 @@
},
{
"title": "Utilities",
"values": [
"valueList": [
{
"text": "£65.00"
}
Expand All @@ -38,7 +38,7 @@
},
{
"title": "Transport",
"values": [
"valueList": [
{
"text": "£70.00"
}
Expand All @@ -53,7 +53,7 @@
},
{
"title": "Other",
"values": [
"valueList": [
{
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"title": "Total turnover",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "£234,000.00"
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/summary/examples/summary/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"title": "What are the dates of the sales period you are reporting for?",
"rowItems": [
{
"values": [
"valueList": [
{
"value": "01 January 2015 to 02 February 2017"
}
Expand Down
16 changes: 8 additions & 8 deletions src/patterns/hub-and-spoke/examples/hub/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ layout: none
"rowItems": [
{
"icon": "check-green",
"values": [
"valueList": [
{
"text": "Completed"
}
Expand All @@ -50,7 +50,7 @@ layout: none
"rowItems": [
{
"icon": "check-green",
"values": [
"valueList": [
{
"text": "Completed"
}
Expand All @@ -70,7 +70,7 @@ layout: none
"rowItems": [
{
"icon": "check-green",
"values": [
"valueList": [
{
"text": "Completed"
}
Expand All @@ -89,7 +89,7 @@ layout: none
"title": "John Smith",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Partially completed"
}
Expand All @@ -108,7 +108,7 @@ layout: none
"title": "Billy Smith",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand All @@ -127,7 +127,7 @@ layout: none
"title": "Sally Smith",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand All @@ -146,7 +146,7 @@ layout: none
"title": "Wilhelmina Susannah Clementine-Smith (Visitor)",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand All @@ -165,7 +165,7 @@ layout: none
"title": "Vera Jones (Visitor)",
"rowItems": [
{
"values": [
"valueList": [
{
"text": "Not started"
}
Expand Down
8 changes: 4 additions & 4 deletions src/patterns/playback/examples/summary-multiple/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"rowItems": [
{
"title": "Food",
"values": [
"valueList": [
{
"text": "£50"
}
Expand All @@ -22,7 +22,7 @@
},
{
"title": "Utilities",
"values": [
"valueList": [
{
"text": "£65"
}
Expand All @@ -35,7 +35,7 @@
},
{
"title": "Transport",
"values": [
"valueList": [
{
"text": "£70"
}
Expand All @@ -48,7 +48,7 @@
},
{
"title": "Other",
"values": [
"valueList": [
{
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
}
Expand Down

0 comments on commit 840db14

Please sign in to comment.