Major supplier refactor making the whole system work better

This commit is contained in:
2014-08-07 15:50:06 +02:00
parent e61767fe78
commit b4353113e1
40 changed files with 6614 additions and 4354 deletions
@@ -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