fix: MPS-24 Phase 2.8 — bulk tagger AJAX tag-focus + real drag-to-reorder
Operator (printableprompts.com, 481 products) reported the bulk tagger
'still refreshing the whole screen' and 'dragging tags doesn't work'
after 2.7. Two real defects the 2.7 static audit missed:
1. Tag-focus was a full-page navigation: clicking a tag chip is
<a href=?focus=slug>, and the view loaded+rendered ALL products on
EVERY GET. On a 481-product catalog every tag click reloaded a
multi-MB page. The forms were AJAX; the dominant workflow was not.
2. Drag-to-reorder never existed: shop_tags.j2 shipped draggable=true +
a handle + help text, but tag_bulk.js had ZERO drag handlers.
Fix:
- shop.py:shop_tags — all_products loads only when focus_tag or
show_suggestions (bare GET is light). New AJAX branch: is_ajax +
?focus=slug -> JSON {focus, products:[{id,title,url,attached}]}.
- shop_tags.j2 — stable [data-focus-section] (always in DOM, hidden
until focused); ?focus= chips carry data-tag-focus-link. No-JS
unchanged (real navigation, server renders the section).
- tag_bulk.js — wireFocusLinks() intercepts chip clicks, fetchFocus()
+ renderFocus() swap the list in place, active-chip + history
pushState/popstate, real-navigation fallback. wireDragAndDrop()
HTML5 DnD -> persistOrder() POSTs action=set_order&tag_slugs=…
(view already supported it) + re-syncs up/down disabled states.
.tag-list-dragging CSS added.
- Tests: TestProductTagsSpa +4 (ajax focus json, unknown-slug null,
set_order persists positions, bare GET no catalog). 1128 passed.
Docs: mps-24.md Phase 2.8, architecture.md, design-system.md, CLAUDE.md.
Deferred: AJAX 'Suggest categories' link (occasional click, not hot path).
This commit is contained in:
parent
f591620424
commit
155f7ff66f
9 changed files with 439 additions and 10 deletions
11
CLAUDE.md
11
CLAUDE.md
|
|
@ -474,7 +474,16 @@ Form section: `home-layout-settings` (`views/shop.py`,
|
|||
stopwords inputs.
|
||||
|
||||
Routes (registered before `shop_slug` catch-all):
|
||||
- `/s/{shop_id}/tags` — operator bulk tagger (`@shop_editor_required`)
|
||||
- `/s/{shop_id}/tags` — operator bulk tagger (`@shop_editor_required`).
|
||||
**Phase 2.8**: tag-focus is AJAX — `tag_bulk.js` intercepts a
|
||||
`[data-tag-focus-link]` chip click and fetches `?focus=<slug>` with
|
||||
`X-Requested-With`; the view returns JSON
|
||||
`{focus, products:[{id,title,url,attached}]}` and the JS swaps the
|
||||
`[data-focus-section]` list in place (no full reload — critical on
|
||||
large catalogs; the view only loads `all_products` when
|
||||
`focus_tag or show_suggestions`). Real HTML5 drag-to-reorder on the
|
||||
tag rows POSTs `action=set_order&tag_slugs=…`. No-JS unchanged: the
|
||||
`?focus=` link is a real navigation, server still renders the section.
|
||||
- `/s/{shop_id}/tag/{slug}` — public tag detail page (works without JS)
|
||||
|
||||
Tag input on product edit: comma-separated `tags` field on
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue