End of train commit
This commit is contained in:
@@ -142,11 +142,23 @@ module Suppliers
|
||||
# POST /sections/1/arrange_tables {number_start: 1423, number_end: 234234}
|
||||
def arrange_tables
|
||||
@section = Section.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
case params[:option]
|
||||
when 'distributed' then render(json: (@section.arrange_tables_in_grid ? {ok: true} : json_alert('messages.could_not_arrange_tables_distributed')))
|
||||
when 'by_row' then render(json: (@section.arrange_tables_in_rows_of(params[:row_count].to_i) ? {ok: true} : json_alert('messages.could_not_arrange_tables_by_row')))
|
||||
when 'by_column' then render(json: (@section.arrange_tables_in_columns_of(params[:column_count].to_i) ? {ok: true} : json_alert('messages.could_not_arrange_tables_by_column')))
|
||||
else render(json: json_alert('messages.could_not_arrange_tables'))
|
||||
#TODO handle messages client side
|
||||
#json_alert('messages.could_not_arrange_tables_distributed')
|
||||
#json_alert('messages.could_not_arrange_tables_by_row')
|
||||
#json_alert('messages.could_not_arrange_tables_by_column')))
|
||||
#json_alert('messages.could_not_arrange_tables')
|
||||
success = case params[:option]
|
||||
when 'distributed' 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)
|
||||
else false
|
||||
end
|
||||
|
||||
if success
|
||||
table_json = ActiveModel::ArraySerializer.new(@section.tables, each_serializer: SupplierTableSerializer, root: false).as_json
|
||||
render json: {tables: table_json}
|
||||
else
|
||||
render json: {}, status: 500
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user