Day detail page: DayExclusion model and remove-from-list button #236

Closed
opened 2026-06-16 03:32:24 +00:00 by ldraney · 1 comment
Owner

Type

Feature

Lineage

Decomposed from #233 (3 of 4). Depends on #235 ("Previously" accordion must exist to have a remove button).

Repo

ldraney/landscaping-assistant

User Story

As a crew lead or admin
I want to remove a property from the "Previously Tuesdays" list
So that properties we no longer service on that day stop cluttering the planning view

Context

The "Previously [Day]s" accordion (#235) shows all properties historically assigned on a weekday. Some properties may no longer be relevant (e.g., a client moved, service changed to a different day). Users need a way to exclude a property from the recurring list for a specific weekday without deleting historical data.

This introduces a DayExclusion model -- a lightweight join table that records "property X is excluded from the Previously list for weekday Y." The "Previously" query filters out excluded properties.

File Targets

Files to create:

  • db/migrate/XXXXXX_create_day_exclusions.rb -- migration for day_exclusions table
  • app/models/day_exclusion.rb -- model with validations
  • app/views/days/_previously_item.html.erb -- extract item partial with remove button (if not already extracted in #235)

Files to modify:

  • app/controllers/days_controller.rb -- add exclude action (POST), update @previously query to filter out excluded properties
  • config/routes.rb -- add post "/days/:date/exclude", to: "days#exclude", as: :day_exclude
  • app/views/days/_previously_section.html.erb -- add remove button per item
  • spec/requests/days_spec.rb -- add specs for exclusion

Schema: day_exclusions

| Column      | Type    | Constraints                          |
|-------------|---------|--------------------------------------|
| id          | bigint  | PK                                   |
| property_id | bigint  | FK to properties, NOT NULL            |
| wday        | integer | 0-6 (Sunday=0 per Ruby), NOT NULL    |
| created_at  | datetime| NOT NULL                             |
| updated_at  | datetime| NOT NULL                             |
  • Unique index on [property_id, wday]
  • belongs_to :property

Feature Flag

Flag: none
Additive behavior on the new day detail page.

Acceptance Criteria

  • Clicking "remove" on a property in the "Previously Tuesdays" list creates a DayExclusion record for that property + wday
  • The excluded property no longer appears in "Previously Tuesdays" on subsequent page loads
  • The exclusion is weekday-specific -- excluding from Tuesday doesn't affect Wednesday
  • Turbo stream response removes the item from the list without full page reload
  • Duplicate exclusion attempts are idempotent (no error, no duplicate record)

Test Expectations

  • Model spec: DayExclusion validates presence of property_id and wday
  • Model spec: DayExclusion enforces uniqueness on [property_id, wday]
  • Request spec: POST /days/:date/exclude with property_id creates exclusion and returns turbo stream
  • Request spec: excluded property no longer appears in the "Previously" section
  • Request spec: exclusion on Tuesday doesn't affect Wednesday's list
  • Run command: bundle exec rspec spec/requests/days_spec.rb spec/models/day_exclusion_spec.rb

Constraints

  • Use Turbo Stream for the remove action -- follow the pattern in work_queue_items/destroy.turbo_stream.erb
  • wday uses Ruby's Date#wday convention: Sunday=0, Monday=1, ..., Saturday=6
  • No "undo" in this ticket -- re-adding excluded properties comes via the picker in #237

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • project-landscaping-assistant
  • Parent: #233 (decomposed)
  • Depends on: #235 ("Previously" accordion)
### Type Feature ### Lineage Decomposed from #233 (3 of 4). Depends on #235 ("Previously" accordion must exist to have a remove button). ### Repo `ldraney/landscaping-assistant` ### User Story As a crew lead or admin I want to remove a property from the "Previously Tuesdays" list So that properties we no longer service on that day stop cluttering the planning view ### Context The "Previously [Day]s" accordion (#235) shows all properties historically assigned on a weekday. Some properties may no longer be relevant (e.g., a client moved, service changed to a different day). Users need a way to exclude a property from the recurring list for a specific weekday without deleting historical data. This introduces a `DayExclusion` model -- a lightweight join table that records "property X is excluded from the Previously list for weekday Y." The "Previously" query filters out excluded properties. ### File Targets Files to create: - `db/migrate/XXXXXX_create_day_exclusions.rb` -- migration for `day_exclusions` table - `app/models/day_exclusion.rb` -- model with validations - `app/views/days/_previously_item.html.erb` -- extract item partial with remove button (if not already extracted in #235) Files to modify: - `app/controllers/days_controller.rb` -- add `exclude` action (POST), update `@previously` query to filter out excluded properties - `config/routes.rb` -- add `post "/days/:date/exclude", to: "days#exclude", as: :day_exclude` - `app/views/days/_previously_section.html.erb` -- add remove button per item - `spec/requests/days_spec.rb` -- add specs for exclusion ### Schema: `day_exclusions` ``` | Column | Type | Constraints | |-------------|---------|--------------------------------------| | id | bigint | PK | | property_id | bigint | FK to properties, NOT NULL | | wday | integer | 0-6 (Sunday=0 per Ruby), NOT NULL | | created_at | datetime| NOT NULL | | updated_at | datetime| NOT NULL | ``` - Unique index on `[property_id, wday]` - `belongs_to :property` ### Feature Flag Flag: none Additive behavior on the new day detail page. ### Acceptance Criteria - [ ] Clicking "remove" on a property in the "Previously Tuesdays" list creates a `DayExclusion` record for that property + wday - [ ] The excluded property no longer appears in "Previously Tuesdays" on subsequent page loads - [ ] The exclusion is weekday-specific -- excluding from Tuesday doesn't affect Wednesday - [ ] Turbo stream response removes the item from the list without full page reload - [ ] Duplicate exclusion attempts are idempotent (no error, no duplicate record) ### Test Expectations - [ ] Model spec: DayExclusion validates presence of property_id and wday - [ ] Model spec: DayExclusion enforces uniqueness on [property_id, wday] - [ ] Request spec: POST `/days/:date/exclude` with property_id creates exclusion and returns turbo stream - [ ] Request spec: excluded property no longer appears in the "Previously" section - [ ] Request spec: exclusion on Tuesday doesn't affect Wednesday's list - [ ] Run command: `bundle exec rspec spec/requests/days_spec.rb spec/models/day_exclusion_spec.rb` ### Constraints - Use Turbo Stream for the remove action -- follow the pattern in `work_queue_items/destroy.turbo_stream.erb` - `wday` uses Ruby's `Date#wday` convention: Sunday=0, Monday=1, ..., Saturday=6 - No "undo" in this ticket -- re-adding excluded properties comes via the picker in #237 ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `project-landscaping-assistant` - Parent: #233 (decomposed) - Depends on: #235 ("Previously" accordion)
Author
Owner

Scope Review: READY

Review note: review-1474-2026-06-15
Ticket is well-scoped with complete template, verified traceability, accurate file targets, and testable acceptance criteria. Dependencies (#234, #235) are correctly documented and must land first. Execution order: #234 -> #235 -> #236 -> #237.

One systemic note (not blocking):

  • [SCOPE] No arch-rails-app architecture note exists in pal-e-docs (affects all rails-app board items, not just this one)
## Scope Review: READY Review note: `review-1474-2026-06-15` Ticket is well-scoped with complete template, verified traceability, accurate file targets, and testable acceptance criteria. Dependencies (#234, #235) are correctly documented and must land first. Execution order: #234 -> #235 -> #236 -> #237. One systemic note (not blocking): - [SCOPE] No `arch-rails-app` architecture note exists in pal-e-docs (affects all rails-app board items, not just this one)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
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
ldraney/landscaping-assistant#236
No description provided.