Skip to content

Commit e80d66a

Browse files
authored
Merge branch 'main' into user-defined-tables
2 parents f58711b + 6b73a57 commit e80d66a

26 files changed

Lines changed: 302 additions & 51 deletions

.github/workflows/codeql.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
analyze:
13-
name: Analyze (${{ matrix.language }})
13+
name: Analyze (${{ matrix.language }}${{ matrix.node-version && format(' - Node.js {0}', matrix.node-version) || '' }})
1414
# Runner size impacts CodeQL analysis time. To learn more, please see:
1515
# - https://gh.io/recommended-hardware-resources-for-running-codeql
1616
# - https://gh.io/supported-runners-and-hardware-resources
@@ -36,12 +36,32 @@ jobs:
3636
build-mode: none
3737
- language: javascript-typescript
3838
build-mode: none
39+
node-version: '16'
40+
- language: javascript-typescript
41+
build-mode: none
42+
node-version: '18'
43+
- language: javascript-typescript
44+
build-mode: none
45+
node-version: '20'
46+
- language: javascript-typescript
47+
build-mode: none
48+
node-version: '22'
49+
- language: javascript-typescript
50+
build-mode: none
51+
node-version: '24'
3952
- language: python
4053
build-mode: none
4154
steps:
4255
- name: Checkout repository
4356
uses: actions/checkout@v4
4457

58+
# Setup Node.js for JavaScript/TypeScript analysis
59+
- name: Setup Node.js
60+
if: matrix.language == 'javascript-typescript'
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: ${{ matrix.node-version }}
64+
4565
# Initializes the CodeQL tools for scanning.
4666
- name: Initialize CodeQL
4767
uses: github/codeql-action/init@v3

.github/workflows/lint.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
name: Lint JS
22
on:
33
push:
4-
branches: [main]
4+
branches: [ main ]
55
pull_request:
6-
branches: [main]
6+
branches: [ main ]
77
jobs:
88
lint-importer:
99
defaults:
1010
run:
1111
working-directory: ./lib/importer
1212
timeout-minutes: 5
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [ '20', '22', '24' ]
17+
name: Lint Importer (Node.js ${{ matrix.node-version }})
1418
steps:
1519
- uses: actions/checkout@v4
1620
- uses: actions/setup-node@v4
1721
with:
18-
node-version: lts/*
22+
node-version: ${{ matrix.node-version }}
1923
- name: Install dependencies
2024
run: npm i
2125
- name: Run linter

.github/workflows/test.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
name: Tests
22
on:
33
push:
4-
branches: [main]
4+
branches: [ main ]
55
pull_request:
6-
branches: [main]
6+
branches: [ main ]
77
jobs:
88
test:
99
defaults:
1010
run:
1111
working-directory: ./prototypes/basic
1212
timeout-minutes: 60
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [ '18', '20', '22', '24' ]
17+
name: Test (Node.js ${{ matrix.node-version }})
1418
steps:
1519
- uses: actions/checkout@v4
1620
- uses: actions/setup-node@v4
1721
with:
18-
node-version: lts/*
22+
node-version: ${{ matrix.node-version }}
1923
- name: Install lib dependencies -- todo, check why
2024
working-directory: ./lib/importer
2125
run: npm i
@@ -28,7 +32,7 @@ jobs:
2832
- uses: actions/upload-artifact@v4
2933
if: always()
3034
with:
31-
name: test-results
35+
name: test-results-node-${{ matrix.node-version }}
3236
path: ./prototypes/basic/test-results
3337
retention-days: 30
3438
importer:
@@ -37,11 +41,15 @@ jobs:
3741
working-directory: ./lib/importer
3842
timeout-minutes: 60
3943
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
node-version: [ '18', '20', '22', '24' ]
47+
name: Test Importer (Node.js ${{ matrix.node-version }})
4048
steps:
4149
- uses: actions/checkout@v4
4250
- uses: actions/setup-node@v4
4351
with:
44-
node-version: lts/*
52+
node-version: ${{ matrix.node-version }}
4553
- name: Install lib dependencies
4654
run: npm i
4755
- name: Run tests

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Make sure you also run the demo prototype so that it discovers the new local ver
5353

5454
### Merge into main
5555

56-
Following the usual process, and once approval is obtained for the change, merge the pull request into the `main` branch. This will result in the usual CI steps and followed by a deployment of the demo prototype.
56+
Following the usual process, and once approval is obtained for the change, merge the pull request into the `main` branch. This will result in the usual CI steps and followed by a deployment of the demo prototype to [https://data-importer.register-dynamics.co.uk](https://data-importer.register-dynamics.co.uk)
5757

5858
### Create a new github release
5959

lib/importer/assets/docs/start.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ <h2 class="govuk-heading-l">How to install it</h2>
128128
<p>
129129
Open up your preferred command line, which you previously used to create a GOV.UK Prototype, and type the following:
130130
</p>
131-
<pre>npm install 'https://gitpkg.vercel.app/register-dynamics/data-import/lib/importer?main'</pre>
131+
<pre>npm install --save @register-dynamics/importer@latest</pre>
132132
<p>
133133
After running this command new routes will automatically be added
134134
to your prototype’s <code>app/routes.js</code> file.

lib/importer/assets/js/selectable_table.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ window.addEventListener("load", function() {
4040
const brRowTarget = document.getElementById("importer:selection:BRRow");
4141
const brColTarget = document.getElementById("importer:selection:BRCol");
4242

43+
// If we have a value for the row target, then we want to select the cells in row tlr, column tlc
44+
// all the way to row brr, column brc by adding the selected class to each td in the range.
45+
if (tlRowTarget && tlRowTarget.value != "-1") {
46+
const [tlr, tlc, brr, brc] = [parseInt(tlRowTarget.value), parseInt(tlColTarget.value), parseInt(brRowTarget.value), parseInt(brColTarget.value)];
47+
const tables = document.querySelectorAll("table.selectable");
48+
for(const table of tables) {
49+
const tbody = table.querySelector("tbody");
50+
if (tbody) {
51+
52+
for (let rowIndex = tlr; rowIndex <= brr; rowIndex++) {
53+
const row = tbody.querySelector(`tr[data-row-index="${rowIndex + 1}"]`);
54+
if (row) {
55+
const cells = row.querySelectorAll("td");
56+
for (let colIndex = tlc; colIndex <= brc; colIndex++) {
57+
if (colIndex >= 0 && colIndex < cells.length) {
58+
cells[colIndex].classList.add(CellSelectedClassName);
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
};
66+
4367
const fromCoordsCache = new Map(); // table -> "row,col" -> CellRef
4468
const fromNodeCache = new Map(); // td node -> CellRef
4569

lib/importer/nunjucks/importer/macros/footer_selector.njk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
{% set rows = importerGetTrailingRows(params.data, params.count) %}
55
{% set caption = importerGetTableCaption(params.data, "Last", params.count) %}
66

7+
{% set currentSelection = params.current %}
8+
{% set setSelectionValue = currentSelection.start.row > -1 %}
9+
710
<div>
8-
<input type="hidden" name="importer:selection:TLRow" id="importer:selection:TLRow"/>
9-
<input type="hidden" name="importer:selection:TLCol" id="importer:selection:TLCol"/>
10-
<input type="hidden" name="importer:selection:BRRow" id="importer:selection:BRRow"/>
11-
<input type="hidden" name="importer:selection:BRCol" id="importer:selection:BRCol"/>
11+
<input type="hidden" name="importer:selection:TLRow" id="importer:selection:TLRow" {% if setSelectionValue %} value="{{ currentSelection.start.row }}" {% endif %}/>
12+
<input type="hidden" name="importer:selection:TLCol" id="importer:selection:TLCol" {% if setSelectionValue %} value="{{ currentSelection.start.column }}" {% endif %}/>
13+
<input type="hidden" name="importer:selection:BRRow" id="importer:selection:BRRow" {% if setSelectionValue %} value="{{ currentSelection.end.row }}" {% endif %}/>
14+
<input type="hidden" name="importer:selection:BRCol" id="importer:selection:BRCol" {% if setSelectionValue %} value="{{ currentSelection.end.column }}" {% endif %}/>
1215
</div>
1316

1417
<div class="rd-range-selector">

lib/importer/nunjucks/importer/macros/header_selector.njk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
{% set rows = importerGetRows(params.data, params.start, params.count) %}
66
{% set caption = importerGetTableCaption(params.data, "First", params.count) %}
77

8+
{% set currentSelection = params.current %}
9+
{% set setSelectionValue = currentSelection.start.row > -1 %}
10+
811
<div>
9-
<input type="hidden" name="importer:selection:TLRow" id="importer:selection:TLRow"/>
10-
<input type="hidden" name="importer:selection:TLCol" id="importer:selection:TLCol"/>
11-
<input type="hidden" name="importer:selection:BRRow" id="importer:selection:BRRow"/>
12-
<input type="hidden" name="importer:selection:BRCol" id="importer:selection:BRCol"/>
12+
<input type="hidden" name="importer:selection:TLRow" id="importer:selection:TLRow" {% if setSelectionValue %} value="{{ currentSelection.start.row }}" {% endif %}/>
13+
<input type="hidden" name="importer:selection:TLCol" id="importer:selection:TLCol" {% if setSelectionValue %} value="{{ currentSelection.start.column }}" {% endif %}/>
14+
<input type="hidden" name="importer:selection:BRRow" id="importer:selection:BRRow" {% if setSelectionValue %} value="{{ currentSelection.end.row }}" {% endif %}/>
15+
<input type="hidden" name="importer:selection:BRCol" id="importer:selection:BRCol" {% if setSelectionValue %} value="{{ currentSelection.end.column }}" {% endif %}/>
1316
</div>
1417

1518
<div class="rd-range-selector">

lib/importer/nunjucks/importer/macros/table_view.njk

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ Renders a table view using the provided parameters to determine what is being sh
2828
<tbody>
2929
{% for rowObj in params.rows %}
3030
<tr class="govuk-table__row {% if rowObj.error %}
31-
validation-error{%endif%}">
32-
33-
31+
validation-error{%endif%}" data-row-index="{{rowObj.index}}">
3432
{% if params.showRowNumbers %}
3533
<th scope="row" class="rowIndex">{{ rowObj.index }}</th>
3634
{% endif %}

lib/importer/nunjucks/views/error-handling/server-error.njk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{% extends "layouts/main.html" %}
22

3+
{% from "govuk/components/footer/macro.njk" import govukFooter %}
4+
35
{% block pageTitle %}
46
Error {% if serviceName %}{{ serviceName }}{% endif %} – GOV.UK Prototype Kit
57
{% endblock %}

0 commit comments

Comments
 (0)