changing table user acceptance specs in the green
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
App.SelectQrcodeController = Ember.Controller.extend
|
||||
actions:
|
||||
selectQr: (table)->
|
||||
Qstorage.setItem 'table_id', table._id
|
||||
@secured ->
|
||||
$.getJSON($data_host + '/user/table_info.json?'+@authentication_string+'&table_id='+table._id).then (res)=>
|
||||
if res.current_table_id
|
||||
@@ -29,6 +28,8 @@ App.SelectQrcodeController = Ember.Controller.extend
|
||||
if res2.occupied
|
||||
@redirect_to 'user_root', message: 'move_table.cannot_move_to_occupied_tabe'
|
||||
else
|
||||
# Now we can move table
|
||||
Qstorage.setItem 'table_id', table._id
|
||||
@redirect_to 'table', table._id, message: 'move_table.moved_to_another_table'
|
||||
cancel: =>
|
||||
@redirect_to 'table', res.current_table_id
|
||||
|
||||
@@ -2,5 +2,5 @@ modal-dialog action="close"
|
||||
h3.flush--top= title
|
||||
p=body
|
||||
hr
|
||||
button{action "close"}= t 'confirm.cancel'
|
||||
button.right{action 'confirm'}= t 'confirm.confirm'
|
||||
button.confirm-cancel{action "close"}= t 'confirm.cancel'
|
||||
button.confirm-ok.right{action 'confirm'}= t 'confirm.confirm'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
each table in tables
|
||||
img{action selectQr table} src="/table_qr_image.svg?table_id=#{unbound table._id}"
|
||||
a{action selectQr table}: img src="/table_qr_image.svg?table_id=#{unbound table._id}"
|
||||
|
||||
@@ -8,7 +8,11 @@ class DashboardController < ApplicationController
|
||||
# Testing action
|
||||
def select_qrcode
|
||||
#@tables = Table.all.sample(2) | List.active.map(&:table)
|
||||
@tables = (current_supplier || Supplier.first).tables.sample(5) | List.active.map(&:table)
|
||||
if Rails.env.test?
|
||||
@tables = Table.all
|
||||
else
|
||||
@tables = (current_supplier || Supplier.first).tables.sample(5) | List.active.map(&:table)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { render layout: 'phone' }
|
||||
format.json { render json: @tables.to_json }
|
||||
|
||||
@@ -36,23 +36,51 @@ class UserController < Users::ApplicationController
|
||||
#end
|
||||
|
||||
# GET /user/table_info.json
|
||||
#def table_info
|
||||
#respond_to do |format|
|
||||
#format.json do
|
||||
#render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
#@table = Table.find(params[:table_id])
|
||||
#res = {}
|
||||
#res[:occupied] = @table.occupied?
|
||||
#res[:reserved] = @table.reserved?
|
||||
#res[:supplier_closed] = @table.supplier.closed?
|
||||
#if list.present?
|
||||
#res[:other_supplier] = true if list.supplier_id != @table.supplier_id
|
||||
#res[:current_table_id] = list.table_id
|
||||
#end
|
||||
#render json: res
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
# used for moving table request
|
||||
# TODO wrap logic of actions
|
||||
# - table_info
|
||||
# - move_table
|
||||
# into separate class and implement security in a non stupid way as it is now
|
||||
def table_info
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
@table = Table.find(params[:table_id])
|
||||
res = {}
|
||||
res[:occupied] = @table.occupied?
|
||||
res[:reserved] = @table.reserved?
|
||||
res[:supplier_closed] = @table.supplier.closed?
|
||||
if list.present?
|
||||
res[:other_supplier] = true if list.supplier_id != @table.supplier_id
|
||||
res[:current_table_id] = list.table_id
|
||||
end
|
||||
render json: res
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# POST /user/move_table.json
|
||||
# used to move the table
|
||||
# TODO wrap logic of actions
|
||||
# - table_info
|
||||
# - move_table
|
||||
# into separate class and implement security in a non stupid way as it is now
|
||||
def move_table
|
||||
render json: json_alert('messages.no_active_list', list_active: false) and return unless list.present?
|
||||
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
@table = Table.find(params[:table_id])
|
||||
if @table.occupied?
|
||||
render json: {occupied: true}
|
||||
elsif @table.reserved?
|
||||
render json: {reserved: true}
|
||||
elsif list.supplier_id != @table.supplier_id
|
||||
res[:other_supplier] = true if list.supplier_id != @table.supplier_id
|
||||
res[:current_table_id] = list.table_id
|
||||
else
|
||||
list.move_to_table! @table
|
||||
render json: {occupied: false, reserved: false}
|
||||
end
|
||||
end
|
||||
|
||||
# GET /suppliers/1/product_list
|
||||
# GET /suppliers/1/product_list.json
|
||||
@@ -285,15 +313,4 @@ class UserController < Users::ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#def move_table
|
||||
#render json: json_alert('messages.no_active_list', list_active: false) and return unless list.present?
|
||||
#render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
#@table = Table.find(params[:table_id])
|
||||
#if @table.occupied?
|
||||
#render json: {occupied: true}
|
||||
#else
|
||||
#list.move_to_table! @table
|
||||
#render json: {occupied: false}
|
||||
#end
|
||||
#end
|
||||
end
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ class List
|
||||
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
|
||||
from_table_id = self.table_id.try(:dup)
|
||||
self.table = to_table
|
||||
self.section_id = to_table.section_id
|
||||
self.section_id = to_table.section_id
|
||||
if save
|
||||
# Update the section of an order
|
||||
orders.each do |order|
|
||||
|
||||
Reference in New Issue
Block a user