Hide fully-cartoned shipments on the admin order page (#3357)#6463
Draft
luwiee wants to merge 1 commit intosolidusio:mainfrom
Draft
Hide fully-cartoned shipments on the admin order page (#3357)#6463luwiee wants to merge 1 commit intosolidusio:mainfrom
luwiee wants to merge 1 commit intosolidusio:mainfrom
Conversation
Cartons and Shipments both render a "Shipped package from 'X'" legend on the admin order edit page. When all of a shipment's inventory units have been moved into a Carton (i.e., the shipment is fully shipped), both partials render against the same data, producing a duplicate row that confuses admins (solidusio#3357). The Shipment partial already filters its manifest items to inventory units with `carton_id IS NULL`. When that filter returns an empty list, the partial has nothing meaningful to show: there is no "Ship" action to expose, no items to display, and no tracking — the authoritative shipped state lives on the Carton. Skip rendering the partial entirely in that case. The Carton partial remains the single source of truth for fully shipped packages, and in-progress shipments (with any non-cartoned inventory units) render unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #3357.
The admin order edit page renders a "Shipped package from 'X'" legend twice for fully-shipped orders: once from the
Cartonpartial and once from theShipmentpartial that the carton was created from. The reporter's screenshot shows the visual confusion this causes — admins see two rows that look like distinct packages but represent the same items.Approach
The
Shipmentpartial already filters its manifest to inventory units withcarton_id IS NULL. When that filter returns an empty list (i.e., every inventory unit has been moved into a Carton), the partial has nothing meaningful left to show:So this PR skips rendering the
Shipmentpartial entirely in that case. TheCartonpartial remains the single source of truth for fully-shipped packages, and in-progress shipments (with any non-cartoned units) render unchanged.Test
Added a non-JS feature spec:
Verified the spec fails on
mainwith the exact symptom reported in #3357 ("H... - Shipped package from 'NY Warehouse'" matching[data-hook='admin_shipment_form']) and passes with the fix applied. Existing shipment specs continue to pass.Trade-offs / alternatives considered
_form.html.erb) instead of inside the partial — rejected because it would either trigger N+1 (shipments.select { |s| s.inventory_units.where(carton_id: nil).any? }) or push a more complex SQL filter into the view. Skipping render at the partial boundary keeps the change local and avoids any query restructuring.Out of scope