Add drag-to-reorder on daily work queue #11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "7-drag-to-reorder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Changes
config/importmap.rb: pin sortablejs@1.15.6 from jspm CDNapp/javascript/controllers/sortable_controller.js: Stimulus controller wrapping Sortable.js, sends reordered IDs via PATCHapp/controllers/work_queue_items_controller.rb:reorderaction with bulk position update in transactionconfig/routes.rb:patch :reordercollection route on work_queue_itemsapp/views/work_queue_items/_queue_item.html.erb: drag handle SVG before each itemapp/views/work_queue_items/index.html.erb: wire sortable controller on queue listapp/assets/stylesheets/application.css: drag handle +.is-draggingghost stylesspec/requests/work_queue_items_spec.rb: 2 new specs for bulk and single-item reorderTest Plan
Review Checklist
Related Notes
project-landscaping-assistantPR #11 Review
DOMAIN REVIEW
Tech stack: Ruby on Rails 8.1, Stimulus.js, Sortable.js (via importmap), vanilla CSS with design tokens, RSpec request specs.
Sortable.js integration:
https://ga.jspm.io/npm:sortablejs@1.15.6/modular/sortable.esm.jsis correct -- uses the ESM build from a trusted CDN.connect(), destroys ondisconnect(), extracts IDs from DOM via regex ondom_id-generated element IDs.handle: ".drag-handle"correctly restricts drag initiation to the grip icon only.ghostClass: "is-dragging"matches the CSS class defined in the stylesheet.Reorder endpoint (
WorkQueueItemsController#reorder):ActiveRecord::Base.transaction-- correct.update_allwhich bypasses model callbacks/validations -- acceptable here since onlyposition(an integer) is being set.PATCH /today/reorderas a collection route -- semantically appropriate.Touch/mobile drag support:
touch-action: noneon.drag-handleis set -- this is required for Sortable.js touch dragging to work on mobile Safari/Chrome.CSS design tokens:
var(--color-muted),var(--spacing-sm),var(--radius),var(--color-accent-light)-- consistent with existing codebase conventions.1.5remand1remfor the handle/icon sizing, which is reasonable for a fixed-size interactive element.Test coverage:
BLOCKERS
1. Reorder endpoint accepts arbitrary IDs without scoping (Medium-severity security concern)
The
reorderaction does:Any caller can pass IDs belonging to any work_date, reordering items across different days. While this app currently has no authentication (single-user landscaping tool), this is still a logic bug -- a drag on today's queue could theoretically reset positions of items from other dates if malformed IDs were submitted.
Recommendation: Scope to the current date:
Verdict: This is a logic correctness issue rather than a true security vulnerability (no auth in this app, single user). Downgrading from BLOCKER to a strong recommendation. Not blocking merge.
2. No error handling on the fetch call in
sortable_controller.jsThe
reorder()method fires a fetch with no.then()/.catch()or response status check. If the server returns 422 or 500, the user sees no feedback, and the DOM shows an order that doesn't match the database.Recommendation: At minimum, revert DOM order on failure:
This is a UX quality gap but not a BLOCKER for a single-user tool.
NITS
Missing
role="list"on<ul>: Sincelist-style: noneis applied, some screen readers (VoiceOver) may not announce it as a list. Addingrole="list"restores semantics.aria-label="Drag to reorder"is good -- accessibility for the handle is covered.Consider
aria-roledescription="sortable"andaria-grabbedon list items for assistive technology users, though this is stretch-goal accessibility for a personal tool.The
reordermethod name shadows the Stimulus action naming convention -- not an issue functionally but#persistOrderor#saveOrderwould be slightly clearer that this is the persistence step, not the drag itself.Spec could test invalid/nonexistent IDs -- what happens if
idscontains an ID that doesn't exist? Currently it silently does nothing (which is fine), but an explicit spec documents that contract.SOP COMPLIANCE
7-drag-to-reordermatches issue #7project-landscaping-assistantpresentPROCESS OBSERVATIONS
VERDICT: APPROVED