Skip to content

Commit

Permalink
Refactor selector to wrap with custom data
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Sep 10, 2024
1 parent 39f71ad commit 742fba4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/importer/govuk-prototype-kit.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
"macroName": "importerTableView",
"importFrom": "importer/macros/table_view.njk"
},
{
"macroName": "importerHeaderSelector",
"importFrom": "importer/macros/header_selector.njk"
},
{
"macroName": "importerRangeSelector",
"importFrom": "importer/macros/range_selector.njk"
Expand Down
8 changes: 8 additions & 0 deletions lib/importer/nunjucks/importer/macros/header_selector.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

{% from "importer/macros/range_selector.njk" import importerRangeSelector %}

{% macro importerHeaderSelector(data, start=0, end=10) %}
{% set rows = importerGetRows(data, start, end) %}

{{ importerRangeSelector(rows) }}
{% endmacro %}
3 changes: 1 addition & 2 deletions lib/importer/nunjucks/importer/macros/range_selector.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

{% macro importerRangeSelector(data, start=0, end=10) %}
{% set rows = importerGetRows(data, start, end) %}
{% macro importerRangeSelector(rows, start=0, end=10) %}

<div>
<input type="hidden" name="importer:selection:TLRow" id="importer:selection:TLRow"/>
Expand Down
4 changes: 2 additions & 2 deletions prototypes/basic/app/views/select_header_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ govukBackLink({ text: "Back", href: "javascript:window.history.back()" }) }}
{% endblock %}

{% from "importer/macros/range_selector.njk" import importerRangeSelector %}
{% from "importer/macros/header_selector.njk" import importerHeaderSelector %}

{% block content %}
<div class="govuk-grid-row">
Expand All @@ -23,7 +23,7 @@ <h1 class="govuk-fieldset__heading">

<form action="{{ importerSelectHeaderPath('/mapping') }}" method="post">
<div class="govuk-form-group">
{{ importerRangeSelector(data, 0, 10) }}
{{ importerHeaderSelector(data, 0, 10) }}
</div>

<div class="govuk-button-group">
Expand Down

0 comments on commit 742fba4

Please sign in to comment.