12 Added notes and colours to customers
This commit is contained in:
@@ -64,10 +64,15 @@ class CustomersController < ApplicationController
|
||||
).limit(10)
|
||||
|
||||
render json: @customers.map { |c|
|
||||
label = "#{c.full_name} (#{c.original_phone})"
|
||||
label += " - #{c.notes}" if c.notes.present?
|
||||
{
|
||||
id: "#{c.first_name}_#{c.surname}_#{c.original_phone}",
|
||||
label: "#{c.full_name} (#{c.original_phone})",
|
||||
birthyear: c.birthyear
|
||||
label: label,
|
||||
birthyear: c.birthyear,
|
||||
color: c.color || 'green',
|
||||
color_hex: c.color_hex,
|
||||
notes: c.notes
|
||||
}
|
||||
}
|
||||
end
|
||||
@@ -86,6 +91,6 @@ class CustomersController < ApplicationController
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def customer_params
|
||||
params.require(:customer).permit(:first_name, :surname, :phone, :notes, :email, :birthyear)
|
||||
params.require(:customer).permit(:first_name, :surname, :phone, :notes, :email, :birthyear, :color)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,7 +41,10 @@ class ReservationsController < ApplicationController
|
||||
# POST /reservations or /reservations.json
|
||||
def create
|
||||
@reservation = @company.reservations.new(
|
||||
reservation_params.except(:customer_id, :customer_birth_year)
|
||||
reservation_params.except(
|
||||
:customer_id, :customer_first_name, :customer_surname,
|
||||
:customer_original_phone, :customer_birth_year, :customer_composite_key
|
||||
)
|
||||
)
|
||||
|
||||
# Find or create customer based on submitted attributes
|
||||
@@ -68,7 +71,7 @@ class ReservationsController < ApplicationController
|
||||
customer_attrs = build_customer_attributes # Use existing helper
|
||||
reservation_attrs = reservation_params.except(
|
||||
:customer_id, :customer_first_name, :customer_surname,
|
||||
:customer_original_phone, :customer_birth_year
|
||||
:customer_original_phone, :customer_birth_year, :customer_composite_key
|
||||
)
|
||||
|
||||
# Find the customer identified by the submitted name/phone
|
||||
@@ -144,6 +147,7 @@ class ReservationsController < ApplicationController
|
||||
:customer_surname,
|
||||
:customer_original_phone,
|
||||
:customer_birth_year,
|
||||
:customer_composite_key,
|
||||
:customer_id # Allow this if select still sends it sometimes
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user