Skip to content

fix(orders): keep the new order draft when a place is edited - #376

Merged
roncodes merged 1 commit into
release/v0.6.72from
fix/new-order-form-keeps-draft
Oct 9, 2026
Merged

roncodes merged 1 commit into
release/v0.6.72from
fix/new-order-form-keeps-draft

Conversation

@roncodes

@roncodes roncodes commented Oct 9, 2026

Copy link
Copy Markdown
Member

Fixes fleetbase/fleetbase#651. Supersedes #349.

On the new order form, saving a place from the pencil modal wiped every field already filled in. The same happened after creating a customer or facilitator from the header actions.

Root cause

  • OperationsOrdersIndexNewRoute.willTransition() called controller.reset() on every transition, including an in-place refresh of the route itself.
  • placeActions.modal.edit() saves with { refresh: true } by default. So once Fix editing unsaved geocoded places in order form #307 let the place save succeed, the follow-up router.refresh() reset the draft.

Changes

  • Route: reset the draft in resetController(controller, isExiting), and only when isExiting. This is Ember's hook for exactly this case: a refresh keeps the draft, and leaving the route still clears it. Unlike resetting in willTransition, it also doesn't wipe the draft when a transition away is aborted.
  • Order::Form::Route#editPlace: save with refresh: false. The place record is edited in place, so the form already shows the change. The callback re-runs the route preview and requests a new service quote, since the location may have moved.

Why not #349

  • Its willTransition() reads transition without declaring it as a parameter, so it would throw a ReferenceError on every transition out of the route.
  • It also copies place attributes onto waypoint records, which isn't needed: the waypoint points at the same place record that was edited.

Tests

  • New tests/unit/routes/operations/orders/index/new-test.js: refresh keeps the draft; exiting resets it. Passes.
  • New rendering test in tests/integration/components/order/form/route-test.js: editPlace saves with refresh: false, and the callback requests a quote refresh. Not yet run. Rendering tests in this file can't boot ember-intl in the local test browser, which also fails the file's three existing tests, and CI doesn't run Ember tests. Worth running ember test --filter "order/form/route" in Chrome before merging.

Resetting in willTransition wiped the draft on any transition, including
the refresh that follows saving a place, customer or facilitator from a
modal. Reset in resetController only when exiting, and edit places from
the route form without a refresh; re-preview the route and quote instead.

Fixes fleetbase/fleetbase#651
@roncodes
roncodes merged commit f9814d6 into release/v0.6.72 Oct 9, 2026
4 of 6 checks passed
@roncodes
roncodes deleted the fix/new-order-form-keeps-draft branch October 9, 2026 07:16
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.

1 participant