Restore quick-add new property from Today tab #105
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-quick-add-from-today-tab"
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
client_nameparam — this wires the UI back upChanges
app/views/work_queue_items/index.html.erb— Add hiddenclient_namefield and Stimulus targets to the picker form, addkeydownaction bindingapp/javascript/controllers/property_picker_controller.js— Addsubmit()Enter handler that sendsclient_nameinstead ofproperty_id, add form/field targets to replacequerySelectorcallsspec/requests/work_queue_items_spec.rb— Add request spec covering the quick-add turbo stream path (20 examples, 0 failures)Test Plan
docker compose run --rm -e RAILS_ENV=test web bundle exec rspec— 20 examples, 0 failureshttps://landscaping-dev.tail5b443a.ts.net/today— typed "New Test Client", pressed Enter, property created + queued + appeared in Recent with "Queued" badgeReview Checklist
Related Notes
None.
Related
Closes #98
PR #105 Review
DOMAIN REVIEW
Stack: Rails 8.1 / Hotwired (Stimulus + Turbo Streams) / RSpec request specs
Stimulus controller (
property_picker_controller.js)The
submit()method is well-structured:event.key !== "Enter"before doing anything -- correct.event.preventDefault()stops the default form submission or newline -- correct.propertyIdTargetbefore settingclientNameTargetso the two params are mutually exclusive -- good.{ once: true }turbo:submit-end listener -- correct pattern.querySelectorcalls to Stimulus targets (formTarget,propertyIdTarget) in theselect()method is a clean improvement that reduces fragile DOM queries.No issues found in the JS.
View (
index.html.erb)client_namefield is properly wired with thedata-property-picker-target="clientName"attribute.keydown->property-picker#submitaction binding on the input is correct.formtarget on theform_withtag is correct.No issues found in the view.
Controller (
work_queue_items_controller.rb, not in the diff but reviewed for context)Property.create!withclient_name: params[:client_name]uses bang create, so a validation failure (blank name) raisesActiveRecord::RecordInvalid. ThePropertymodel hasvalidates :client_name, presence: true, which catches blank/nil. However,create!will raise an unrescued exception rather than returning a user-friendly turbo stream error. The JSsubmit()method trims and checks for empty before sending, so in practice this path should not be hit from the UI, but a direct POST withclient_name: ""would 500. This is a pre-existing pattern in the controller (not introduced by this PR) and the JS front-gates it, so I am noting it as a nit rather than a blocker.params[:client_name]goes through Rails strong-ish parameter handling. Sinceclient_nameis a simple string attribute with a presence validation, SQL injection risk is mitigated by ActiveRecord parameterized queries. No raw SQL is involved. Acceptable.Request spec (
work_queue_items_spec.rb)prependaction. This confirms the@new_propertybranch in the turbo stream template works..change(Property, :count).by(1)and.change(WorkQueueItem, :count).by(1)-- good compound assertion.BLOCKERS
None found.
client_nameis validated byvalidates :client_name, presence: trueon the model. The JS trims whitespace and rejects empty strings before submitting. No unvalidated user input reaches the database.NITS
Branch naming: Branch is
fix-quick-add-from-today-tabbut SOP convention is{issue-number}-{kebab-case-purpose}. Should be98-restore-quick-add-from-today-tabor similar. This is a process nit; the PR body correctly referencesCloses #98.Unrescued
create!on blankclient_name: If someone POSTs directly withclient_name: " "(whitespace only),Property.create!will raiseActiveRecord::RecordInvalidand return a 500. The JS front-gates this, so it is not reachable from the UI, but switching tocreate(no bang) with an error branch would be more defensive. Pre-existing pattern, not introduced by this PR.Missing edge case test -- blank
client_name: A test likepost "/today", params: { client_name: "", date: Date.current.to_s }to confirm the server handles it gracefully (even if it currently 500s) would document the expected behavior. Low priority since the JS prevents this path.Missing edge case test -- duplicate
client_name: There is no uniqueness constraint onclient_namein the schema or model. A user could type "Test" and create a second property with the same name. This may be intentional (same client, different property), but a test documenting this behavior would be useful.Related Notessection is empty: PR body hasRelated Notes: None.-- the SOP asks for a plan slug reference in the Related section. TheRelatedsection does referenceCloses #98which is correct, but there is no plan slug. Minor if no plan exists for this work.SOP COMPLIANCE
fix-quick-add-from-today-tab, missing98-prefix per conventionCloses #98is present but no plan slug referencedPROCESS OBSERVATIONS
querySelectorto Stimulus targets inselect()is the only modification to existing behavior, and it is a mechanical improvement with identical semantics.VERDICT: APPROVED
The code is clean, well-scoped, and tested. The branch naming and missing plan slug are process nits that do not affect code quality or correctness. No blockers found.