diff --git a/src/controllers/publish.ts b/src/controllers/publish.ts index 3115a9e..87ef54b 100644 --- a/src/controllers/publish.ts +++ b/src/controllers/publish.ts @@ -337,9 +337,8 @@ export const fetchTimeDimensionPreview = async (req: Request, res: Response, nex export const yearTypeChooser = async (req: Request, res: Response, next: NextFunction) => { try { - const dimension = singleLangDataset(res.locals.dataset, req.language).dimensions?.find( - (dim) => dim.id === req.params.dimensionId - ); + const dataset = singleLangDataset(res.locals.dataset, req.language); + const dimension = dataset.dimensions?.find((dim) => dim.id === req.params.dimensionId); if (!dimension) { logger.error('Failed to find dimension in dataset'); next(new NotFoundException()); @@ -361,19 +360,20 @@ export const yearTypeChooser = async (req: Request, res: Response, next: NextFun ) ); return; + } else { + req.session.dimensionPatch = { + dimension_type: DimensionType.TimePeriod, + date_type: req.body.yearType + }; + req.session.save(); + res.redirect( + req.buildUrl( + `/publish/${req.params.datasetId}/time-period/${req.params.dimensionId}/period-of-time/year-format`, + req.language + ) + ); + return; } - req.session.dimensionPatch = { - dimension_type: DimensionType.TimePeriod, - date_type: req.body.yearType - }; - req.session.save(); - res.redirect( - req.buildUrl( - `/publish/${req.params.datasetId}/time-period/${req.params.dimensionId}/period-of-time/year-format`, - req.language - ) - ); - return; } res.render('publish/year-type'); @@ -516,7 +516,7 @@ export const quarterChooser = async (req: Request, res: Response, next: NextFunc return; } patchRequest.quarter_format = req.body.quarterType; - if (req.body.fifthQuarter) { + if (req.body.fifthQuater === 'yes') { patchRequest.fifth_quarter = true; } try { @@ -527,6 +527,8 @@ export const quarterChooser = async (req: Request, res: Response, next: NextFunc res.redirect(`/publish/${req.params.datasetId}/time-period/${req.params.dimensionId}/review`); return; } catch (err) { + req.session.dimensionPatch = undefined; + req.session.save(); const error = err as ApiException; logger.debug(`Error is: ${JSON.stringify(error, null, 2)}`); if (error.status === 400) { @@ -537,6 +539,7 @@ export const quarterChooser = async (req: Request, res: Response, next: NextFunc return; } logger.error('Something went wrong other than not matching'); + logger.error(`Full error JSON: ${JSON.stringify(error, null, 2)}`); res.redirect( req.buildUrl( `/publish/${req.params.datasetId}/time-period/${req.params.dimensionId}/period-of-time/`, diff --git a/src/i18n/en.json b/src/i18n/en.json index 41cb362..57cef2e 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -2,6 +2,8 @@ "developer_warning": "Warning This is a developer page and has not been through user research", "developer_tag": "Developer Page", "external_tag": "External Page", + "yes": "Yes", + "no": "No", "buttons": { "continue": "Continue", "back": "Back", @@ -89,7 +91,7 @@ } }, "time_dimension_chooser": { - "heading": "Set up dimension containing time", + "heading": "Set up dimension containing dates", "subheading": "Dates", "showing": "A sample of {{rows}} of {{total}} rows.", "question": "What kind of dates does the dimension contain?", @@ -131,7 +133,7 @@ } }, "period-type-chooser": { - "heading": "What are the periods of time?", + "heading": "What are the shortest periods of time in the dimension?", "subheading": "Dates", "chooser": { "years": "Years", @@ -140,46 +142,47 @@ } }, "year_type": { - "heading": "What type of year does this dimension represent?", + "heading": "What type of year does the dimension represent?", "chooser": { "calendar": "Calendar", - "calendar-hint": "1st January - 31st December", + "calendar-hint": "1 January to 31 December", "financial" : "Financial", - "financial-hint": "1st April - 31st March", + "financial-hint": "1 April to 31 March", "tax": "Tax", - "tax-hint": "6th April - 5th April", + "tax-hint": "6 April to 5 April", "academic": "Academic", - "academic-hint": "1st September - 31st August", + "academic-hint": "1 September to 31 August", "meteorological": "Meteorological", - "meteorological-hint": "1st March - 28th/29th February" + "meteorological-hint": "1 March to 28 or 29 February" } }, "year_format": { - "heading": "What format is used to represent years?", + "heading": "What format is used for years in the dimension?", "example": "For example, {{example}}" }, "quarter_format": { - "heading": "What format is used to represent quarters?", + "heading": "What format is used for quarters in the dimension?", "heading-alt": "What format is used for quarterly totals?", "example": "For example, {{example}}", - "fifth_quarter": "Year totals are represented as a 5th quarter", + "fifth_quarter": "Is a quarter used to represent yearly totals?\n", "no_quarterly_totals": "There are no quarterly totals" }, "month_format": { - "heading": "What format is used to represent months?", + "heading": "What format is used for months in the dimension?", "example": "For example, {{example}}" }, "period_match_failure": { - "heading": "Date formatting cannot be matched to the fact table", - "information": "{{failureCount}} of the dates in the fact table do not match the date formatting you have indicated. You should check:", - "formatting": "the date formatting in the fact table is correct", - "choices": "you indicated the correct date formats", - "supplied_format":"Indicated date format:", + "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:", + "formatting": "all date codes in the dimension are correct", + "choices": "you indicated the correct date formatting", + "supplied_format":"Indicated date formatting:", "year_format": "Years: {{format}}", "quarter_format": "Quarters: {{format}}", "month_format": "Months: {{format}}", "date_format": "Date: {{format}}", - "subheading": "Date formats that cannot be matched", + "subheading": "Unique date 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": "Indicate different date formatting", @@ -436,6 +439,7 @@ "rows": "{{count}} row", "rows_other": "{{count}} rows", "row_number": "Row", + "preview_summary": "There are $t(publish.preview.columns, {\"count\": {{cols}} }) and $t(publish.preview.rows, {\"count\": {{rows}} }) in your upload.", "columns_rows": "$t(publish.preview.columns, {\"count\": {{cols}} }) and $t(publish.preview.rows, {\"count\": {{rows}} })", "upload_summary": "There are $t(publish.preview.columns, {\"count\": {{cols}} }) and $t(publish.preview.rows, {\"count\": {{rows}} }) in the data table. $t(publish.preview.columns, {\"count\": {{ignored}} }) in the CSV upload have been ignored.", "showing_rows": "Showing rows {{start}} – {{end}} of {{total}}", @@ -452,7 +456,7 @@ "measure" : "Measure or data types", "dimension": "Dimension", "time": "Dimension containing dates", - "ignore": "Ignored", + "ignore": "This column can be ignored", "unknown": "Unknown" } }, @@ -549,7 +553,8 @@ "download_file": "Download File", "location": "Location", "filename": "Filename", - "mime_type": "Mime Type" + "mime_type": "Mime Type", + "fact_tables": "Fact Tables" } }, "errors": { diff --git a/src/views/partials/pagination.ejs b/src/views/partials/pagination.ejs index e5d1659..3f496fc 100644 --- a/src/views/partials/pagination.ejs +++ b/src/views/partials/pagination.ejs @@ -72,9 +72,7 @@ -
-

- <%= t('publish.preview.showing_rows', {start: locals.page_info.start_record, end: locals.page_info.end_record, total: locals.page_info.total_records}) %> -

+
+ <%= t('publish.preview.showing_rows', {start: locals.page_info.start_record, end: locals.page_info.end_record, total: locals.page_info.total_records}) %>
\ No newline at end of file diff --git a/src/views/publish/period-match-failure.ejs b/src/views/publish/period-match-failure.ejs index 36b0c80..3cfcda4 100644 --- a/src/views/publish/period-match-failure.ejs +++ b/src/views/publish/period-match-failure.ejs @@ -46,6 +46,8 @@ <% } %> +

<%= t('publish.period_match_failure.actions') %>

+

<%= t('publish.period_match_failure.upload_different_file')%>
diff --git a/src/views/publish/preview.ejs b/src/views/publish/preview.ejs index 236792c..bb589d3 100644 --- a/src/views/publish/preview.ejs +++ b/src/views/publish/preview.ejs @@ -19,13 +19,12 @@ <%- include("../partials/error-handler"); %>

-
-

+

+

<% if (locals.revisit) { %> <%= t('publish.preview.upload_summary', {cols: locals.headers?.length - locals.ignoredCount, rows: locals.page_info?.total_records, ignored: locals.ignoredCount}) %> <% } else { %> - <%- t('publish.preview.upload_has') %> - <%= t('publish.preview.columns_rows', {cols: locals.headers.length, rows: locals.page_info.total_records}) %> + <%= t('publish.preview.preview_summary', {cols: locals.headers.length, rows: locals.page_info.total_records}) %> <% } %>

@@ -63,16 +62,18 @@ <% locals.headers.forEach(function(cell, idx) { %> - - <% if (cell.source_type && cell.source_type !== 'unknown' && cell.source_type !== 'line_number') { %> - <%= t(`publish.preview.source_type.${cell.source_type}`) %>
- <% } %> - <% if (cell.source_type !== 'line_number') { %> + <% if (cell.source_type === 'line_number') { %> + + <%= t('publish.preview.row_number') %> + + <% } else { %> + + <% if (cell.source_type && cell.source_type !== 'unknown' && cell.source_type !== 'line_number') { %> + <%= t(`publish.preview.source_type.${cell.source_type}`) %>
+ <% } %> <%= cell.name || t('publish.preview.unnamed_column', { colNum: idx + 1 }) %> - <% } else { %> - <%= t('publish.preview.row_number') %> - <% } %> - + + <% } %> <% }); %> @@ -80,11 +81,9 @@ <% locals.data.forEach(function(row) { %> <% row.forEach(function(cell, index) { %> - <% if (index === 0) { %> - <%= cell %> - <% } else { %> - <%= cell %> - <% } %> + + <%= cell %> + <% }); %> <% }); %> @@ -96,20 +95,24 @@ <%- include("../partials/pagination", t, locals.current_page, locals.total_records, locals.pagaination); %>
-
- <% if (locals.revisit) { %> - <%= t('publish.preview.buttons.change_datatable') %> - <% } else { %> -

<%= t('publish.preview.confirm_correct') %>

-
- -
- <% } %> +
+ +
<% } %> @@ -133,13 +136,10 @@ background-color: #eeeeee; } - .line-number { - color: #7f7f7f; - } - - tbody > tr > td.line-number { + tbody > tr > td.line_number { text-align: right; font-family: monospace; + color: #7f7f7f; } .region-subhead { diff --git a/src/views/publish/quarter-format.ejs b/src/views/publish/quarter-format.ejs index 969c6b9..7f9e7dc 100644 --- a/src/views/publish/quarter-format.ejs +++ b/src/views/publish/quarter-format.ejs @@ -87,15 +87,33 @@
<% } %> -
 
-
- -
+ +
+
+ +

<%- t('publish.quarter_format.fifth_quarter')%> - -

+ + +

<%- t('publish.quarter_format.example', { example: 'Q5' })%>

+
+
+ + +
+
+ + +
+
diff --git a/src/views/publish/year-type.ejs b/src/views/publish/year-type.ejs index b512838..2bfa859 100644 --- a/src/views/publish/year-type.ejs +++ b/src/views/publish/year-type.ejs @@ -47,6 +47,15 @@ <%= t('publish.year_type.chooser.calendar-hint')%> +
+ + +
+ <%= t('publish.year_type.chooser.meteorological-hint')%> +
+
-
- - -
- <%= t('publish.year_type.chooser.meteorological-hint')%> -
-