Skip to content

Commit

Permalink
Merge commit 'b261a0b8d7096f5953b6fa045805047cce30068b' into 682-data…
Browse files Browse the repository at this point in the history
…set-task-list-fetch-data-from-all-active-resources
  • Loading branch information
GeorgeGoodall committed Dec 17, 2024
2 parents 7de56d1 + b261a0b commit 81db693
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 36 deletions.
9 changes: 2 additions & 7 deletions src/assets/scss/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -25,8 +26,6 @@ $govuk-global-styles: true;
white-space: normal;
min-width: fit-content;
}


}

.app-inset-text---warning {
Expand All @@ -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");
Expand Down Expand Up @@ -179,7 +177,6 @@ code * {
padding: 0px;
}


.dl-table {
overflow-y: auto;
overflow-x: hidden;
Expand All @@ -193,7 +190,6 @@ code * {
}
}


.dl-table__head {
position: sticky;
top: 0;
Expand All @@ -205,7 +201,6 @@ code * {
}
}


.dl-table__header {
border: 1px solid $govuk-border-colour;
text-wrap: nowrap;
Expand Down
21 changes: 5 additions & 16 deletions src/middleware/dataview.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<a href='${text}' target='_blank' rel='noopener noreferrer' aria-label='${text} (opens in new tab)'>${text}</a>`
} else {
value = text
}
if (urlRegex.test(entity[field])) {
html = `<a href='${entity[field]}' target='_blank' rel='noopener noreferrer' aria-label='${entity[field]} (opens in new tab)'>${entity[field]}</a>`
value = undefined
}

const valueObj = {
Expand Down
1 change: 0 additions & 1 deletion src/views/check/results/errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ <h3 class="govuk-heading-m">How to improve the data</h3>
{% block scripts %}
{{ super() }}
{% if options.geometries %}
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
<script>
window.serverContext = {
containerId: 'map',
Expand Down
1 change: 0 additions & 1 deletion src/views/check/results/no-errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ <h3 class="govuk-heading-m">Before you continue</h3>
{% block scripts %}
{{ super() }}
{% if options.geometries %}
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
<script>
window.serverContext = {
containerId: 'map',
Expand Down
2 changes: 1 addition & 1 deletion src/views/components/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<table class="govuk-table dl-table">
<colgroup>
{% for field in params.fields %}
<col class="{% if (r/.*-date/g).test(field) %}govuk-table__cell--numeric{% endif %}" />
<col />
{% endfor %}
</colgroup>
<thead class="govuk-table__head dl-table__head">
Expand Down
1 change: 0 additions & 1 deletion src/views/organisations/dataset-overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ <h2 class="govuk-heading-m">Dataset actions</h2>
{% block scripts %}
{{ super() }}
{% if showMap %}
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
<script>
window.serverContext = {
containerId: 'map',
Expand Down
1 change: 0 additions & 1 deletion src/views/organisations/issueDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ <h3 class="govuk-heading-m">
{% block scripts %}
{{ super() }}
{% if entry.geometries and entry.geometries.length %}
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
<script>
window.serverContext = {
containerId: 'map',
Expand Down
5 changes: 1 addition & 4 deletions src/views/organisations/issueTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
aria-label="Static map showing {{dataset.name}} for {{organisation.name}}.">
</div>
{% endif %}


</div>
</div>

Expand Down Expand Up @@ -109,7 +107,6 @@ <h3 class="govuk-heading-m">
{% block scripts %}
{{ super() }}
{% if geometries and geometries.length %}
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
<script>
window.serverContext = {
containerId: 'map',
Expand All @@ -119,4 +116,4 @@ <h3 class="govuk-heading-m">
</script>
<script src="/public/js/map.bundle.js"></script>
{% endif %}
{% endblock %}
{% endblock %}
8 changes: 4 additions & 4 deletions test/unit/middleware/dataview.middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
]
Expand Down

0 comments on commit 81db693

Please sign in to comment.