Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes some minor issues with the lookup table journey #61

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/controllers/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const uploadFile = async (req: Request, res: Response, next: NextFunction
}
}

res.render('publish/upload', { revisit, errors });
res.render('publish/upload', { revisit, errors, uploadType: false });
};

export const factTablePreview = async (req: Request, res: Response, next: NextFunction) => {
Expand Down Expand Up @@ -314,7 +314,7 @@ export const uploadLookupTable = async (req: Request, res: Response, next: NextF
res.status(400);
logger.error('Lookup table did not match data in the fact table.', err);
const failurePreview = JSON.parse(error.body as string) as ViewErrDTO;
res.render('publish/period-match-failure', {
res.render('publish/dimension-match-failure', {
...failurePreview,
patchRequest: { dimension_type: DimensionType.LookupTable },
dimension
Expand All @@ -336,7 +336,7 @@ export const uploadLookupTable = async (req: Request, res: Response, next: NextF
}
}

res.render('publish/upload', { revisit, errors });
res.render('publish/upload', { revisit, errors, uploadType: 'lookup' });
};

export const lookupReview = async (req: Request, res: Response, next: NextFunction) => {
Expand Down
15 changes: 15 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@
"heading": "What format is used for months in the dimension?",
"example": "For example, {{example}}"
},
"dimension_match_failure": {
"lookup_heading": "Lookup table data cannot be matched to the data table",
"heading": "Reference data cannot be matched to the data table",
"information": "{{failureCount, number}} date codes in the dimension do not match the date formatting you have indicated. You should check:",
"formatting": "the reference codes used in the data table are correct",
"choices": "you selected the correct lookup table",
"subheading": "Reference codes that cannot be matched",
"actions": "Actions",
"upload_different_file": "Upload corrected or different data table",
"upload_different_file_warning": "(This will remove reference data from all dimensions)",
"try_different_format": "Select a different lookup table",
"no_matches": "None of the dates matched the format supplied"
},
"period_match_failure": {
"heading": "Date formatting cannot be matched to the dimension",
"information": "{{failureCount, number}} date codes in the dimension do not match the date formatting you have indicated. You should check:",
Expand Down Expand Up @@ -443,6 +456,8 @@
},
"upload": {
"title": "Upload the data table",
"lookup_heading": "Upload a lookup table",
"measure_heading": "Upload a measure table",
"note": "The file should be in a CSV format"
},
"preview": {
Expand Down
8 changes: 3 additions & 5 deletions src/views/publish/dimension-chooser.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

<h1 class="govuk-heading-xl"><%= t('publish.dimension_type_chooser.heading') %></h1>

<h2 class="govuk-heading"><%= t('publish.dimension_type_chooser.subheading') %></h2>

<% if (locals?.errors) { %>
<div class="govuk-error-summary" data-module="govuk-error-summary">
<div role="alert">
Expand Down Expand Up @@ -48,10 +46,10 @@
<tr class="govuk-table__row">
<% locals.headers.forEach(function(cell, idx) { %>
<th scope="col" class="govuk-table__header">
<% if (cell.name === dimension.joinColumn) { %>
<%= cell.name %>
<% } else { %>
<% if (i18n.exists(`publish.lookup_table_review.column_headers.${cell.name.toLowerCase()}`)) { %>
<%= t(`publish.lookup_table_review.column_headers.${cell.name.toLowerCase()}`) %>
<% } else { %>
<%= cell.name %>
<% } %>
</th>
<% }); %>
Expand Down
48 changes: 48 additions & 0 deletions src/views/publish/dimension-match-failure.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<%- include("../partials/header", t); %>

<div class="govuk-width-container app-width-container">
<main class="govuk-main-wrapper" id="main-content" role="main">
<div class="top-links">
<div class="govuk-width-container">
<a href="<%= locals.referrer %>" class="govuk-back-link"><%= t('buttons.back') %></a>
<a href="<%= buildUrl(`/publish/${locals.datasetId}/tasklist`, i18n.language) %>" class="govuk-link return-link"><%= t('publish.header.overview') %></a>
</div>
</div>

<% if (locals.patchRequest.dimension_type === 'lookup_table') { %>
<h1 class="govuk-heading-xl"><%= t('publish.dimension_match_failure.lookup_heading') %></h1>
<% } else { %>
<h1 class="govuk-heading-xl"><%= t('publish.dimension_match_failure.heading') %></h1>
<% } %>

<p class="govuk-body"><%= t('publish.dimension_match_failure.information', {failureCount: locals.extension.totalNonMatching}) %></p>
<ul class="govuk-list govuk-list--bullet">
<li class="govuk-list--bullet"><%= t('publish.dimension_match_failure.formatting') %></li>
<li class="govuk-list--bullet"><%= t('publish.dimension_match_failure.choices') %></li>
</ul>

<h2 class="govuk-heading-l"><%= t('publish.dimension_match_failure.subheading') %></h2>

<ul class="govuk-list govuk-list--bullet">
<% if (locals.extension.nonMatchingValues.length === 0) { %>
<li class="govuk-list--bullet"><%= t('publish.dimension_match_failure.no_matches') %></li>
<% } else { %>
<% locals.extension.nonMatchingValues.forEach((value) => { %>
<li class="govuk-list--bullet"><%= value %></li>
<% });%>
<% } %>
</ul>

<h2 class="govuk-heading-l"><%= t('publish.dimension_match_failure.actions') %></h2>

<p class="govuk-body"><a href="<%= buildUrl(`/publish/${locals.dataset.id}/upload`, i18n.language) %>" class="govuk-link">
<%= t('publish.dimension_match_failure.upload_different_file')%>
</a><br>
<%= t('publish.dimension_match_failure.upload_different_file_warning')%></p>

<p class="govuk-body"><a href="<%= buildUrl(`/publish/${locals.datasetId}/lookup/${locals.dimension.id}/`, i18n.language) %>" class="govuk-link">
<%= t('publish.dimension_match_failure.try_different_format')%></a></p>
</main>
</div>

<%- include("../partials/footer"); %>
15 changes: 13 additions & 2 deletions src/views/publish/upload.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@
<% if (locals.revisit) { %>
<div class="top-links">
<div class="govuk-width-container">
<a href="javascript:history.back()" class="govuk-back-link"><%= t('buttons.back') %></a>
<a href="<%= locals.referrer %>" class="govuk-back-link"><%= t('buttons.back') %></a>
<% if (locals.datasetId) { %>
<a href="<%= buildUrl(`/publish/${locals.datasetId}/tasklist`, i18n.language) %>" class="govuk-link return-link"><%= t('publish.header.overview') %></a>
<% } %>
</div>
</div>
<% } %>

<h1 class="govuk-heading-xl"><%= t('publish.upload.title') %></h1>
<% if (locals.uploadType === 'lookup') { %>
<h1 class="govuk-heading-xl"><%= t('publish.upload.lookup_heading') %></h1>
<% } else if (locals.uploadType === 'measure') { %>
<h1 class="govuk-heading-xl"><%= t('publish.upload.measure_heading') %></h1>
<% } else { %>
<h1 class="govuk-heading-xl"><%= t('publish.upload.title') %></h1>
<% } %>

<%- include("../partials/error-handler"); %>

<form method="post" enctype="multipart/form-data">
<div class="govuk-form-group">
<label class="govuk-label govuk-label--m" for="csv">
Expand All @@ -26,6 +34,9 @@
<button type="submit" class="govuk-button" data-module="govuk-button">
<%= t('buttons.upload_csv') %>
</button>
<% if (locals.uploadType) { %>
<a href="#" class="govuk-button govuk-button--secondary"><%= t('buttons.preview') %></a>
<% } %>
</form>
</main>
</div>
Expand Down
Loading