updates based on F5 testing
This commit is contained in:
@@ -4,11 +4,12 @@ module Suppliers
|
||||
@employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago)
|
||||
#@employee_shifts.include_relations(:employee, :supplier)
|
||||
# Only select shifts from currently linked and employees
|
||||
@employee_shifts.select! do |shift|
|
||||
return false unless current_supplier.employee_ids.include?(shift.employee.try(:id))
|
||||
shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
|
||||
true
|
||||
end
|
||||
#@employee_shifts.select! do |shift|
|
||||
# return false unless current_supplier.employee_ids.include?(shift.employee.try(:id))
|
||||
# shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
|
||||
# true
|
||||
#end
|
||||
#@employee_shifts.each { |shift| shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee)
|
||||
render json: @employee_shifts
|
||||
end
|
||||
def create
|
||||
|
||||
@@ -8,6 +8,7 @@ module Suppliers
|
||||
# GET /employees.json
|
||||
def index
|
||||
@employees = current_supplier.employees
|
||||
@employees.each { |employee| employee.enrich_with_settings current_supplier.settings_for(employee) }
|
||||
render json: @employees
|
||||
end
|
||||
|
||||
|
||||
@@ -15,8 +15,20 @@ module Users
|
||||
#EMBER
|
||||
def current
|
||||
@list = current_user.active_list
|
||||
params[:id] = @list.try(:id) # serializer determines collection or not based on the presence of this
|
||||
show
|
||||
render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id)
|
||||
include_config = %w[
|
||||
supplier
|
||||
supplier.product_categories
|
||||
supplier.product_categories.products
|
||||
supplier.product_categories.products.product_variants
|
||||
join_requests
|
||||
join_requests.user
|
||||
table
|
||||
orders
|
||||
orders.product_orders
|
||||
]
|
||||
include_config << 'users' if @list.user_ids.size > 1
|
||||
render json: @list, include: include_config, serializer: Users::ListSerializer, is_collection: false
|
||||
end
|
||||
|
||||
def table
|
||||
|
||||
@@ -4,10 +4,16 @@ module Users
|
||||
def show
|
||||
@supplier = Supplier.find(params[:id])
|
||||
render json: {}, status: :not_found and return unless @supplier.present?
|
||||
render json: @supplier, include: %w[
|
||||
product_categories
|
||||
product_categories.products
|
||||
product_categories.products.product_variants
|
||||
render json: @supplier
|
||||
end
|
||||
|
||||
def product_categories
|
||||
@supplier = Supplier.find(params[:id])
|
||||
render json: {}, status: :not_found and return unless @supplier.present?
|
||||
@supplier.product_categories.include_relations products: :product_variants
|
||||
render json: @supplier.product_categories, serializer: Users::ProductCategorySerializer, is_collection: true, include: %w[
|
||||
products
|
||||
products.product_variants
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,19 +3,19 @@ module Users
|
||||
respond_to :json
|
||||
def show
|
||||
@table = Table.find(params[:id])
|
||||
render json: JSONAPI::Serializer.serialize(@table, serializer: Users::TableSerializer)
|
||||
render json: @table, include: ['supplier']
|
||||
end
|
||||
|
||||
def supplier
|
||||
table = Table.find(params[:id])
|
||||
supplier = table.supplier
|
||||
supplier.product_categories.include_relations(products: :product_variants)
|
||||
render json: supplier, include: %w[
|
||||
product_categories
|
||||
product_categories.products
|
||||
product_categories.products.product_variants
|
||||
]
|
||||
end
|
||||
#def supplier
|
||||
# table = Table.find(params[:id])
|
||||
# supplier = table.supplier
|
||||
# supplier.product_categories.include_relations(products: :product_variants)
|
||||
# render json: supplier, include: %w[
|
||||
# product_categories
|
||||
# product_categories.products
|
||||
# product_categories.products.product_variants
|
||||
# ]
|
||||
#end
|
||||
|
||||
# POST /tables/:id/needs_help.json
|
||||
def needs_help
|
||||
@@ -67,6 +67,7 @@ module Users
|
||||
res = {}
|
||||
res[:active_list_present] = true if active_list.present?
|
||||
res[:occupied] = table.occupied?
|
||||
res[:active] = table.active?
|
||||
res[:reserved] = table.reserved?
|
||||
res[:supplier_closed] = table.supplier.closed?
|
||||
res[:no_product_orders] = true unless product_orders = new_order_product_orders.presence
|
||||
|
||||
@@ -32,7 +32,10 @@ class List
|
||||
add_user(user)
|
||||
user.save
|
||||
join_request_user_ids_will_change!
|
||||
save and broadcast_users 'join_request_approved', id: "jr-#{user.id}"
|
||||
if save
|
||||
broadcast_users 'join_request_approved', id: "jr-#{user.id}"
|
||||
broadcast_supplier supplier_id, 'user_joined_list', list_id: id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class Table
|
||||
property :needs_help, type: :boolean, default: false
|
||||
property :width, type: Float, default: 0.8
|
||||
property :height, type: Float, default: 0.8
|
||||
property :active, type: :boolean, default: true
|
||||
|
||||
belongs_to :supplier
|
||||
belongs_to :section
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Suppliers::TableSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id#, :active_list_id
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :active#, :active_list_id
|
||||
end
|
||||
|
||||
@@ -2,4 +2,5 @@ class Users::SupplierSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :open, :name, :orders_placed_count, :orders_in_process_count, :user_message
|
||||
has_many :product_categories, serializer: Users::ProductCategorySerializer
|
||||
related_link_for :product_categories
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class Users::TableSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied #, :supplier_id #, :alist_id
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :active #, :supplier_id #, :alist_id
|
||||
has_one :supplier, serializer: Users::SupplierSerializer
|
||||
|
||||
#def list_id
|
||||
#object.active_list_id || object.active_list.try(:id)
|
||||
#end
|
||||
|
||||
related_link_for :supplier
|
||||
#related_link_for :supplier
|
||||
#def list
|
||||
#object.active_list
|
||||
#end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Waiter::TableSerializer
|
||||
include Qwaiter::WaiterBaseSerializer
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help, :active
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user