Skip to content

tripDiary: support entering on the road work place when usual places are inlined - #1757

Merged
tahini merged 3 commits into
chairemobilite:mainfrom
tahini:fix1552
Jul 30, 2026
Merged

tripDiary: support entering on the road work place when usual places are inlined#1757
tahini merged 3 commits into
chairemobilite:mainfrom
tahini:fix1552

Conversation

@tahini

@tahini tahini commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

fixes #1552

Add 2 widgets, only when the inlineUsualPlacesEntry is true, to the visited places group: visitedPlacePreviousWorkPlaceName and visitedPlacePreviousWorkPlaceGeography. These widgets allow to enter the previous work place geography, when not available, to populate the previous place that will be added upon saving the place.

The widgets are not available if the inlineUsualPlacesEntry is false.

See individual commits for more details.

Summary by CodeRabbit

  • New Features
    • Added inline support for capturing a previous usual workplace name and its map location within relevant visited-place questions.
    • Included on-screen map instructions plus required-field and map precision validations, with improved feedback for missing or imprecise locations.
    • Automatically selects the best available starting point for map positioning (from the most relevant prior/home data).
  • Bug Fixes
    • Preserves previous workplace name and geography when usual workplaces are included for on-the-road work entries, preventing accidental overwrites.

@tahini
tahini requested a review from kaligrafy July 29, 2026 21:26
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ddf436b7-553f-4869-bb7f-ce94fcad0815

📥 Commits

Reviewing files that changed from the base of the PR and between d4f363b and aa2f822.

📒 Files selected for processing (9)
  • locales/en/visitedPlaces.yml
  • locales/fr/visitedPlaces.yml
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/types/Data.ts
📜 Recent review details
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-03-31T18:20:32.322Z
Learnt from: kaligrafy
Repo: chairemobilite/evolution PR: 1462
File: packages/evolution-common/src/services/baseObjects/Completable.ts:1-6
Timestamp: 2026-03-31T18:20:32.322Z
Learning: In this repository (chairemobilite/evolution), do not flag or require a copyright year in file headers. For new files, the header format `Copyright Polytechnique Montreal and contributors` (without a year) is acceptable. Only verify the header presence/consistency, not the presence of the year.

Applied to files:

  • packages/evolution-common/src/services/questionnaire/types/Data.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
📚 Learning: 2026-06-26T01:23:52.727Z
Learnt from: tahini
Repo: chairemobilite/evolution PR: 1683
File: packages/evolution-common/src/services/questionnaire/sections/segments/widgetSegmentModePre.ts:61-63
Timestamp: 2026-06-26T01:23:52.727Z
Learning: In chairemobilite/evolution questionnaire code, do not populate questionnaire label `context` with external factory option values (e.g., `WidgetFactoryOptions.context`). Treat label `context` as label-specific domain data only (such as sequence/gender). CATI variants must not be derived from translation/label context; route them via the dedicated CATI mechanism used elsewhere in the codebase.

Applied to files:

  • packages/evolution-common/src/services/questionnaire/types/Data.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
📚 Learning: 2026-06-15T16:08:25.515Z
Learnt from: tahini
Repo: chairemobilite/evolution PR: 1635
File: packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsGeography.ts:243-248
Timestamp: 2026-06-15T16:08:25.515Z
Learning: In the visitedPlaces questionnaire section, geography objects are expected to always include a `properties` field. When cloning/updating a visited-places geography (e.g., writing `clonedGeography.properties.lastAction`), using a non-null assertion (`clonedGeography.properties!.lastAction = ...`) is intentional. Reviewers should not treat this as a potential null/undefined bug or suggest changing it to optional chaining/guards; if `properties` is unexpectedly missing, it should fail fast as an upstream survey/data validation error.

Applied to files:

  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
🔇 Additional comments (13)
packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts (3)

22-32: Duplicated zoom constant and geography validation rules with widgetsGeography.ts; already tracked by the FIXME per your earlier note.


50-78: LGTM!

Also applies to: 94-166


8-20: 📐 Maintainability & Code Quality

No change needed.

_cloneDeep is imported but unused outside the import; the TS lint rule ignores unused variables prefixed with _, so this doesn’t need removal.

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts (2)

261-263: The widget lookup is now the geography one, but the path at Line 263 still ends with ._previousWorkPlace.name; same point as the earlier comment on this test.


32-51: LGTM!

Also applies to: 174-252, 330-453

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts (2)

321-325: Line 324 still ends with , instead of ; (the other block was fixed); same point as the earlier comment.


218-266: LGTM!

Also applies to: 267-320, 328-345, 426-427

packages/evolution-common/src/services/questionnaire/types/Data.ts (1)

239-244: LGTM!

locales/en/visitedPlaces.yml (1)

86-86: LGTM!

Also applies to: 98-103

locales/fr/visitedPlaces.yml (1)

84-84: LGTM!

Also applies to: 98-104

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts (1)

21-21: LGTM!

Also applies to: 43-47, 59-60, 141-144, 154-154

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts (1)

150-168: LGTM!

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts (1)

21-21: LGTM!

Also applies to: 30-31, 66-66, 403-481


Walkthrough

Adds inline previous workplace name and geography fields for on-the-road visited places. The widgets include conditional visibility, map centering, required-field and precision validations, and English/French translations. Group configuration registers them, while save-flow logic copies their values into inserted usual-workplace places. Tests cover widget behavior, group wiring, and insertion scenarios.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: kaligrafy

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: inlining usual work place entry in the tripDiary flow.
Linked Issues check ✅ Passed The PR adds the inlined usual work place widgets and save flow needed for workOnTheRoad with workUsual departures.
Out of Scope Changes check ✅ Passed The changes stay focused on the usual work place inline flow, with tests, locales, types, and widget wiring all in scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tahini

tahini commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Still needs to be tested in a real survey (od_mtl), but I'm putting up the PR now so coderabbitai can review it in parallel.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts`:
- Around line 229-232: Replace the trailing commas after the _previousWorkPlace
assignments in both affected test blocks with semicolons, keeping the following
arrivalTime statements separate.

In
`@packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts`:
- Line 366: Update the setResponse call in the affected geography test to
replace the correctly underscored previous-workplace geography path fragment,
matching the working paths used by the nearby cases so the activity response is
set.
- Around line 255-264: The test currently retrieves the name widget
configuration instead of the geography widget, so it does not cover the intended
non-inlined geography conditional. Update the `getWidgetConfigs()` lookup in the
test to use the previous-workplace geography widget’s configuration while
preserving the existing interview setup and expected false result.

In
`@packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts`:
- Around line 50-51: Remove the stray 'bla' literal from the parameter type of
the previousWorkPlaceConditional implementation, keeping it aligned with the
declared factory type's 'name' | 'geography' union.
- Around line 22-32: Share the visited-place geography validation helper and
default-zoom constant between widgetsPreviousWorkplaceGeography.ts and
widgetsGeography.ts. Extract the duplicated rules and constant into a common
module, then update both widget implementations to import and reuse them so
placement precision changes remain synchronized.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9b870341-c9d1-47ca-b8ce-be14cd47a4f9

📥 Commits

Reviewing files that changed from the base of the PR and between 53538a4 and d4f363b.

📒 Files selected for processing (9)
  • locales/en/visitedPlaces.yml
  • locales/fr/visitedPlaces.yml
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/types/Data.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: build-and-test (24.x)
  • GitHub Check: check-format
  • GitHub Check: code-lint
  • GitHub Check: test-sequential (24.x)
  • GitHub Check: generate-and-build-generator (24.x)
  • GitHub Check: pr-build-check
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-03-31T18:20:32.322Z
Learnt from: kaligrafy
Repo: chairemobilite/evolution PR: 1462
File: packages/evolution-common/src/services/baseObjects/Completable.ts:1-6
Timestamp: 2026-03-31T18:20:32.322Z
Learning: In this repository (chairemobilite/evolution), do not flag or require a copyright year in file headers. For new files, the header format `Copyright Polytechnique Montreal and contributors` (without a year) is acceptable. Only verify the header presence/consistency, not the presence of the year.

Applied to files:

  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/types/Data.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
📚 Learning: 2026-06-15T16:08:25.515Z
Learnt from: tahini
Repo: chairemobilite/evolution PR: 1635
File: packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsGeography.ts:243-248
Timestamp: 2026-06-15T16:08:25.515Z
Learning: In the visitedPlaces questionnaire section, geography objects are expected to always include a `properties` field. When cloning/updating a visited-places geography (e.g., writing `clonedGeography.properties.lastAction`), using a non-null assertion (`clonedGeography.properties!.lastAction = ...`) is intentional. Reviewers should not treat this as a potential null/undefined bug or suggest changing it to optional chaining/guards; if `properties` is unexpectedly missing, it should fail fast as an upstream survey/data validation error.

Applied to files:

  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
📚 Learning: 2026-06-26T01:23:52.727Z
Learnt from: tahini
Repo: chairemobilite/evolution PR: 1683
File: packages/evolution-common/src/services/questionnaire/sections/segments/widgetSegmentModePre.ts:61-63
Timestamp: 2026-06-26T01:23:52.727Z
Learning: In chairemobilite/evolution questionnaire code, do not populate questionnaire label `context` with external factory option values (e.g., `WidgetFactoryOptions.context`). Treat label `context` as label-specific domain data only (such as sequence/gender). CATI variants must not be derived from translation/label context; route them via the dedicated CATI mechanism used elsewhere in the codebase.

Applied to files:

  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts
  • packages/evolution-common/src/services/questionnaire/types/Data.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/widgetsPreviousWorkplaceGeography.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/buttonsVisitedPlace.test.ts
  • packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/widgetsPreviousWorkplaceGeography.test.ts
🔇 Additional comments (6)
packages/evolution-common/src/services/questionnaire/types/Data.ts (1)

239-244: LGTM!

locales/en/visitedPlaces.yml (1)

86-86: LGTM!

Also applies to: 98-103

locales/fr/visitedPlaces.yml (1)

84-84: LGTM!

Also applies to: 98-104

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/groupPersonVisitedPlaces.ts (1)

43-47: LGTM! Reverse-order insertion correctly puts the name question before the geography one, right after the on-the-road departure activity.

Also applies to: 59-60, 141-144, 154-154

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/__tests__/groupPersonVisitedPlaces.test.ts (1)

21-21: LGTM!

Also applies to: 30-31, 66-66, 403-481

packages/evolution-common/src/services/questionnaire/sections/visitedPlaces/buttonsVisitedPlace.ts (1)

150-168: 📐 Maintainability & Code Quality

No change needed.

VisitedPlace is not a strict name?: never discriminated union in this payload type, and this package’s config does not enable strict.

			> Likely an incorrect or invalid review comment.

tahini added 3 commits July 29, 2026 17:52
First part of chairemobilite#1552

This adds the name and geography widgets and tests for the
`_previousWorkPlace`. These widgets appear if the questionnaire
configuration supports inlining usual places, and the work on the road
previous place activity is 'workUsual', and no usual work place has been
defined for this respondent. In all other cases, those 2 widgets are
invisible.
Second part of chairemobilite#1552

This adds the previous work place geography widgets to the visitedPlaces
group when the `inlineUsualPlacesEntry` is `true`. The widgets are just not
added if it is not the case.
fixes chairemobilite#1552

Last step to the inlining of usual places. For work on the road
activities starting from the usual work place when the previous place is
not already work usual, this adds the name and geography to the place,
from the current place's previous work place data. Add test cases
with usual work place previous and next activities for workOnTheRoad.
@tahini

tahini commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed to work with od_mtl after adding the new widgets in the excel. Ready for review

@github-actions

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tahini
tahini merged commit d9bba94 into chairemobilite:main Jul 30, 2026
7 checks passed
@tahini
tahini deleted the fix1552 branch July 30, 2026 12:51
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.

tripDiary: Support entering work place from trip diary when activity is workOnTheRoad with departureType workUsual

2 participants