mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-11-17 18:40:36 -05:00
Fix vehicle dropdown after a customer change; drop vehicles.js
The issue form already reloads on the server when the customer changes
(redmine_qbo's updateIssueFrom), re-rendering the vehicle list for the
new customer. 0a3c734 broke that by always keeping the issue's current
vehicle in the list, so after changing the customer the previous
customer's vehicle stayed listed and selected.
- The current vehicle is only kept for an existing issue whose customer
hasn't been changed in the form (keeps sold vehicles' history);
otherwise only the selected customer's vehicles are offered
- Removes vehicles.js, which duplicated the form reload, its include and
the JSON vehicle listing it used
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
4 files changed
+16
-58
No files matched your search
@@ -21,17 +21,13 @@ class VehiclesController < ApplicationController
|
||||
params.require(:vehicle).permit(:year, :make, :model, :customer_id, :notes, :vin)
|
||||
end
|
||||
|
||||
# Vehicles for one customer (also as JSON for the issue form), or search results
|
||||
# Vehicles for one customer, or search results
|
||||
def index
|
||||
if params[:customer_id].present?
|
||||
@customer = Customer.find_by(id: params[:customer_id])
|
||||
return render_404 unless @customer
|
||||
|
||||
vehicles = @customer.vehicles.order(:year, :make, :model)
|
||||
respond_to do |format|
|
||||
format.html { @vehicles = vehicles.paginate(page: params[:page]) }
|
||||
format.json { render json: vehicles.map { |v| { id: v.id, name: v.name } } }
|
||||
end
|
||||
@vehicles = @customer.vehicles.order(:year, :make, :model).paginate(page: params[:page])
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user