feat/category-only-edit #4

Merged
mtkell merged 2 commits from feat/category-only-edit into main 2026-04-11 19:56:49 +00:00
Owner

PR: feat/category-only-editmain

Objective

Stage 1B — Category-only product edit. Final slice of Stage 1 (controlled product editing). Adds the ability to update a product's category through the same narrow single-field edit pattern established by price, name, and description edits. No taxonomy subsystem introduced.

Inspection findings

Baseline main at cebac4c confirmed: four narrow edit capabilities landed (status, price, name, description). Each follows an identical vertical pattern — repository contract → use case → controller action/result → preview panel inline edit UI → snack bar feedback → tests. Category was the only remaining Stage 1 field. The existing ProductDraft.category field and copyWith(category:) were already present. No structural changes needed — only additive wiring through the established pattern.

Implementation

Followed the exact pattern from prior slices:

  1. Repository contract — added updateProductCategory(String id, String category) to ProductPublishingRepository
  2. Use case — created UpdateProductCategory (single-responsibility, delegates to repository)
  3. Fake repo — implemented updateProductCategory with copyWith + timestamp update
  4. WP repo — implemented updateProductCategory mapping category name to WooCommerce categories field via existing _resolveCategoryId helper
  5. Controller — added CategoryActionResult class, updateCategory() method, lastCategoryResult / consumeCategoryResult() (one-shot result pattern)
  6. Preview panel — replaced static _MetadataRow for Category with _buildCategoryRow (inline text field with save/cancel, edit icon gated on onCategoryChanged callback)
  7. Publishing page — wired UpdateProductCategory into controller constructor and onCategoryChanged into preview panel
  8. Snack bar — added showCategoryActionSnackBar for success/failure feedback
  9. Barrel export — added update_product_category.dart to feature_wordpress.dart
  10. Test mocks — updated dashboard_controller_test.dart and product_publishing_page_test.dart mocks for new repository method

Changed files

File Change
lib/src/domain/product_publishing_repository.dart Added updateProductCategory contract
lib/src/application/update_product_category.dart New use case (created)
lib/src/application/product_publishing_controller.dart CategoryActionResult, updateCategory, result handling
lib/src/data/fake_product_publishing_repository.dart Implemented updateProductCategory
lib/src/data/wordpress_product_publishing_repository.dart Implemented updateProductCategory (WP API)
lib/src/presentation/widgets/product_preview_panel.dart Inline category edit UI
lib/src/presentation/product_publishing_page.dart Wired use case + callback
lib/src/presentation/widgets/status_action_snack_bar.dart showCategoryActionSnackBar
lib/feature_wordpress.dart Barrel export
test/product_publishing_controller_test.dart 5 new updateCategory tests
test/fake_product_publishing_repository_test.dart 6 new updateProductCategory tests
test/widgets/product_publishing_page_test.dart Mock updated
apps/kell_web/test/.../dashboard_controller_test.dart Mock updated
docs/development/master_development_brief.md Updated baseline + next branch
docs/development/build_execution_tracker.md Slice record

Validation

Check Result
dart analyze No issues found
feature_wordpress tests 223/223 passed
kell_web dashboard tests 5/5 passed

Definition of done (per brief)

  • Category can be updated through a controlled workflow
  • No taxonomy subsystem added
  • Tests/analyze clean

Next slice

feat/post-write-consistency — Stage 2A: Post-write consistency hardening. Stage 1 is now complete; all single-field edit capabilities are landed.

## PR: `feat/category-only-edit` → `main` ### Objective Stage 1B — Category-only product edit. Final slice of Stage 1 (controlled product editing). Adds the ability to update a product's category through the same narrow single-field edit pattern established by price, name, and description edits. No taxonomy subsystem introduced. ### Inspection findings Baseline `main` at `cebac4c` confirmed: four narrow edit capabilities landed (status, price, name, description). Each follows an identical vertical pattern — repository contract → use case → controller action/result → preview panel inline edit UI → snack bar feedback → tests. Category was the only remaining Stage 1 field. The existing `ProductDraft.category` field and `copyWith(category:)` were already present. No structural changes needed — only additive wiring through the established pattern. ### Implementation Followed the exact pattern from prior slices: 1. **Repository contract** — added `updateProductCategory(String id, String category)` to `ProductPublishingRepository` 2. **Use case** — created `UpdateProductCategory` (single-responsibility, delegates to repository) 3. **Fake repo** — implemented `updateProductCategory` with `copyWith` + timestamp update 4. **WP repo** — implemented `updateProductCategory` mapping category name to WooCommerce `categories` field via existing `_resolveCategoryId` helper 5. **Controller** — added `CategoryActionResult` class, `updateCategory()` method, `lastCategoryResult` / `consumeCategoryResult()` (one-shot result pattern) 6. **Preview panel** — replaced static `_MetadataRow` for Category with `_buildCategoryRow` (inline text field with save/cancel, edit icon gated on `onCategoryChanged` callback) 7. **Publishing page** — wired `UpdateProductCategory` into controller constructor and `onCategoryChanged` into preview panel 8. **Snack bar** — added `showCategoryActionSnackBar` for success/failure feedback 9. **Barrel export** — added `update_product_category.dart` to `feature_wordpress.dart` 10. **Test mocks** — updated `dashboard_controller_test.dart` and `product_publishing_page_test.dart` mocks for new repository method ### Changed files | File | Change | |------|--------| | `lib/src/domain/product_publishing_repository.dart` | Added `updateProductCategory` contract | | `lib/src/application/update_product_category.dart` | New use case (created) | | `lib/src/application/product_publishing_controller.dart` | `CategoryActionResult`, `updateCategory`, result handling | | `lib/src/data/fake_product_publishing_repository.dart` | Implemented `updateProductCategory` | | `lib/src/data/wordpress_product_publishing_repository.dart` | Implemented `updateProductCategory` (WP API) | | `lib/src/presentation/widgets/product_preview_panel.dart` | Inline category edit UI | | `lib/src/presentation/product_publishing_page.dart` | Wired use case + callback | | `lib/src/presentation/widgets/status_action_snack_bar.dart` | `showCategoryActionSnackBar` | | `lib/feature_wordpress.dart` | Barrel export | | `test/product_publishing_controller_test.dart` | 5 new `updateCategory` tests | | `test/fake_product_publishing_repository_test.dart` | 6 new `updateProductCategory` tests | | `test/widgets/product_publishing_page_test.dart` | Mock updated | | `apps/kell_web/test/.../dashboard_controller_test.dart` | Mock updated | | `docs/development/master_development_brief.md` | Updated baseline + next branch | | `docs/development/build_execution_tracker.md` | Slice record | ### Validation | Check | Result | |-------|--------| | `dart analyze` | No issues found ✅ | | `feature_wordpress` tests | 223/223 passed ✅ | | `kell_web` dashboard tests | 5/5 passed ✅ | ### Definition of done (per brief) - ✅ Category can be updated through a controlled workflow - ✅ No taxonomy subsystem added - ✅ Tests/analyze clean ### Next slice **`feat/post-write-consistency`** — Stage 2A: Post-write consistency hardening. Stage 1 is now complete; all single-field edit capabilities are landed.
mtkell added 2 commits 2026-04-11 19:56:32 +00:00
mtkell merged commit 8e7e4cbc69 into main 2026-04-11 19:56:49 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mtkell/kell_creations#4
No description provided.