Commit 8e5667b
authored
JSONForms address field: country-filtered states, defaults, BC geocoder search (#42)
* feat(forms): add JSONForms address field with country-filtered states
- New Address control (@repo/react) dispatched on options.format:'address':
searchable country combobox filters the states/provinces dropdown;
per-country state/postal labels (curated ISO2 map); postal field hidden
when the country has no postal system; changing country clears province.
Degrades to plain text inputs without a GeoDataProvider. Editable +
read-only display renderers + shared model/normalize helpers.
- GeoDataProvider hooks-port keeps the library API-agnostic; each web app
supplies its own geo fetchers and mounts the provider once at the root.
- Public geo API (/v1/geo/countries, /v1/geo/countries/:id/states) added
to both BFFs, reading geo reference data; integer :id validated -> 400.
- Form builder: 'address' palette entry + object-schema serialization.
- Postal codes validated against the country's regex on submit (422);
drafts remain unvalidated. Address stored inline in submission JSONB.
* feat(forms): address field default country / state in the builder inspector
- Inspector: an address field gains a geo-powered defaults editor (default
country + default state/province, reusing the same country-filtered
dropdowns and per-country labels as the field). Changing the default
country clears the default province.
- Model/codec: ControlNode carries defaultCountry/defaultProvince, serialized
into the address property's JSON-Schema `default` and parsed back.
- Renderer: the address control seeds itself from schema.default when the
field is still empty, so citizens see the pre-filled values (they can
change them). The write is deferred a macrotask (a handleChange during the
mount commit is dropped before JsonForms finishes init) and the seed flag
flips inside the timer so the seed survives StrictMode's double-invoke.
* feat(forms): BC address geocoder autocomplete for the address field
- New "Search for your address" typeahead under the Country selector, shown
only when the selected country/province is a server-supported geocoder region
(v1: Canada / British Columbia, matched by ISO codes). As-you-type it queries
the region's geocoder and fills Address line 1 + City on select (the geocoder
returns no postal code, so postal stays manual).
- ISO-scoped, extensible geocoder proxy on both BFFs: GET /v1/geo/address-search
and /address-search/regions (@public). A provider registry keyed by
"<COUNTRY>:<PROVINCE>" (CA:BC -> BC OLS geocoder) registers a region only when
its credentials are set; the API key stays server-side and never reaches the
browser. Upstream errors degrade to [] (typing never 5xxs). The states read
now exposes iso2 so the client can match regions.
- Env: optional BC_GEOCODER_API_KEY + BC_GEOCODER_URL (both apis); the field is
hidden entirely when the geocoder is unconfigured.
- GeoData port gains optional searchAddresses + useAddressSearchRegions; both web
apps wire them, with react-select(-async-paginate) added to optimizeDeps for
the lazy form route.
* style(platform-web): console sidebar nav active-state accent border
Remove the link underline and add a left accent border to the console
sidebar nav items — a transparent border by default, bcgov-blue when active.
* fix(forms): enforce required validation on the address field
A required address only forced the object to EXIST, not its sub-fields — and
the control writes empty strings, so blank addresses passed. Now a required
address serializes the object's own required set (country, address line 1,
city, state/province, postal code — address line 2 stays optional) with
minLength:1, so empties are rejected by Ajv on both the client (JSONForms
submit gating) and the server (submit validation).
JSONForms attributes the sub-field (child-path) errors below the object
control, not on it, so the address field showed no message — the citizen saw
a disabled Submit with no reason. The control now derives requiredness from
the schema and renders its own per-field asterisk + "This field is required"
message (shown in validation-visible modes).
* fix(forms): show the selected address label, not raw JSON, in the search field
The address-search option value encodes the whole suggestion as JSON so a
pick can both fill the form and be mapped back. AsyncSelect's controlled-value
effect, with no resolver, was displaying that JSON value as the selected
label. Add a resolveValue that decodes the value back to the suggestion's
human `label` for display (via a shared parseSuggestion helper).
* feat(forms): default a new address field to Canada / British Columbia
createField('address') now seeds defaultCountry='Canada' and
defaultProvince='British Columbia', so a freshly-added address field
pre-fills those in the inspector's defaults editor and in the builder
preview. Authors can still change or clear them.
* feat(forms): show field defaults in the builder canvas card
The canvas field-card preview renders the control readonly, so the address
control's default-seeding effect (which skips readonly) never populated it —
the card showed an empty country/province. Seed the preview data from each
property's JSON-Schema `default`, so the address card reflects its Canada /
British Columbia default (and any future defaulted field shows its default).
* chore(charts): wire BC_GEOCODER_URL / BC_GEOCODER_API_KEY for the address search
Add BC_GEOCODER_URL (public BC OLS endpoint, non-sensitive) to the env
ConfigMap of both API charts, and document BC_GEOCODER_API_KEY as an optional
key in each app's existingSecret (values comments + charts README secret table
and create-secret example). Absent key → the address-search field is hidden.
The CI deploy's `helm dependency build` picks these up into the umbrella chart.1 parent 1c83560 commit 8e5667b
55 files changed
Lines changed: 3230 additions & 12 deletions
File tree
- apps
- citizen-portal-api
- src
- config
- modules
- applications
- services
- util
- geo
- controllers
- dtos
- services
- test
- citizen-portal-web
- src
- lib
- platform-api
- src
- config
- modules/geo
- controllers
- dtos
- services
- test
- platform-web
- src
- components
- console
- form-builder
- lib
- test
- charts
- citizen-portal-api
- platform-api
- packages/react
- src
- jsonforms-renderers-display
- controls
- jsonforms-renderers
- controls/address
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
Lines changed: 39 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
258 | 286 | | |
259 | 287 | | |
260 | 288 | | |
| |||
275 | 303 | | |
276 | 304 | | |
277 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
278 | 315 | | |
279 | 316 | | |
280 | 317 | | |
| |||
Lines changed: 101 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments