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 issue and does some rework for UX #57

Merged
merged 1 commit into from
Dec 11, 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
35 changes: 19 additions & 16 deletions src/controllers/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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');
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -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/`,
Expand Down
45 changes: 25 additions & 20 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"developer_warning": "<strong class=\"govuk-tag govuk-tag--red govuk-phase-banner__content__tag\">Warning</strong> This is a developer page and has not been through user research",
"developer_tag": "<span class=\"govuk-tag govuk-tag--yellow govuk-phase-banner__content__tag\">Developer Page</span>",
"external_tag": "<span class=\"govuk-tag govuk-tag--orange govuk-phase-banner__content__tag\">External Page</span>",
"yes": "Yes",
"no": "No",
"buttons": {
"continue": "Continue",
"back": "Back",
Expand Down Expand Up @@ -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?",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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}}",
Expand All @@ -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"
}
},
Expand Down Expand Up @@ -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": {
Expand Down
6 changes: 2 additions & 4 deletions src/views/partials/pagination.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@
</nav>
</div>

<div class="govuk-grid-column-one-third">
<p class="govuk-body" style="text-align: right; padding-top: 10px">
<%= t('publish.preview.showing_rows', {start: locals.page_info.start_record, end: locals.page_info.end_record, total: locals.page_info.total_records}) %>
</p>
<div class="govuk-grid-column-one-third govuk-hint" style="text-align: right; padding-top: 10px">
<%= t('publish.preview.showing_rows', {start: locals.page_info.start_record, end: locals.page_info.end_record, total: locals.page_info.total_records}) %>
</div>
</div>
2 changes: 2 additions & 0 deletions src/views/publish/period-match-failure.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
<% } %>
</ul>

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

<p class="govuk-body"><a href="<%= buildUrl(`/publish/${locals.dataset.id}/upload`, i18n.language) %>" class="govuk-link">
<%= t('publish.period_match_failure.upload_different_file')%>
</a><br>
Expand Down
64 changes: 32 additions & 32 deletions src/views/publish/preview.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
<%- include("../partials/error-handler"); %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<p class="govuk-body" style="padding-top: 10px;">
<div class="govuk-grid-column-one-half" style="padding-top: 7px">
<p class="govuk-body">
<% if (locals.revisit) { %>
<%= t('publish.preview.upload_summary', {cols: locals.headers?.length - locals.ignoredCount, rows: locals.page_info?.total_records, ignored: locals.ignoredCount}) %>
<% } else { %>
<strong><%- t('publish.preview.upload_has') %></strong>
<%= 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}) %>
<% } %>
</p>
</div>
Expand Down Expand Up @@ -63,28 +62,28 @@
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<% locals.headers.forEach(function(cell, idx) { %>
<th scope="col" class="govuk-table__header <%= cell.source_type === 'line_number' ? 'line-number' :'' %>">
<% if (cell.source_type && cell.source_type !== 'unknown' && cell.source_type !== 'line_number') { %>
<span class="region-subhead"><%= t(`publish.preview.source_type.${cell.source_type}`) %></span><br />
<% } %>
<% if (cell.source_type !== 'line_number') { %>
<% if (cell.source_type === 'line_number') { %>
<th scope="col" class="govuk-table__header">
<span class="govuk-visually-hidden"><%= t('publish.preview.row_number') %></span>
</th>
<% } else { %>
<th scope="col" class="govuk-table__header">
<% if (cell.source_type && cell.source_type !== 'unknown' && cell.source_type !== 'line_number') { %>
<span class="region-subhead"><%= t(`publish.preview.source_type.${cell.source_type}`) %></span><br />
<% } %>
<%= cell.name || t('publish.preview.unnamed_column', { colNum: idx + 1 }) %>
<% } else { %>
<%= t('publish.preview.row_number') %>
<% } %>
</th>
</th>
<% } %>
<% }); %>
</tr>
</thead>
<tbody>
<% locals.data.forEach(function(row) { %>
<tr>
<% row.forEach(function(cell, index) { %>
<% if (index === 0) { %>
<td class="govuk-table__cell line-number"><span class="linespan"><%= cell %></span></td>
<% } else { %>
<td class="govuk-table__cell"><%= cell %></td>
<% } %>
<td class="govuk-table__cell <%= locals.headers[index].source_type %>">
<%= cell %>
</td>
<% }); %>
</tr>
<% }); %>
Expand All @@ -96,20 +95,24 @@
<%- include("../partials/pagination", t, locals.current_page, locals.total_records, locals.pagaination); %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<% if (locals.revisit) { %>
<a href="<%= buildUrl(`/publish/${locals.datasetId}/change`, i18n.language) %>" class="govuk-button govuk-!-display-inline"><%= t('publish.preview.buttons.change_datatable') %></a>
<% } else { %>
<p class="govuk-body"><%= t('publish.preview.confirm_correct') %></p>
<form method="post" role="continue">
<button type="submit" name="confirm" value="true" class="govuk-button govuk-!-display-inline" data-module="govuk-button" data-prevent-double-click="true">
<div class="govuk-grid-column-full">
<form method="post" role="continue">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--m">
<h2 class="govuk-fieldset__heading">
<%= t('publish.preview.confirm_correct') %>
</h2>
</legend>
<div class="govuk-button-group">
<button type="submit" name="confirm" value="true" class="govuk-button" data-module="govuk-button" style="vertical-align: unset;" data-prevent-double-click="true">
<%= t('buttons.continue') %>
</button>
<button type="submit" name="confirm" value="false" class="govuk-button govuk-button--secondary govuk-!-display-inline" data-module="govuk-button">
<%= t('publish.preview.buttons.choose_different') %>
</button>
</form>
<% } %>
</div>
</fieldset>
</form>
</div>
</div>
<% } %> <!-- Do I have data? -->
Expand All @@ -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 {
Expand Down
30 changes: 24 additions & 6 deletions src/views/publish/quarter-format.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,33 @@
</label>
</div>
<% } %>
<div class="govuk-checkboxes__divider">&nbsp;</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="fifthQuarter" name="fifthQuarter" type="checkbox" value="true">
<label class="govuk-label govuk-checkboxes__label" for="fifthQuarter">
</fieldset>
</div>

<div class="govuk-form-group">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
<h2 class="govuk-fieldset__heading">
<%- t('publish.quarter_format.fifth_quarter')%>
</label>
</div>
</h2>
</legend>
<p class="govuk-hint"><%- t('publish.quarter_format.example', { example: 'Q5' })%></p>
<div class="govuk-radios" data-module="govuk-radios">
<div class="govuk-radios__item">
<input class="govuk-radios__input" id="fifth-quater-yes" name="fifthQuater" type="radio" value="yes">
<label class="govuk-label govuk-radios__label" for="fifth-quater-yes">
<%= t('yes') %>
</label>
</div>
<div class="govuk-radios__item">
<input class="govuk-radios__input" id="fifth-quater-no" name="fifthQuater" type="radio" value="no">
<label class="govuk-label govuk-radios__label" for="fifth-quater-no">
<%= t('no') %>
</label>
</div>
</fieldset>
</div>

<div class="govuk-button-group">
<button type="submit" name="confirm" value="true" class="govuk-button" data-module="govuk-button" style="vertical-align: unset;" data-prevent-double-click="true">
<%= t('buttons.continue') %>
Expand Down
2 changes: 1 addition & 1 deletion src/views/publish/time-chooser.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<% }); %>
</tbody>
</table>
<p class="govuk-body"><%= t('publish.time_dimension_review.showing', {rows: locals.page_size, total: locals.page_info.total_records}) %></p>
<p class="govuk-body govuk-hint"><%= t('publish.time_dimension_review.showing', {rows: locals.page_size, total: locals.page_info.total_records}) %></p>
</div>
</div>

Expand Down
Loading
Loading