83 lines
2.6 KiB
Ruby
83 lines
2.6 KiB
Ruby
class Settings::TablesController < ApplicationController
|
|
before_action :set_settings_table, only: [:show, :edit, :update, :destroy]
|
|
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create]
|
|
# GET /settings/tables
|
|
# GET /settings/tables.json
|
|
def index
|
|
@settings_tables = @zone.tables
|
|
end
|
|
|
|
# GET /settings/tables/1
|
|
# GET /settings/tables/1.json
|
|
def show
|
|
@table = Table.find(params[:id])
|
|
end
|
|
|
|
# GET /settings/tables/new
|
|
def new
|
|
@settings_table = Table.new
|
|
end
|
|
|
|
# GET /settings/tables/1/edit
|
|
def edit
|
|
end
|
|
|
|
# POST /settings/tables
|
|
# POST /settings/tables.json
|
|
def create
|
|
@settings_table = Table.new(settings_table_params)
|
|
@settings_table.type = DiningFacility::TABLE_TYPE
|
|
@settings_table.zone_id = params[:zone_id]
|
|
@settings_table.created_by = current_login_employee.name
|
|
respond_to do |format|
|
|
if @settings_table.save
|
|
format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully created.' }
|
|
format.json { render :show, status: :created, location: @settings_table }
|
|
else
|
|
format.html { render :new }
|
|
format.json { render json: @settings_table.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PATCH/PUT /settings/tables/1
|
|
# PATCH/PUT /settings/tables/1.json
|
|
def update
|
|
@settings_table.created_by = current_login_employee.name
|
|
respond_to do |format|
|
|
if @settings_table.update(settings_table_params)
|
|
format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully updated.' }
|
|
format.json { render :show, status: :ok, location: @settings_table }
|
|
else
|
|
format.html { render :edit }
|
|
format.json { render json: @settings_table.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /settings/tables/1
|
|
# DELETE /settings/tables/1.json
|
|
def destroy
|
|
@settings_table.destroy
|
|
respond_to do |format|
|
|
format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully destroyed.' }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_settings_table
|
|
@settings_table = Table.find(params[:id])
|
|
end
|
|
|
|
def set_settings_zone
|
|
@zone = Zone.find(params[:zone_id])
|
|
end
|
|
|
|
# Never trust parameters from the scary internet, only allow the white list through.
|
|
def settings_table_params
|
|
params.require(:table).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by)
|
|
end
|
|
end
|