upgrade pat3
This commit is contained in:
@@ -20,7 +20,7 @@ class SupplierController < ApplicationController
|
||||
# POST /supplier/settings
|
||||
def update
|
||||
@supplier = current_supplier
|
||||
if current_supplier.update_attributes(params[:supplier])
|
||||
if current_supplier.update_attributes(supplier_params)
|
||||
redirect_to supplier_root_path
|
||||
else
|
||||
render action: :edit
|
||||
@@ -115,4 +115,10 @@ class SupplierController < ApplicationController
|
||||
@order.is_delivered!
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def supplier_params
|
||||
params.require(:supplier).permit(:name, :email, :open, :time_zone, :night_offset, :location, :lat, :lng, :offer_wifi, :wifi_ssid, :wifi_type, :wifi_password, :iens_profile)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,5 +3,9 @@ module Suppliers
|
||||
before_filter :authenticate_supplier!
|
||||
layout 'tablet'
|
||||
|
||||
rescue_from 'RestClient::Conflict' do |e|
|
||||
#binding.pry
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
+16
-8
@@ -4,7 +4,7 @@ class Section
|
||||
include ActiveModel::SerializerSupport
|
||||
|
||||
property :title
|
||||
property :path, type: Array, default: [[0.0, 0.0], [20.0, 30.0]] # default width 20m height 30m
|
||||
property :path, type: Array, default: [[0.0, 0.0], [20.0, 0.0], [20.0, 30.0], [0.0, 30.0]] # default width 20m height 30m
|
||||
|
||||
belongs_to :supplier
|
||||
has_many :tables
|
||||
@@ -34,20 +34,25 @@ class Section
|
||||
@active_orders ||= Order.active_for_supplier_and_section(supplier_id, id)
|
||||
end
|
||||
|
||||
|
||||
def width
|
||||
self.path.last.try(:first).to_f - self.path.first.try(:first).to_f
|
||||
x_coords = path.map(&:first)
|
||||
x_coords.max - x_coords.min
|
||||
end
|
||||
def height
|
||||
self.path.last.try(:last).to_f - self.path.first.try(:last).to_f
|
||||
|
||||
def height
|
||||
y_coords = path.map(&:last)
|
||||
y_coords.max - y_coords.min
|
||||
end
|
||||
|
||||
def width=(val)
|
||||
val = val.to_f
|
||||
self.path[0] ||= [0.0, 0.0]
|
||||
self.path[1] ||= [0.0, 0.0]
|
||||
unless path[1][0] == val
|
||||
self.path[2] ||= [0.0, 0.0]
|
||||
self.path[3] ||= [0.0, 0.0]
|
||||
unless path[1][0] == val && path[2][0] == val
|
||||
self.path[1][0] = val
|
||||
self.path[2][0] = val
|
||||
path_will_change!
|
||||
end
|
||||
end
|
||||
@@ -56,8 +61,11 @@ class Section
|
||||
val = val.to_f
|
||||
self.path[0] ||= [0.0, 0.0]
|
||||
self.path[1] ||= [0.0, 0.0]
|
||||
unless path[1][1] == val
|
||||
self.path[1][1] = val
|
||||
self.path[2] ||= [0.0, 0.0]
|
||||
self.path[3] ||= [0.0, 0.0]
|
||||
unless path[2][1] == val && path[3][1] == val
|
||||
self.path[2][1] = val
|
||||
self.path[3][1] = val
|
||||
path_will_change!
|
||||
end
|
||||
end
|
||||
|
||||
+10
-5
@@ -56,21 +56,26 @@ class Table
|
||||
if tables.is_a?(Array)
|
||||
lists = List.active_for_table(tables.map(&:id))
|
||||
for table in tables
|
||||
table.active_list_id = lists.find{|l| l.table_id == table.id}.try(:id)
|
||||
if list = lists.find{|l| l.table_id == table.id}
|
||||
table.active_list_id = list.id
|
||||
table.active_list = list
|
||||
end
|
||||
end
|
||||
tables
|
||||
else
|
||||
table = tables
|
||||
list = List.active_for_table(table).first
|
||||
table.active_list_id = list.id if list.present?
|
||||
if list = List.active_for_table(table).first
|
||||
table.active_list_id = list.id
|
||||
table.active_list = list
|
||||
end
|
||||
table
|
||||
end
|
||||
end
|
||||
|
||||
def active_list
|
||||
# nil memoizing
|
||||
return @active_list if @active_list_is_set
|
||||
@active_list ||= self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first)
|
||||
return @active_list if @active_list || @active_list_is_set
|
||||
self.active_list = self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first)
|
||||
end
|
||||
|
||||
def active_list=(val)
|
||||
|
||||
Reference in New Issue
Block a user