Skip to content

Commit

Permalink
Merge branch 'development' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
teddmason committed Nov 18, 2021
2 parents e3383df + 6f3d82b commit f6ab4e8
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 4 deletions.
43 changes: 41 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"body-scroll-lock": "^3.1.5",
"core-js": "2.6.11",
"d3": "^7.1.1",
"datatables.net-buttons": "^2.0.1",
"datatables.net-buttons-dt": "^2.0.1",
"datatables.net-dt": "^1.11.3",
"elm-pep": "^1.0.6",
"geojson": "0.5.0",
Expand All @@ -70,7 +72,6 @@
"webpack": "^5.57.1",
"webpack-cli": "^4.9.0"
},
"devDependencies": {},
"standard": {
"ignore": [
"server/dist",
Expand Down
28 changes: 27 additions & 1 deletion server/src/js/pages/stations-overview.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import $ from 'jquery'
import 'datatables.net-dt'
import 'datatables.net-buttons'
import 'datatables.net-buttons/js/buttons.html5.js'
window.jQuery = $
window.$ = $

$(document).ready(function () {
$('#stations-overview').DataTable({
dom: 'lBfrtip',
buttons: [{
extend: 'csv',
text: 'Export as csv',
filename: 'stations-overview-' + new Date().toISOString(),
exportOptions: {
modifier: {
search: 'none'
},
format: {
header: (data, row, column, node) => {
if (data.indexOf('<select>') > -1) {
data = data.match(/(?<=">)(.*?)(?=<\/option>)/g)[0] || data
}
return data
}
}
}
}],
initComplete: function () {
this.api().columns().every(function () {
const column = this
Expand All @@ -23,7 +44,7 @@ $(document).ready(function () {
'percentile_95'
]
if (noSelect.indexOf(column.header().innerHTML) === -1) {
const select = $('<select><option value="">' + column.header().innerHTML + '</option></select>')
const select = $('<select><option value="" style="font-weight:800">' + column.header().innerHTML + '</option></select>')
.appendTo($(column.header()).empty())
.on('change', function () {
const val = $.fn.dataTable.util.escapeRegex(
Expand All @@ -44,6 +65,11 @@ $(document).ready(function () {
$('#stations-overview').removeClass('off-screen')
// After processing adjust body to match table
$('body').width($('table').width() + 30)

// wrap top controls
$('.dataTables_length, .dt-buttons, .dataTables_filter').wrapAll('<div class="top-controls" />')
// wrap bottom controls
$('.dataTables_info, .dataTables_paginate').wrapAll('<div class="bottom-controls" />')
}
})
})
2 changes: 2 additions & 0 deletions server/src/sass/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ $govuk-breakpoints: (
@import "components/flood-location-link";
@import "components/toggle-list-display";
@import "components/social";
@import "components/stations-overview";

// Utilities
@import "utilities/details";
@import "utilities/summary-list";

// Datatables
@import "node_modules/datatables.net-dt/css/jquery.dataTables";
@import "node_modules/datatables.net-buttons-dt/css/buttons.dataTables";
31 changes: 31 additions & 0 deletions server/src/sass/components/_stations-overview.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#stations-overview_wrapper {
.top-controls,
.bottom-controls {
overflow: auto;
}
.dataTables_length,
.dt-buttons {
text-align: left !important;
}
.dt-buttons,
.dataTables_length,
.dataTables_filter {
padding-right: 10px;
}

.dataTables_length {
padding-top: 10px;
padding-bottom: 10px;
}
.dataTables_filter {
padding-top: 5px;
}

.dataTables_paginate,
.dataTables_filter {
float: left !important;
}
.dataTables_info {
float: right !important;
}
}
15 changes: 15 additions & 0 deletions server/views/stations-overview.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{% extends 'layout.html' %}

{% block head %}
{{ super() }}
<meta name="robots" content="noindex" />
{% endblock %}

{% block content %}
<style>
.govuk-width-container {
Expand Down Expand Up @@ -27,6 +32,16 @@ <h2 class="govuk-heading-m" id="loading">Loading data, one moment please...</h2>
<td class="govuk-table__cell">
{% if name === 'rloi_id' %}
<a href="/station/{{ value }}{% if station.direction === 'd' %}/downstream{% endif%}" target="_blank">{{ value }}</a>
{% elif name === 'error' %}
{% if value %}
yes
{% else %}
{% if value === false %}
no
{% else %}
n/a
{% endif %}
{% endif %}
{% else %}
{{ value }}
{% endif %}
Expand Down

0 comments on commit f6ab4e8

Please sign in to comment.