diff --git a/assets/javascripts/application.js b/assets/javascripts/application.js index 9af1d96..1257c26 100644 --- a/assets/javascripts/application.js +++ b/assets/javascripts/application.js @@ -12,11 +12,12 @@ $(function() { data: { selected_customer: $("input#issue_customer_id").val() } }); - $("input#project_customers_id").on("change", function() { - $.ajax({ - url: "/filter_vehicles_by_customer", - type: "GET", - data: { selected_customer: $("input#project_customers_id").val() } - }); + $("input#project_customer_id").on("change", function() { + $.ajax({ + url: "/filter_vehicles_by_customer", + type: "GET", + data: { selected_customer: $("input#project_customer_id").val() } + }); + }); }); }); diff --git a/config/locales/en.yml b/config/locales/en.yml index 48d40a0..df9763a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -17,6 +17,7 @@ en: field_qbo_invoice: "Invoice" field_qbo_estimate: "Estimate" field_vehicles: "Vehicle" + field_vehicle: "Vehicle" field_vin: "VIN" field_notes: "Notes" field_qbo_billed: "Billed" diff --git a/lib/projects_form_hook_listener.rb b/lib/projects_form_hook_listener.rb index f1a66f1..834c7b5 100644 --- a/lib/projects_form_hook_listener.rb +++ b/lib/projects_form_hook_listener.rb @@ -15,21 +15,21 @@ class ProjectsFormHookListener < Redmine::Hook::ViewListener f = context[:form] # Check to see if there is a quickbooks user attached to the issue - selected_customer = context[:project].customers_id ? context[:project].customers_id : nil - selected_vehicle = context[:project].vehicles_id ? context[:project].vehicles_id : nil + selected_customer = context[:project].customer ? context[:project].customer : nil + selected_vehicle = context[:project].vehicle_id ? context[:project].vehicle_id : nil # Load customer information customer = Customer.find_by_id(selected_customer) if selected_customer - search_customer = f.autocomplete_field :customers_id, autocomplete_customer_name_customers_path, :selected => selected_customer, :update_elements => {:id => '#project_customer_id', :value => '#project_customer'} - customer_id = f.hidden_field :customers_id, :id => "project_customer_id" + search_customer = f.autocomplete_field :customer, autocomplete_customer_name_customers_path, :selected => selected_customer, :update_elements => {:id => '#project_customer_id', :value => '#project_customer'} + customer_id = f.hidden_field :customer_id, :id => "project_customer_id" - if context[:project].customers_id + if context[:project].customer vehicles = customer.vehicles.pluck(:name, :id).sort! else vehicles = [nil].compact end - vehicle = f.select :vehicles_id, vehicles, :selected => selected_vehicle, include_blank: true + vehicle = f.select :vehicle_id, vehicles, :selected => selected_vehicle, include_blank: true return "

#{search_customer} #{customer_id}

#{vehicle}

" end