Move Assigned to Another Crew to bottom, remove Schedule section #222
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "move-other-crew-bottom-v2"
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
Supersedes PR #215.
Changes
weeks_controller.rb— addtoggle_assignaction with 4-state cycle, removemoveactionweeks/index.html.erb— remove Schedule accordion, keep upload button (flag-gated)week_assign_controller.js— handle other-crew state in pill toggleweek_move_controller.js— deleted (move action removed)application.css— add other-crew pill styles, remove Schedule grid stylestoday/index.html.erb— move other-crew section to bottomroutes.rb— remove move route, add toggle_assignTest Plan
Review Checklist
Related Notes
Supersedes #215. Closes #214
PR #222 Review
DOMAIN REVIEW
Stack: Ruby on Rails 7 (ERB views, Stimulus JS, Turbo Streams, CSS custom properties). This is a server-rendered Rails app with Hotwire for partial-page updates.
Architecture assessment: The 4-state pill cycle (empty -> assigned -> completed -> other-crew -> destroyed) is cleanly implemented. The Stimulus controller refactor from boolean flags (
wasAssigned,wasCompleted) to a#state(btn)helper that returns a string is a measurable improvement in readability and correctness. The extractedCHECK_SVGandOTHER_CREW_SVGconstants eliminate inline SVG duplication.Controller logic (weeks_controller.rb): The
toggle_assignaction correctly differentiatescompleted_by_other?-> destroy,completed?->mark_done_by_other!, unassigned ->toggle_completion!, and missing -> create. The state machine ordering matters and is correct.Model fitness:
WorkQueueItemhasmark_done_by_other!andtoggle_completion!(verified), andcompleted_by_otheris a boolean column so Rails auto-generates the?predicate. No model changes needed for the new states.CSS: Removed ~190 lines of dead
.week-grid-*and.week-move/.day-pickerstyles. The new.is-other-crewand.is-completed:hoverpill styles use design tokens (--color-warning,--color-danger) with hardcoded fallbacks (#f59e0b,#fef3c7). Fallbacks are acceptable as defensive defaults for the CSS custom property system.Schedule removal: Clean. The 70-line
<details>accordion, the@assigned/@unassignedpartition logic, and the@item_idshash are all removed together. No orphaned references remain.Move action removal:
week_move_controller.jsdeleted,moveroute removed fromroutes.rb,moveaction removed fromweeks_controller.rb, and allPATCH /weeks/movespecs removed. Clean teardown.BLOCKERS
1. Missing
@done_by_other_items_by_propertyinmark_otheraction -- will cause NoMethodErrorThe PR adds
done_by_other_items_by_property: @done_by_other_items_by_propertyto the_last_week_itemrender call inmark_other.turbo_stream.erb(line 10 in diff). However, themark_otheraction inwork_queue_items_controller.rbis NOT modified by this PR. It never sets@done_by_other_items_by_property.In Rails, unset instance variables evaluate to
nil. The_last_week_itempartial (post-PR) callsdone_by_other_items_by_property[item.property_id]-- invoking[]onnilraisesNoMethodError: undefined method '[]' for nil.Affected flow: User clicks "Assign to another crew" on a Last Week item -> Turbo Stream response renders
_last_week_itempartial -> crash.Fix: Add this to the
mark_otheraction, after existing@done_by_other_this_week_idsassignment:(This also consolidates the duplicate query into one, matching the pattern used in
create,destroy, andindex.)Similarly:
@queued_items_by_propertyis set inmark_other(line 177) but the PR also passesqueued_items_by_propertyto_last_week_iteminmark_other.turbo_stream.erb. This one IS set, so no crash. But confirmmark_other.turbo_stream.erbline 10 matches.2. Missing
@done_by_other_items_by_propertyinmark_otherfor_other_crew_section-- secondary crash pathThe
mark_other.turbo_stream.erbdiff also passesqueued_property_ids: @queued_property_ids, date: @dateto_other_crew_section(line 6). These ARE set in the controller. No issue here. But if future changes to_other_crew_sectionreferencedone_by_other_items_by_property, same pattern applies. Currently safe.NITS
Unused local in
_recent_sectionrenders: The PR passesdone_by_other_items_by_propertyto_recent_sectionincreate.turbo_stream.erbanddestroy.turbo_stream.erb, but the_recent_sectionpartial only usesdone_by_other_this_week_ids(a Set of property IDs), not the items-by-property hash. The extra local is harmless but misleading. Consider removing it from those render calls to keep the interface clean.DRY opportunity --
done_by_other_rowspattern: The two-step pattern (pluck rows, derive both Set and Hash) is now repeated in 4 controller locations:index,create,destroy, and the fix needed formark_other. Consider extracting a private helper:Render parameter lines are getting long. The
_last_week_itemrender calls now have 7 locals. This is approaching the point where a presenter object or alocals:hash variable would improve readability.Missing
@done_by_other_this_weekincreateTurbo Stream: The PR adds aturbo_stream.replace "done-by-other-section"block increate.turbo_stream.erbthat renders_other_crew_sectionwithdone_by_other_this_week: @done_by_other_this_week. Thecreateaction in the PR diff does set@done_by_other_this_week(added lines in the diff). Confirmed safe.SOP COMPLIANCE
.envfiles committedPROCESS OBSERVATIONS
completed_by_othercolumn)VERDICT: NOT APPROVED
One BLOCKER: the
mark_otheraction does not set@done_by_other_items_by_property, which will cause aNoMethodErrorwhen the "Assign to another crew" button is used on a Last Week item and the Turbo Stream response tries to render_last_week_item. Fix that controller action, and this is ready to merge.