Major supplier refactor making the whole system work better
This commit is contained in:
@@ -4,22 +4,21 @@ module Suppliers
|
||||
# GET /sections
|
||||
# GET /sections.json
|
||||
def index
|
||||
# render json: {} and return
|
||||
@sections = current_supplier.sections
|
||||
@sections.include_relation(:tables)
|
||||
@active_lists = List.active_for_supplier(current_supplier.id)
|
||||
@active_table_ids = @active_lists.map(&:table_id).compact
|
||||
for section in @sections
|
||||
for table in section.tables
|
||||
if active_list = @active_lists.find{|l| l.table_id == table.id}
|
||||
table.active_list = active_list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @sections, each_serializer: SupplierExtendedSectionSerializer }
|
||||
end
|
||||
# @active_lists = List.active_for_supplier(current_supplier.id)
|
||||
# @active_table_ids = @active_lists.map(&:table_id).compact
|
||||
# for section in @sections
|
||||
# for table in section.tables
|
||||
# if active_list = @active_lists.find{|l| l.table_id == table.id}
|
||||
# table.active_list = active_list
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
render json: @sections, each_serializer: SupplierExtendedSectionSerializer
|
||||
end
|
||||
|
||||
# GET /sections/1
|
||||
|
||||
Reference in New Issue
Block a user