Skip to content

[6.x] Port the order index to the Inertia element index - #4387

Merged
nfourtythree merged 2 commits into
6.xfrom
feature/6x-port-order-index
Oct 14, 2026
Merged

nfourtythree merged 2 commits into
6.xfrom
feature/6x-port-order-index

Conversation

@nfourtythree

Copy link
Copy Markdown
Contributor

Description

The order index was still rendered from orders/_index.twig through the legacy element index bridge, so the custom behaviour in CommerceOrderIndex.js no longer ran. That meant no date range filter, no New order button, no status handle URLs, and actions with JS triggers (Update Order Status, Share cart, Download PDF) didn't work.

Orders now follow the same pattern as Products and Transfers. OrdersController::index renders commerce::orders/Index with a new OrderIndexViewModel, and the sources go in the secondary nav.

What the view model handles:

  • commerce/orders/{handle} URLs keep working for status and cart sources (via Order::sourceCpUri() and defaultSourceKey()), so existing links and bookmarks still land on the right source.
  • The site menu picks the store, as before. Orders aren't localized, so showSiteMenu() is overridden to show it on multi-site installs, and storeId is added in baseCriteria().
  • The date range filter (the legacy presets plus a custom From/To) applies to the source's date-attr and is kept in the URL and across source switches.
  • New order is only offered with commerce-editOrders.

Actions that need a settings step are swapped for window events in actions() and handled on the page:

  • Update Order Status opens a dialog (status, message, suppress emails).
  • Download PDF opens a popover anchored to the Actions button (PDF choice, collated or ZIP). The choice is hidden when the store has one PDF, and the download type when one order is selected.
  • Share cart opens the CP copy text prompt. It's now single-select, and get-load-cart-url accepts an id since the Vue bulk bar sends IDs rather than numbers.

Every action request now carries ?site=. Without it defineActions()/defineSources() resolve the current site's store, so actions on a non-primary store's cart sources can't find their source.

Other fixes this turned up:

  • The Vite build now uses relative URLs for chunk assets. The order page is the first lazily loaded page with its own CSS, and it was being preloaded from /build/ instead of Commerce's published path, which left the page blank.
  • DownloadOrderPdfAction::pdfFileName() crashed when a PDF has no file name format (ZIP and single order downloads). It now falls back to {handle}-{number}.
  • The {num, plural, =1{Order} other{Orders}} updated. translation had a lowercase value.

Removed: orders/_index.twig, the DownloadOrderPdf trigger template, CommerceOrderIndex.js, CommerceUpdateOrderStatusModal.js, DownloadOrderPdf.js (with the commercecp bundle rebuilt) and the actions' getTriggerHtml() methods.

Left out on purpose: source badge counts. They should be a native cms element index feature, so get-index-sources-badge-counts and badgeCount => 0 in defineSources() stay for now, and the index shows no counts until that lands.

Date bounds are passed in UTC to work around cms Query::whereDateParam() comparing local times against UTC-stored dates. That will be fixed separately in cms, and the workaround stays correct afterwards.

Covered by OrderIndexTest, and checked in the browser across sources, both stores, date presets and custom ranges, all three custom actions and export.

@nfourtythree nfourtythree self-assigned this Oct 13, 2026
@nfourtythree
nfourtythree marked this pull request as ready for review October 14, 2026 10:52
@nfourtythree
nfourtythree requested a review from a team as a code owner October 14, 2026 10:52
@nfourtythree
nfourtythree requested a balanced review from Copilot October 14, 2026 10:53

Copilot AI left a comment

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.

🟡 Changes recommended

The new UI permits costly no-op status updates and drops the Share cart prompt’s explanatory instructions.

3 open findings
What changed in this PR

Ports the order index to the Inertia element index while preserving store scoping, filtering, source URLs, and custom order actions.

Changes:

  • Adds the Inertia order index, view model, date filtering, and action dialogs.
  • Removes the legacy Twig and JavaScript order-index implementation.
  • Fixes asset URLs, PDF filenames, cart lookup by ID, and translation casing.
File Description
vite.config.mts Makes JavaScript-hosted asset URLs relative.
tests/​Feature/​Http/​Controllers/​OrderIndexTest.php Tests index sources, filtering, permissions, and actions.
src/​Order/​Elements/​Order.php Adds source-specific CP URLs.
src/​Order/​Actions/​UpdateOrderStatus.php Removes the legacy trigger UI.
src/​Order/​Actions/​DownloadOrderPdfAction.php Removes legacy UI and adds filename fallback.
src/​Order/​Actions/​CopyLoadCartUrl.php Makes cart sharing single-select.
src/​Http/​ViewModels/​OrderIndexViewModel.php Builds the Inertia index payload.
src/​Http/​Controllers/​OrdersController.php Renders Inertia and supports cart IDs.
src-yii2/​web/​assets/​commercecp/​src/​js/​DownloadOrderPdf.js Removes legacy PDF UI.
src-yii2/​web/​assets/​commercecp/​src/​js/​CommerceUpdateOrderStatusModal.js Removes legacy status modal.
src-yii2/​web/​assets/​commercecp/​src/​js/​CommerceOrderIndex.js Removes the legacy index implementation.
src-yii2/​web/​assets/​commercecp/​src/​commercecp.js Removes deleted module imports.
src-yii2/​web/​assets/​commercecp/​dist/​commercecp.js.map Rebuilds the legacy source map.
src-yii2/​web/​assets/​commercecp/​dist/​commercecp.js Rebuilds the legacy bundle.
src-yii2/​templates/​orders/​_index.twig Removes the legacy index template.
src-yii2/​templates/​_components/​elementactions/​DownloadOrderPdf/​trigger.twig Removes the legacy PDF trigger.
resources/​js/​window.d.ts Extends router and request typings.
resources/​js/​pages/​orders/​Index.vue Adds the Inertia order page.
resources/​js/​modules/​orders/​UpdateOrderStatusDialog.vue Adds the status-update dialog.
resources/​js/​modules/​orders/​OrderDateRangeMenu.vue Adds date-range controls.
resources/​js/​modules/​orders/​order-actions.ts Implements custom action requests.
resources/​js/​modules/​orders/​DownloadOrderPdfPopover.vue Adds PDF download options.
resources/​js/​cp.ts Registers the order page.
resources/​js/​cms-elements.d.ts Types index filter parameters.
lang/​en/​commerce.php Corrects translation capitalization.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread resources/js/modules/orders/UpdateOrderStatusDialog.vue
Comment thread resources/js/pages/orders/Index.vue
Comment thread src/Http/Controllers/OrdersController.php Outdated

Copilot AI left a comment

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.

🔵 Needs a closer look

Invalid calendar dates are normalized into unintended filter bounds rather than rejected.

0 open findings

3 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Reject invalid dates instead of normalizing custom range bounds

src/​Http/​ViewModels/​OrderIndexViewModel.php:402

createFromFormat() normalizes invalid calendar dates instead of rejecting them (for example, 2026-02-30 becomes 2026-03-02). A crafted custom-range URL therefore filters on and echoes a different date rather than ignoring the invalid bound. Validate the parsed value with an exact round trip before returning it.

🧠 Review effort: Balanced

@nfourtythree
nfourtythree merged commit 791c08c into 6.x Oct 14, 2026
6 of 7 checks passed
@nfourtythree
nfourtythree deleted the feature/6x-port-order-index branch October 14, 2026 11: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.

2 participants