Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin stock locations form #6160

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

chaimann
Copy link
Contributor

@chaimann chaimann commented Feb 25, 2025

Summary

Adds a page with form for stock locations create/update, as well as updates stock locations table with links to go to edit page.

Updates "ui/forms/checkbox" component to contain common layout and logic reused between all checkboxes in admin forms, separating a "checkbox" component as a single element into its own component "ui/checkbox".

Adds helper methods .back, .discard and .save for UI button components

Adds missing tests for refund reasons, tax categories and product forms, where missing hidden input prevented booleans to be saved properly.

Page screenshot:
image

There are a few differences from the design card which I believe make sense to have:

  • "Name" and "Internal Name" are placed on the same row;
  • "Address" panel is a reused component "ui/forms/address", so the placement of the fields is different from the design;
  • there is no email column in stock_locations, and the "Phone" field is included in "ui/forms/address", so "Phone" field is not placed in its own section;
  • "Active" is a checkbox rather than select field, since it's a boolean;
  • texts for hints are copied from current backend; there is currently no hint for "Default" checkbox there so I haven't added any hint for "Set as default for all products";

Checklist

@chaimann chaimann force-pushed the admin-stock-locations-form branch from 2acc0de to 17d8f3d Compare February 26, 2025 14:01
@github-actions github-actions bot added the changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem label Feb 26, 2025
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.91%. Comparing base (cc2f7cb) to head (95992db).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6160      +/-   ##
==========================================
+ Coverage   88.81%   88.91%   +0.10%     
==========================================
  Files         835      839       +4     
  Lines       18153    18202      +49     
==========================================
+ Hits        16122    16184      +62     
+ Misses       2031     2018      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added changelog:solidus_core Changes to the solidus_core gem and removed changelog:solidus_core Changes to the solidus_core gem labels Feb 26, 2025
@chaimann chaimann force-pushed the admin-stock-locations-form branch from 2ee470c to 8c92d69 Compare February 28, 2025 10:50
@github-actions github-actions bot removed the changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem label Feb 28, 2025
@chaimann chaimann force-pushed the admin-stock-locations-form branch 3 times, most recently from 526a065 to 95992db Compare March 1, 2025 14:13
@chaimann chaimann marked this pull request as ready for review March 1, 2025 14:37
@chaimann chaimann requested a review from a team as a code owner March 1, 2025 14:37
chaimann added 12 commits March 14, 2025 19:13
As a common resource controller make it inherit from
ResourcesController.
Changes description:
 - introduced `@include_name_field` flag that controls whether to show
 "Name" field on the form;
 - renamed keyword `address` to `addressable` to better reflect that the
 nature of the passed object;
 - renamed keyword `name` to `fieldset_name` to avoid confusion with
 "Name" field, whereas `fieldset_name` is a name to be used for the form (e.g. "users[billing_address_attributes]");

Motivation:
This change allows to reuse this component in location stock form
component, where the only difference between forms is that "Name" field
is not there for location stock address.

Also, maybe it'll be sensible in the future to migrate stock location to
use a `stock_location_address` association and remove all the address
related fields from the `stock_location` table, but for now it's quite a
big task to be contained in current scope. So for now, just treat
`stock_location` as an `addressable` which can be used to render address
form component.
This is the first step to refactor checkbox component, so
 it can be used as a separate element or as a form
 control.
Motivation:
We have a couple of places throughout the admin where checkboxes
are used as part of a form, with all the same elements being reused
 to construct a checkbox field:
 - label with some caption;
 - hidden input field to support sending a "0" value in request;
 - optional toggletip hint;
Few places however lacked the hidden input, therefore the form was
not submitting the "0" value correctly.

This updated component builds a reusable form checkbox, that
encapsulates all the needed layout and logic for a form checkbox to
 be displayed and work properly, with an interface to customise it
 to each form needs.
@chaimann chaimann force-pushed the admin-stock-locations-form branch from 95992db to c0d25ea Compare March 14, 2025 18:13
@chaimann
Copy link
Contributor Author

test failure seems to be one of those intermittent

@chaimann
Copy link
Contributor Author

@kennyadsl @tvdeyen hey guys, you might have missed this one, can I get some eyes 👀 please?

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract the address component changes into a separate PR please? This change warrants more visibility in changelogs.

@chaimann chaimann marked this pull request as draft March 17, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants