From 2f85c49386a81070aceb3818f959b34262d6930d Mon Sep 17 00:00:00 2001 From: Alaric Snell-Pym Date: Tue, 23 Sep 2025 09:50:42 +0100 Subject: [PATCH 01/11] Initial implementation of format picking in the UI. Still to do: - Skip the format selection step if it's not needed - Improve text on the format selection step - Use guessed types to preselect formats if we can --- lib/importer/govuk-prototype-kit.config.json | 5 ++ .../nunjucks/importer/macros/field_mapper.njk | 3 +- .../importer/macros/format_picker.njk | 87 +++++++++++++++++++ lib/importer/src/dudk/backend.js | 38 ++++++-- lib/importer/src/dudk/sheets.js | 16 ++-- .../src/dudk/types/attribute-types.js | 10 +-- lib/importer/src/functions.js | 43 ++++++++- lib/importer/src/index.js | 70 +++++++++------ lib/importer/src/session.js | 8 ++ lib/importer/templates/mapping.html | 2 +- prototypes/basic/app/config.json | 2 +- prototypes/basic/app/views/mapping.html | 2 +- 12 files changed, 232 insertions(+), 54 deletions(-) create mode 100644 lib/importer/nunjucks/importer/macros/format_picker.njk diff --git a/lib/importer/govuk-prototype-kit.config.json b/lib/importer/govuk-prototype-kit.config.json index 2e85f535..616a929d 100644 --- a/lib/importer/govuk-prototype-kit.config.json +++ b/lib/importer/govuk-prototype-kit.config.json @@ -30,6 +30,11 @@ "path": "/templates/mapping.html", "type": "nunjucks" }, + { + "name": "Choose field formats", + "path": "/templates/format.html", + "type": "nunjucks" + }, { "name": "Review your data", "path": "/templates/review.html", diff --git a/lib/importer/nunjucks/importer/macros/field_mapper.njk b/lib/importer/nunjucks/importer/macros/field_mapper.njk index c6737e10..86824c19 100644 --- a/lib/importer/nunjucks/importer/macros/field_mapper.njk +++ b/lib/importer/nunjucks/importer/macros/field_mapper.njk @@ -46,6 +46,7 @@ {% endif %} + {% if params.caption %} @@ -67,7 +68,7 @@ {% set mappingsLen = mapping | length %} + {% set possibleFormatsByColumn = importerPossibleColumnFormats(params.data) %} {% for h in headings.data %} {% set hIndex = loop.index0 %} {% set currentValue = importerErrorMappingData(error, hIndex) %} - {% set possibleFormats = importerPossibleColumnFormats(params.data, hIndex) %} + {% set possibleFormats = possibleFormatsByColumn[hIndex] %} @@ -70,10 +71,14 @@
{{params.caption}}
{{ h.name }} {{ h.examples }} - {% for field in fields %}
{{ h.name }} {% if possibleFormats %} diff --git a/lib/importer/nunjucks/views/error-handling/server-error.njk b/lib/importer/nunjucks/views/error-handling/server-error.njk index f3b424d4..9726d16e 100644 --- a/lib/importer/nunjucks/views/error-handling/server-error.njk +++ b/lib/importer/nunjucks/views/error-handling/server-error.njk @@ -45,11 +45,6 @@ {% endblock %} -{% block footer %} - {{ govukFooter({}) }} -{% endblock %} - - {% block pageScripts %}