Skip to content

Commit

Permalink
Add do nothing post endpoint for setting footer row
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Sep 10, 2024
1 parent 742fba4 commit 9e71493
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 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 @@ -64,6 +64,10 @@
"macroName": "importerHeaderSelector",
"importFrom": "importer/macros/header_selector.njk"
},
{
"macroName": "importerFooterSelector",
"importFrom": "importer/macros/footer_selector.njk"
},
{
"macroName": "importerRangeSelector",
"importFrom": "importer/macros/range_selector.njk"
Expand Down
22 changes: 21 additions & 1 deletion lib/importer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const IMPORTER_ROUTE_MAP = new Map([
["importerSelectSheetPath", "/importer/sheets"],
["importerMapDataPath", "/importer/mapping"],
["importerReviewDataPath","/importer/review"],
["importerSelectHeaderPath", "/importer/header_selection"]
["importerSelectHeaderPath", "/importer/header_selection"],
["importerSelectFooterPath", "/importer/footer_selection"]
]);

exports.Initialise = (config, router, prototypeKit) => {
Expand Down Expand Up @@ -261,6 +262,25 @@ exports.Initialise = (config, router, prototypeKit) => {
});


//--------------------------------------------------------------------
// Allows the user to optionally select a footer row should the data
// contain one
//--------------------------------------------------------------------
router.post(IMPORTER_ROUTE_MAP.get("importerSelectFooterPath"), (request, response) => {
let session = request.session.data[IMPORTER_SESSION_KEY];
if (!session) {
response.status(404);
return;
}

// WIP: Do nothing yet


// Ensure the session is persisted. Currently in session, eventually another way
request.session.data[IMPORTER_SESSION_KEY] = session;
redirectOnwards(request, response);
});

//--------------------------------------------------------------------
// Sets the mapping that the user has selected for this session. It
// is expected that the mapping will be an associative array (map/dict)
Expand Down
8 changes: 8 additions & 0 deletions lib/importer/nunjucks/importer/macros/footer_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 importerFooterSelector(data, start=0, end=10) %}
{% set rows = importerGetRows(data, start, end) %}

{{ importerRangeSelector(rows) }}
{% endmacro %}
18 changes: 14 additions & 4 deletions lib/importer/templates/select_footer_row.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{% extends "layouts/main.html" %}

{% block head %}
{{ super() }}
{% endblock %}

{% block pageTitle %} – {{ serviceName }} – GOV.UK Prototype Kit {% endblock %}

{% block beforeContent %}
{{ govukBackLink({ text: "Back", href: "javascript:window.history.back()" }) }}
{% endblock %}

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

{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<form action="{{ importerSelectSheetPath('/mapping') }}" method="post">
<div class="govuk-grid-column-three-quarters">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
<h1 class="govuk-fieldset__heading">
Select cells containing footer data
</h1>
</legend>

<form action="{{ importerSelectFooterPath('/mapping') }}" method="post">
<div class="govuk-form-group">
{{ importerRangeSelector(data) }}
{{ importerFooterSelector(data) }}
</div>

<div class="govuk-button-group">
Expand Down
18 changes: 14 additions & 4 deletions lib/importer/templates/select_header_row.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{% extends "layouts/main.html" %}

{% block head %}
{{ super() }}
{% endblock %}

{% block pageTitle %} – {{ serviceName }} – GOV.UK Prototype Kit {% endblock %}

{% block beforeContent %}
{{ 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">
<div class="govuk-grid-column-two-thirds">
<form action="{{ importerSelectSheetPath('/mapping') }}" method="post">
<div class="govuk-grid-column-three-quarters">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
<h1 class="govuk-fieldset__heading">
Select cells containing column headings
</h1>
</legend>

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

<div class="govuk-button-group">
Expand Down
2 changes: 1 addition & 1 deletion prototypes/basic/app/views/select_header_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1 class="govuk-fieldset__heading">
</h1>
</legend>

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

0 comments on commit 9e71493

Please sign in to comment.