feat(time): prefill work-item from ?ticket_id on Log Time (PMS-362) #253

Merged
nrupard merged 1 commit from feat/pms-362-log-time-ticket-prefill into main 2026-06-17 16:57:28 +02:00
Owner

What

Closes AC2 of PMS-362. The "Add Contact from Company" prefill (AC1) was already shipped and works on main; this finishes the deep-link sweep by fixing the one remaining gap the audit found: Add Time Entry from Ticket.

The gap

The ticket-detail "Log Time" button was a routed Link { to: Route::TimeEntryNew {} } carrying no ticket_id, and TimeEntryNewPage read no URL params - so it opened an empty work-item picker and the user had to re-find the ticket they just clicked from.

Fix

  • tickets.rs: switch the Log Time affordance to a plain <a href="/time/new?ticket_id={id}">. A Link would strip the query (the TimeEntryNew route declares no query params); the router still intercepts the same-origin anchor for SPA nav. Mirrors the Add Contact / New Ticket prefill links.
  • time.rs: TimeEntryNewPage reads ticket_id from window.location.search on mount (read_ticket_prefill_from_url) and seeds the work_item signal to ticket:<uuid>, so the picker opens preselected and submit resolves the ticket's company_id as usual. Direct navigation (no params) still opens an empty picker - no regression (AC3).
Link Consumer-side read
Add Contact from Company <a> + ContactNewPage reads location.search (shipped)
Add Ticket from Company <a> + New Ticket reads read_company_prefill_from_url (MAPPS-207)
Add Time Entry from Ticket <a> + TimeEntryNewPage reads read_ticket_prefill_from_url (this PR)
Add Site from Company N/A - inline modal, no route/deep-link
Add Asset from Company/Contact N/A - no such deep link exists

Verification

wasm cargo check, cargo clippy --target wasm32-unknown-unknown --lib -- -D warnings, and cargo fmt --all --check all pass.

#PMS-362

## What Closes AC2 of PMS-362. The "Add Contact from Company" prefill (AC1) was already shipped and works on main; this finishes the deep-link sweep by fixing the one remaining gap the audit found: **Add Time Entry from Ticket**. ## The gap The ticket-detail "Log Time" button was a routed `Link { to: Route::TimeEntryNew {} }` carrying no `ticket_id`, and `TimeEntryNewPage` read no URL params - so it opened an empty work-item picker and the user had to re-find the ticket they just clicked from. ## Fix - `tickets.rs`: switch the Log Time affordance to a plain `<a href="/time/new?ticket_id={id}">`. A `Link` would strip the query (the `TimeEntryNew` route declares no query params); the router still intercepts the same-origin anchor for SPA nav. Mirrors the Add Contact / New Ticket prefill links. - `time.rs`: `TimeEntryNewPage` reads `ticket_id` from `window.location.search` on mount (`read_ticket_prefill_from_url`) and seeds the `work_item` signal to `ticket:<uuid>`, so the picker opens preselected and submit resolves the ticket's `company_id` as usual. Direct navigation (no params) still opens an empty picker - no regression (AC3). ## AC2 audit (every "Add X from Y" deep link + its consumer read) | Link | Consumer-side read | | --- | --- | | Add Contact from Company | `<a>` + `ContactNewPage` reads `location.search` (shipped) | | Add Ticket from Company | `<a>` + New Ticket reads `read_company_prefill_from_url` (MAPPS-207) | | **Add Time Entry from Ticket** | `<a>` + `TimeEntryNewPage` reads `read_ticket_prefill_from_url` (this PR) | | Add Site from Company | N/A - inline modal, no route/deep-link | | Add Asset from Company/Contact | N/A - no such deep link exists | ## Verification wasm `cargo check`, `cargo clippy --target wasm32-unknown-unknown --lib -- -D warnings`, and `cargo fmt --all --check` all pass. #PMS-362
feat(time): prefill work-item from ?ticket_id on Log Time (PMS-362 AC2)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m53s
Create release / Create release from merged PR (pull_request) Has been skipped
e52924c39f
The ticket-detail "Log Time" button navigated to /time/new with no context, so the work-item picker opened empty and the user had to re-find the ticket they just clicked from - the same deep-link-drops-context bug PMS-362 fixed for Add Contact, on the flow AC2 names ("Add Time Entry from Ticket").

- tickets.rs: switch the Log Time affordance from a routed Link to a plain <a href="/time/new?ticket_id={id}">. A Link would strip the query (the TimeEntryNew route declares no query params); the router still intercepts the same-origin anchor for SPA nav. Mirrors the Add Contact / New Ticket prefill links.
- time.rs: TimeEntryNewPage reads ticket_id from window.location.search on mount (read_ticket_prefill_from_url) and seeds the work_item signal to `ticket:<uuid>`, so the picker opens with that ticket selected and submit resolves its company_id as usual. Direct navigation (no params) still opens an empty picker - no regression.

This closes AC2: every "Add X from Y" deep link now round-trips its parent. Audit: Add Contact from Company (anchor + location.search, already shipped), Add Ticket from Company (MAPPS-207), Add Time Entry from Ticket (this change). Add Site from Company is an inline modal (no route), and there is no Add-Asset-from-company/contact deep link, so neither needs a consumer read.

#PMS-362
nrupard deleted branch feat/pms-362-log-time-ticket-prefill 2026-06-17 16:57:29 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!253
No description provided.