make section table management with adding and positioning tables
This commit is contained in:
@@ -111,5 +111,32 @@ module Suppliers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# POST /sections/1/add_tables {number_start: 1423, number_end: 234234}
|
||||
def add_tables
|
||||
@section = Section.find_by_supplier_and_id(current_supplier, params[:id])
|
||||
number_start = params[:number_start].to_i
|
||||
number_end = params[:number_end].to_i
|
||||
for table_number in number_start..number_end
|
||||
next if table_number.zero?
|
||||
table = Table.new(number: table_number)
|
||||
table.supplier = current_supplier
|
||||
table.section = @section
|
||||
table.save
|
||||
end
|
||||
@section.arrange_tables_in_grid
|
||||
render json: {ok: true}
|
||||
end
|
||||
|
||||
# POST /sections/1/arrange_tables {number_start: 1423, number_end: 234234}
|
||||
def arrange_tables
|
||||
@section = Section.find_by_supplier_and_id(current_supplier, params[:id])
|
||||
case params[:option]
|
||||
when 'distribute' then @section.arrange_tables_in_grid
|
||||
when 'by_row' then @section.arrange_tables_in_rows_of(params[:row_count].to_i)
|
||||
when 'by_column' then @section.arrange_tables_in_columns_of(params[:column_count].to_i)
|
||||
end
|
||||
render json: {ok: true}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user