Add Products Admin
|Assignee:||Pavan Rikhi||% Done:|
|Target version:||v0.9.0 - Admin|
Add, List, & Edit Products
Adding a product should show all product/attribute/variant fields in a single form, along with a "multiple variants" button, that splits out the product/attribute fields followed by multiple variant forms.
Same for editing a single variant product.
Do not allow deleting products or variants. Instead, add an "inactive" field that prevents them from being returned by the search/details/category routes.
Require that a Product has at least one variant.
Sanitize the descriptions and names!
[#1123] Add Admin API Routes for Creating Products
Add a newProductDataRoute for fetching the data needed to present the
New Product form as well as a newProductRoute for posting data to create
a new Product. Validation is done to ensure the slug & SKUs are unique
and that the specified Category exists.
[#1123] Refactor New Product Form
Extract the form specific parts of the New Product Page into a separate
set of Model, Msg, Update, & View types/functions. This will enable
re-use between the Add & Edit Product views.
Fix a bug where SeedAttributes would not be set if all attributes were
[#1123] Add API Routes for Editing Products
Add an editProductDataRoute for fetching the data necessary to show the
Edit Product Form, as well as an editProductRoute for posting the
updated data for a product.
Add ToJSON instances for the NewVariantData & NewSeedData types.
Add an option ProductVariantId field to the NewVariantData type for
updating existing variants of a product.
Extract the duplicate skuSuffix checking function from the
NewProductParameters's Validation instance into a separate function so
it can be re-used in Validation for the EditProductParameters type.
[#1123] Add Edit Product Page to the Admin Site
Add a new ProductEdit AdminRoute responsible for fetching a Product's
data, rendering & updating a Form, and posting the new data to the API
This admin page behaves differently than previous ones. On the other
pages, the Edit Form keeps track of the fields that have changed with
respect to the original data that was fetched when the page was loaded &
only submits the updated fields. To quicken development, we instead use
the product data as the basis for the form & submit all the product data
to the server instead of only the changed fields. This means the product
data gets stored in the ProductAdmin's EditForm model instead of the
PageData type on the global model, so some tweaking is required in the
Main module's fetchDataForRoute function so that the
model.editProductForm gets updated instead of the model.pageData field.
Add links to the edit page to the Admin's Products List page/table.
Redirect users to the product's edit page after they successfully create
a new product.
Modify the ProductAdmin.formView function so that the submit button's
text is passed in as an argument. Show an existing image in the form if
one is specified.