Zone and OQS

This commit is contained in:
Phyo
2017-06-17 18:00:59 +06:30
parent cd804a3d18
commit b093a993ba
26 changed files with 608 additions and 60 deletions

View File

@@ -71,6 +71,6 @@ class Settings::OrderQueueStationsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_order_queue_station_params
params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by)
params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] })
end
end

View File

@@ -0,0 +1,81 @@
class Settings::RoomsController < ApplicationController
before_action :set_settings_room, only: [:show, :edit, :update, :destroy]
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create]
# GET /settings/rooms
# GET /settings/rooms.json
def index
@settings_rooms = @zone.rooms
end
# GET /settings/rooms/1
# GET /settings/rooms/1.json
def show
@room = Room.find(params[:id])
end
# GET /settings/rooms/new
def new
@settings_room = Room.new
end
# GET /settings/rooms/1/edit
def edit
end
# POST /settings/rooms
# POST /settings/rooms.json
def create
@settings_room = Room.new(settings_room_params)
@settings_room.type = DiningFacility::ROOM_TYPE
@settings_room.zone_id = params[:zone_id]
respond_to do |format|
if @settings_room.save
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully created.' }
format.json { render :show, status: :created, location: @settings_room }
else
puts "abc"
format.html { render :new }
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/rooms/1
# PATCH/PUT /settings/rooms/1.json
def update
respond_to do |format|
if @settings_room.update(settings_room_params)
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_room }
else
format.html { render :edit }
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/rooms/1
# DELETE /settings/rooms/1.json
def destroy
@settings_room.destroy
respond_to do |format|
format.html { redirect_to settings_zones_path, notice: 'Room was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_room
@settings_room = Room.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_room_params
params.require(:room).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by)
end
end

View File

@@ -0,0 +1,81 @@
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]
respond_to do |format|
if @settings_table.save
format.html { redirect_to settings_zone_tables_path, notice: 'Table was successfully created.' }
format.json { render :show, status: :created, location: @settings_table }
else
puts "abc"
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
respond_to do |format|
if @settings_table.update(settings_table_params)
format.html { redirect_to settings_zone_tables_path, 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_zones_path, 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

View File

@@ -10,6 +10,8 @@ class Settings::ZonesController < ApplicationController
# GET /settings/zones/1
# GET /settings/zones/1.json
def show
@settings_tables = @settings_zone.tables
@settings_rooms = @settings_zone.rooms
end
# GET /settings/zones/new
@@ -28,7 +30,7 @@ class Settings::ZonesController < ApplicationController
respond_to do |format|
if @settings_zone.save
format.html { redirect_to @settings_zone, notice: 'Zone was successfully created.' }
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully created.' }
format.json { render :show, status: :created, location: @settings_zone }
else
format.html { render :new }
@@ -42,7 +44,7 @@ class Settings::ZonesController < ApplicationController
def update
respond_to do |format|
if @settings_zone.update(settings_zone_params)
format.html { redirect_to @settings_zone, notice: 'Zone was successfully updated.' }
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_zone }
else
format.html { render :edit }
@@ -56,7 +58,7 @@ class Settings::ZonesController < ApplicationController
def destroy
@settings_zone.destroy
respond_to do |format|
format.html { redirect_to settings_zones_url, notice: 'Zone was successfully destroyed.' }
format.html { redirect_to settings_zones_path, notice: 'Zone was successfully destroyed.' }
format.json { head :no_content }
end
end
@@ -69,6 +71,6 @@ class Settings::ZonesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_zone_params
params.require(:settings_zone).permit(:name, :is_active, :created_by)
params.require(:zone).permit(:name, :is_active, :created_by)
end
end