Skip to content

feat DF-527: location components#225

Merged
mokhld merged 22 commits intomainfrom
feat/df-527-location
Oct 30, 2025
Merged

feat DF-527: location components#225
mokhld merged 22 commits intomainfrom
feat/df-527-location

Conversation

@mokhld
Copy link
Copy Markdown
Contributor

@mokhld mokhld commented Oct 21, 2025

Proposed change

Jira ticket:

https://eaflood.atlassian.net/browse/DF-529

  • Bug fix
  • New feature
  • Breaking change
  • Misc. (documentation, build updates, etc)

Checklist

  • You have executed this code locally and it performs as expected.
  • You have added tests to verify your code works.
  • You have added code comments and JSDoc, where appropriate.
  • There is no commented-out code.
  • You have added developer docs in README.md and docs/* (where appropriate, e.g. new features).
  • The tests are passing (npm run test).
  • The linting checks are passing (npm run lint).
  • The code has been formatted (npm run format).

@mokhld mokhld marked this pull request as ready for review October 21, 2025 08:50
@mokhld mokhld force-pushed the feat/df-527-location branch from 6b33cc0 to e7a6177 Compare October 24, 2025 11:43

const { name, options, schema } = def

const isRequired = options.required !== false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sonar doesn't like the negation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed to not complain about this one.


protected getValidationConfig() {
return {
pattern: /^[A-Z]{2}\d{8}$/i,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this pattern used anywhere? It may fail if the value hasn't been cleaned (your custom validation cleans before validating)

def: ComponentDef,
options: ConstructorParameters<typeof ComponentBase>[1]
): Component {
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Was there a type error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was initially, but it's not complaining now so have removed.

name?: string
value?: Item['value']
classes?: string
prefix?: ComponentText
Copy link
Copy Markdown
Contributor

@jbarnsley10 jbarnsley10 Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a prefix/suffix needed on a DateInputItem? Or is this part of your pre/post markdown stuff?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to match to figma designs in that there is a grey degree unit symbol in the input field for lat/ long fields. I'll a comment to make it clearer.

controller = new PageControllers.SummaryPageController(model, pageDef)
break

case ControllerType.SummaryWithConfirmationEmail:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must have missed this when I added the confirmation email. Thanks for fixing


<div class="govuk-date-input">
{% for item in component.model.items %}
<div class="govuk-date-input__item">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a date-input-item?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, this was from an earlier draft. It makes sense to split this out into it's own css class and scss sheet.

Copy link
Copy Markdown
Contributor

@jbarnsley10 jbarnsley10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great work. Just a few comments/questions.


protected getValidationConfig() {
return {
pattern: /^[A-Z]{2}\d{6,10}$/i,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davidjamesstone ! Didn't know that was there. It's quite a bit more complicated than what I have here though however I'm probably missing test cases that would've failed for this. Will take a look.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's been updated.

const viewModel = super.getViewModel(payload, errors)

// Add instruction text to the component for rendering
if (this.instructionText) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have options available as a field, could we not use that rather than duplicating the var?

if (options.instructionText)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point, that been updated.

name: ComponentDef['name']
title: ComponentDef['title']
schema?: Extract<ComponentDef, { schema: object }>['schema']
schema?: Extract<ComponentDef, { schema?: unknown }>['schema']
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should always be an object, why is it unknown?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had type issues earlier, but resolved. That's been updated.

Comment on lines +47 to +50
const eastingMin = schema?.easting?.min ?? 0
const eastingMax = schema?.easting?.max ?? 70000
const northingMin = schema?.northing?.min ?? 0
const northingMax = schema?.northing?.max ?? 1300000
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid the magic numbers and put 70000, 1300000 in constants? What do they mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I was copying the defaults in the ticket but will update. I'm surprised Sonar never picked this up... It's usually pretty good at this sort of thing.

Copy link
Copy Markdown
Contributor

@davidjamesstone davidjamesstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New Major Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@mokhld mokhld merged commit b562f92 into main Oct 30, 2025
9 of 10 checks passed
@mokhld mokhld deleted the feat/df-527-location branch October 30, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants