solidus icon indicating copy to clipboard operation
solidus copied to clipboard

[Admin][Settings][Shipments] Introduce shipping method creation and modification capability

Open JustShah opened this issue 8 months ago • 2 comments

Add Admin UI and Feature Specs for Shipping Methods

Solves: https://github.com/orgs/solidusio/projects/12/views/1?pane=issue&itemId=52590575

This PR implements a complete admin interface for managing Shipping Methods in Solidus Admin, along with feature specs and UI components.

Shipping Method Form Component

  • Built using ui/forms/field and ui/panel components.
  • Panels include:
    • Details: Name, admin name, code, carrier, service level, tracking URL.
    • Pricing: Calculator selection and preference fields.
    • Taxation: Tax category select.
    • Availability: Stores, zones, stock locations, availability toggles.
    • Organization: Shipping categories.
  • JavaScript interactivity:
    • Toggles preference fields based on selected calculator.
    • Shows/hides stock locations based on "Available to all" checkbox.

Calculator Support

  • Dropdown to select calculator type (e.g., Flat Rate, Per Item).
  • Dynamically renders preference fields based on calculator class.
  • Supports various field types:
    • Decimal (e.g., preferred_amount, preferred_flat_percent)
    • Integer
    • String
    • Currency

Controller Enhancements

  • ShippingMethodsController updated to:
    • Inherit from SolidusAdmin::ResourcesController
    • Handle assignment of shipping_categories and zones
    • Permit nested calculator_attributes and multiple select values like store_ids

UI Improvements

  • Index page:
    • Displays shipping methods
    • Includes edit links
  • New/Edit pages:
    • Form rendered via components
    • Locale support for all labels and UI copy

image image

JustShah avatar May 07 '25 06:05 JustShah

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 88.86%. Comparing base (f55384c) to head (b13304f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6232      +/-   ##
==========================================
+ Coverage   88.83%   88.86%   +0.02%     
==========================================
  Files         850      857       +7     
  Lines       18328    18359      +31     
==========================================
+ Hits        16281    16314      +33     
+ Misses       2047     2045       -2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 07 '25 07:05 codecov[bot]

While trying to save I got:

Unpermitted parameters: :store_ids, :zones. Context: { controller: SolidusAdmin::ShippingMethodsController, action: create, request: #<ActionDispatch::Request:0x000000032c6199d0>, params: {"authenticity_token"=>"[FILTERED]", "shipping_method"=>{"name"=>"Foo", "admin_name"=>"foo-bar", "code"=>"baz", "carrier"=>"UPS", "service_level"=>"123", "tracking_url"=>"foo.com/?track=:tracking", "calculator_type"=>"Spree::Calculator::Shipping::FlatPercentItemTotal", "calculator_attributes"=>{"preferred_flat_percent"=>"23"}, "tax_category_id"=>"1", "store_ids"=>"1", "zones"=>["1"], "available_to_all"=>"1", "available_to_users"=>"1"}, "controller"=>"solidus_admin/shipping_methods", "action"=>"create"} }

elia avatar May 23 '25 14:05 elia