Skip to content

Feat/df 1086: Geometry type restrictions#407

Merged
jbarnsley10 merged 5 commits into
mainfrom
feat/df-1086-geometry-type-restrictions
May 19, 2026
Merged

Feat/df 1086: Geometry type restrictions#407
jbarnsley10 merged 5 commits into
mainfrom
feat/df-1086-geometry-type-restrictions

Conversation

@jbarnsley10
Copy link
Copy Markdown
Contributor

@jbarnsley10 jbarnsley10 commented May 19, 2026

Proposed change

Allows the form definition to specify which geometry types (point, line or shape) are allowed to be entered in the map (Geospatial component)

Jira ticket: DF-1086

Type of change

  • 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).

return `${items[0]} or ${items[1]}`
}

return `${items[0]}, ${items[1]} or ${items[2]}`
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.

probably more futureproof to replace this with a join?

  if (items.length === 2) {
    return items.join(' or ')
  }

  const last = items.pop()
  return `${items.join(', ')} or ${last}`

bonus points if you split out the two into a business logic function and a formatting function, e.g.

function formatDelimitedList(items, separator, lastSeparator) {}
function getAllowedTypesPhrase(allowPoint, allowLine, allowShape) // calls formatDelimitedList(items, ',', 'or')

* @returns {string}
*/
function getAllowableGeometryTypes() {
return options.geometryTypes ?? ''
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 wonder if a string[] would be better here?
Otherwise, if we introduce more geometry types later e.g. multipoint, multiline the string.includes below might give false positives.

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.

Yes, I think that's a good point. It has to be a string when coming from dataset attributes, but I could parse into an array here.

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.

Pushed

@sonarqubecloud
Copy link
Copy Markdown

@jbarnsley10 jbarnsley10 merged commit ca53207 into main May 19, 2026
25 checks passed
@jbarnsley10 jbarnsley10 deleted the feat/df-1086-geometry-type-restrictions branch May 19, 2026 12:34
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.

3 participants