From d3a38215dc838cb57a84ec890caf49d508933d57 Mon Sep 17 00:00:00 2001 From: Dilwoar Hussain Date: Thu, 12 Dec 2024 15:36:55 +0000 Subject: [PATCH 1/2] Remove numeric class from columns This makes all columns consistent. The GOVUK Design system documentation also suggests using this class only when comparing columns of numbers: When comparing columns of numbers, align the numbers to the right in table cells. https://github.com/digital-land/submit/issues/679 --- src/middleware/dataview.middleware.js | 21 +++++-------------- src/views/components/table.html | 2 +- .../middleware/dataview.middleware.test.js | 8 +++---- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/middleware/dataview.middleware.js b/src/middleware/dataview.middleware.js index 9cbaeaf8..27282046 100644 --- a/src/middleware/dataview.middleware.js +++ b/src/middleware/dataview.middleware.js @@ -39,25 +39,14 @@ export const constructTableParams = (req, res, next) => { const fields = uniqueDatasetFields const rows = entities.map(entity => ({ columns: Object.fromEntries(fields.map(field => { - let value - let classes = '' + let value = entity[field] + const classes = '' let html - // if the value is a number or a date string - if (/^\d{4}-\d{2}-\d{2}$/.test(entity[field]) || /^\d+(\.\d+)?$/.test(entity[field])) { - classes = 'govuk-table__cell--numeric' - value = entity[field] - } - const urlRegex = /^https?:\/\/[^\s]+$/ - - if (typeof entity[field] === 'string') { - const text = entity[field] - if (urlRegex.test(text)) { - html = `${text}` - } else { - value = text - } + if (urlRegex.test(entity[field])) { + html = `${entity[field]}` + value = undefined } const valueObj = { diff --git a/src/views/components/table.html b/src/views/components/table.html index b62748a0..8fac3c87 100644 --- a/src/views/components/table.html +++ b/src/views/components/table.html @@ -39,7 +39,7 @@ {% for field in params.fields %} - + {% endfor %} diff --git a/test/unit/middleware/dataview.middleware.test.js b/test/unit/middleware/dataview.middleware.test.js index 26c52820..a6cee40f 100644 --- a/test/unit/middleware/dataview.middleware.test.js +++ b/test/unit/middleware/dataview.middleware.test.js @@ -92,14 +92,14 @@ describe('dataview.middleware.test.js', () => { rows: [ { columns: { - num_field: { value: 0.06, classes: 'govuk-table__cell--numeric', html: undefined }, - date_field: { value: '2022-01-01', classes: 'govuk-table__cell--numeric', html: undefined } + num_field: { value: 0.06, classes: '', html: undefined }, + date_field: { value: '2022-01-01', classes: '', html: undefined } } }, { columns: { - num_field: { value: '10', classes: 'govuk-table__cell--numeric', html: undefined }, - date_field: { value: '2022-01-02', classes: 'govuk-table__cell--numeric', html: undefined } + num_field: { value: '10', classes: '', html: undefined }, + date_field: { value: '2022-01-02', classes: '', html: undefined } } } ] From a0f71ac3d91d84675834d91a750cf39774886114 Mon Sep 17 00:00:00 2001 From: Dilwoar Hussain Date: Fri, 13 Dec 2024 11:22:31 +0000 Subject: [PATCH 2/2] Import maplibre css from node modules Removes the requirement to use CDNs to avoid risk to downtime indirectly. --- src/assets/scss/index.scss | 9 ++------- src/views/check/results/errors.html | 1 - src/views/check/results/no-errors.html | 1 - src/views/organisations/dataset-overview.html | 1 - src/views/organisations/issueDetails.html | 1 - src/views/organisations/issueTable.html | 5 +---- 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/assets/scss/index.scss b/src/assets/scss/index.scss index f264a630..cb4e0840 100644 --- a/src/assets/scss/index.scss +++ b/src/assets/scss/index.scss @@ -2,6 +2,7 @@ $govuk-global-styles: true; @import "node_modules/govuk-frontend/dist/govuk/all"; @import "node_modules/@x-govuk/govuk-prototype-components/x-govuk/all"; +@import "node_modules/maplibre-gl/dist/maplibre-gl"; @import "src/assets/scss/_scrollable-container.scss"; @import "./step-by-step-nav.scss"; @import "./overrides"; @@ -25,8 +26,6 @@ $govuk-global-styles: true; white-space: normal; min-width: fit-content; } - - } .app-inset-text---warning { @@ -42,9 +41,8 @@ $govuk-global-styles: true; color: govuk-colour('blue'); font-weight: bold; } - - } + .app-map { height: 500px; @include govuk-responsive-margin(6, $direction: "bottom"); @@ -179,7 +177,6 @@ code * { padding: 0px; } - .dl-table { overflow-y: auto; overflow-x: hidden; @@ -193,7 +190,6 @@ code * { } } - .dl-table__head { position: sticky; top: 0; @@ -205,7 +201,6 @@ code * { } } - .dl-table__header { border: 1px solid $govuk-border-colour; text-wrap: nowrap; diff --git a/src/views/check/results/errors.html b/src/views/check/results/errors.html index a60eb2ce..46d6f9dc 100644 --- a/src/views/check/results/errors.html +++ b/src/views/check/results/errors.html @@ -95,7 +95,6 @@

How to improve the data

{% block scripts %} {{ super() }} {% if options.geometries %} - {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %}