End of evening commit, changing supplier to JSONAPI
This commit is contained in:
@@ -6,10 +6,7 @@ module Suppliers
|
||||
@tables = Table.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25, from_number: params[:from_number], to_number: params[:to_number])
|
||||
@tables.include_relation(:section)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @tables }
|
||||
end
|
||||
render json: @tables
|
||||
end
|
||||
|
||||
# GET /tables/1
|
||||
@@ -17,10 +14,7 @@ module Suppliers
|
||||
def show
|
||||
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @table }
|
||||
end
|
||||
render json: @table
|
||||
end
|
||||
|
||||
# GET /tables/new
|
||||
@@ -29,10 +23,7 @@ module Suppliers
|
||||
@table = Table.new
|
||||
@table.section_id = params[:section_id].presence
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @table }
|
||||
end
|
||||
render json: @table
|
||||
end
|
||||
|
||||
# GET /tables/1/edit
|
||||
@@ -46,14 +37,10 @@ module Suppliers
|
||||
@table = Table.new(table_params)
|
||||
@table.supplier = current_supplier
|
||||
|
||||
respond_to do |format|
|
||||
if @table.save
|
||||
format.html { redirect_to [:suppliers, @table.section || @table], notice: t('action.create.successfull', model: Table.model_name.human) }
|
||||
format.json { render json: @table, status: :created }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: {errors: @table.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
if @table.save
|
||||
render json: @table, status: :created
|
||||
else
|
||||
render json: {errors: @table.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,14 +49,10 @@ module Suppliers
|
||||
def update
|
||||
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @table.update_attributes(table_params)
|
||||
format.html { redirect_to [:suppliers, @table.section || @table], notice: t('action.update.successfull', model: Table.model_name.human) }
|
||||
format.json { render json: @table }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: {errors: @table.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
if @table.update_attributes(table_params)
|
||||
render json: @table
|
||||
else
|
||||
render json: {errors: @table.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,10 +62,7 @@ module Suppliers
|
||||
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@table.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to suppliers_tables_url, notice: t('action.destroy.successfull', model: Table.model_name.human) }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
head :ok
|
||||
end
|
||||
|
||||
def qr_codes
|
||||
|
||||
Reference in New Issue
Block a user