Make section table view work request and event based
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.2"
|
||||
@@ -20,10 +21,13 @@
|
||||
xml:space="preserve"
|
||||
id="svg2"
|
||||
inkscape:version="0.48.2 r9819"
|
||||
sodipodi:docname="location-balloon.svg"><metadata
|
||||
sodipodi:docname="location-balloon.svg"
|
||||
inkscape:export-filename="/Users/bterkuile/companytools/development/rails/qwaiter/app/assets/images/supplier/settings/location-balloon.png"
|
||||
inkscape:export-xdpi="68.059998"
|
||||
inkscape:export-ydpi="68.059998"><metadata
|
||||
id="metadata89"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
@@ -37,8 +41,8 @@
|
||||
id="namedview87"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.4941487"
|
||||
inkscape:cx="273.18572"
|
||||
inkscape:cy="568.54313"
|
||||
inkscape:cx="380.27011"
|
||||
inkscape:cy="488.22983"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
@@ -164,27 +168,29 @@
|
||||
class="SlideGroup"
|
||||
id="g49">
|
||||
<path
|
||||
style="fill:#ffffff;stroke:none"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path59"
|
||||
d="m 7388.007,10723.32 c -814,0 -1628,415 -1628,831 l 0,622 0,623 0,848 0,623 0,622 c 0,416 814,832 1628,832 l -3736.9999,1936 6179,-1936 1659.9999,0 1221,0 1221,0 c 814,0 1629,-416 1629,-832 l 0,-622 0,-623 0,-848 0,-623 0,-622 c 0,-416 -815,-831 -1629,-831 l -1221,0 -1221,0 -1659.9999,0 -1221,0 -1221.0001,0 z m -1628,0 0,0 z m 9801,5001 0,0 z" /><path
|
||||
style="fill:none;stroke:#faa732;stroke-width:64.91110992;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
style="fill:#ffffff;stroke:#faa732;stroke-width:64.91110992000000124;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path61"
|
||||
d="m 7388.007,10723.32 c -814,0 -1628,415 -1628,831 l 0,622 0,623 0,848 0,623 0,622 c 0,416 814,832 1628,832 0,0 -257.6153,652.507 -500.6945,891.35 -675.1155,663.349 -2499.654,1346.866 -2499.654,1346.866 0,0 1937.451,-380.518 2845.1246,-752.656 922.8078,-378.343 2597.224,-1485.56 2597.224,-1485.56 l 1659.9999,0 1221,0 1221,0 c 814,0 1629,-416 1629,-832 l 0,-622 0,-623 0,-848 0,-623 0,-622 c 0,-416 -815,-831 -1629,-831 l -1221,0 -1221,0 -1659.9999,0 -1221,0 z"
|
||||
sodipodi:nodetypes="ssccccscacacccssccccssccccs" /><text
|
||||
d="m 8049.1044,11195.532 c -814,0 -1628,415 -1628,831 l 0,622 0,623 0,848 0,623 0,622 c 0,416 814,832 1628,832 0,0 -257.6153,652.507 -500.6945,891.35 -675.1155,663.349 -2499.654,1346.866 -2499.654,1346.866 0,0 1937.451,-380.518 2845.1246,-752.656 922.8078,-378.343 2597.2245,-1485.56 2597.2245,-1485.56 l 1659.999,0 1221,0 1221,0 c 814,0 1629,-416 1629,-832 l 0,-622 0,-623 0,-848 0,-623 0,-622 c 0,-416 -815,-831 -1629,-831 l -1221,0 -1221,0 -1659.999,0 -1221.0005,0 z"
|
||||
sodipodi:nodetypes="ssccccscacacccssccccssccccs"
|
||||
inkscape:export-filename="/Users/bterkuile/companytools/development/rails/qwaiter/app/assets/images/supplier/settings/location-balloon.png"
|
||||
inkscape:export-xdpi="68.059998"
|
||||
inkscape:export-ydpi="68.059998" /><text
|
||||
id="text63"
|
||||
class="TextShape"
|
||||
x="-339.99295"
|
||||
y="623.32043"><tspan
|
||||
x="321.10446"
|
||||
y="1095.5328"
|
||||
inkscape:export-filename="/Users/bterkuile/companytools/development/rails/qwaiter/app/assets/images/supplier/settings/location-balloon.png"
|
||||
inkscape:export-xdpi="68.059998"
|
||||
inkscape:export-ydpi="68.059998"><tspan
|
||||
style="font-size:1128px;font-weight:400;font-family:'Arial, sans-serif'"
|
||||
id="tspan65"
|
||||
font-weight="400"
|
||||
font-size="1128px"
|
||||
class="TextParagraph"><tspan
|
||||
id="tspan67"
|
||||
y="12358.32"
|
||||
x="6772.0068"
|
||||
y="12830.533"
|
||||
x="7433.104"
|
||||
class="TextPosition"><tspan
|
||||
style="fill:#000000;stroke:none"
|
||||
id="tspan69">Klik op de kaart</tspan></tspan></tspan><tspan
|
||||
@@ -194,8 +200,8 @@
|
||||
font-size="1128px"
|
||||
class="TextParagraph"><tspan
|
||||
id="tspan73"
|
||||
y="13615.32"
|
||||
x="7338.0068"
|
||||
y="14087.533"
|
||||
x="7999.104"
|
||||
class="TextPosition"><tspan
|
||||
style="fill:#000000;stroke:none"
|
||||
id="tspan75"> </tspan><tspan
|
||||
@@ -207,13 +213,44 @@
|
||||
font-size="1128px"
|
||||
class="TextParagraph"><tspan
|
||||
id="tspan81"
|
||||
y="14872.32"
|
||||
x="7242.0068"
|
||||
y="15344.533"
|
||||
x="7903.104"
|
||||
class="TextPosition"><tspan
|
||||
style="fill:#000000;stroke:none"
|
||||
id="tspan83"> </tspan><tspan
|
||||
style="fill:#000000;stroke:none"
|
||||
id="tspan85">aan te geven</tspan></tspan></tspan></text>
|
||||
|
||||
</g>
|
||||
<image
|
||||
y="13557.102"
|
||||
x="6631.6304"
|
||||
id="image4034"
|
||||
xlink:href="data:image/png;base64,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
|
||||
rkJggg==
|
||||
"
|
||||
height="1502.8586"
|
||||
width="1299.7695" /></g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 9.6 KiB |
@@ -7,6 +7,7 @@ class List
|
||||
needs_help: -> @attributes.needs_help
|
||||
needs_payment: -> @attributes.needs_payment
|
||||
active: -> @attributes.state == 'active'
|
||||
table_id: -> @attributes.table_id
|
||||
products: -> @attributes.products || []
|
||||
supplier_name: -> @attributes.supplier_name
|
||||
created_at: -> @attributes.created_at
|
||||
|
||||
@@ -7,31 +7,50 @@ root.Qsupplier=
|
||||
body = $('#active-orders-table tbody')
|
||||
order = new Order(e.data)
|
||||
body.append @mustache('#active-order-template', order)
|
||||
$('.section-table-list-'+order.list_id()).addClass('active_order')
|
||||
else if(e.event == 'list_needs_help')
|
||||
$('#list-needs-help-indicator-'+e.data.id).removeClass('hide')
|
||||
$('#list-is-helped-button-'+e.data.id).removeClass('hide')
|
||||
$('.section-table-list-'+e.data.id).addClass('needs_help')
|
||||
else if(e.event == 'list_needs_payment')
|
||||
$('#list-needs-payment-indicator-'+e.data.id).removeClass('hide')
|
||||
else if(e.event == 'list_added')
|
||||
$('.section-table-list-'+e.data.id).addClass('needs_payment')
|
||||
else if(e.event == 'list_added') # DEPRICATED now handled by list_update
|
||||
list = new List(e.data)
|
||||
$('#active-lists-table tbody').append @mustache('#active-list-template', list)
|
||||
# Add classes to section table view
|
||||
table = $('#section-table-'+list.table_id())
|
||||
table.addClass('section-table-list-'+list.id())
|
||||
table.addClass('occupied')
|
||||
table.addClass('needs_help') if list.needs_help()
|
||||
table.addClass('needs_payment') if list.needs_payment()
|
||||
else if e.event == 'list_update'
|
||||
list = new List(e.data)
|
||||
row = $('#list-row-'+list.id())
|
||||
content = @mustache('#active-list-template', list)
|
||||
if row.length then row.replaceWith(content) else $('#active-lists-table tbody').append(content)
|
||||
table = $('#section-table-'+list.table_id())
|
||||
if table.length
|
||||
table.addClass('section-table-list-'+list.id())
|
||||
table.addClass('occupied')
|
||||
table.addClass('needs_help') if list.needs_help()
|
||||
table.addClass('needs_payment') if list.needs_payment()
|
||||
else if e.event == 'list_closed'
|
||||
$('#list-row-'+e.data.id).remove()
|
||||
$('.of-list-'+e.data.id).remove()
|
||||
table_list_class = 'section-table-list-'+e.data.id
|
||||
$('.'+table_list_class).removeClass('occupied needs_help needs_payment active_order').removeClass(table_list_class)
|
||||
else if e.event == 'list_helped'
|
||||
list_id = e.data.id
|
||||
$('#list-needs-help-indicator-'+list_id).addClass('hide')
|
||||
$('#list-is-helped-button-'+list_id).addClass('hide')
|
||||
$('.section-table-list-'+list_id).removeClass('needs_help')
|
||||
else if e.event == 'order_being_processed'
|
||||
$('#order-in-process-button-'+e.data.id).hide()
|
||||
$('#order-row-'+e.data.id).removeClass('placed').addClass('active')
|
||||
else if e.event == 'order_being_delivered'
|
||||
$('#order-row-'+e.data.id).remove()
|
||||
$('.section-table-list-'+e.data.list_id).removeClass('active_order')
|
||||
else if e.event == 'list_changed_table'
|
||||
list_row = $('#list-row-'+e.data.list_id)
|
||||
list_row.find('.table_number').text(e.data.table.number).addClass('changed')
|
||||
@@ -39,6 +58,14 @@ root.Qsupplier=
|
||||
order_rows = $('.of-list-'+e.data.list_id)
|
||||
order_rows.find('.table_number').text(e.data.table.number).addClass('changed')
|
||||
order_rows.find('.section_title').text(e.data.section_title)
|
||||
# Move properties from table in section tables view
|
||||
window.last_data = e.data
|
||||
from_table = $('#section-table-'+e.data.from_table_id)
|
||||
to_table = $('#section-table-'+e.data.table._id)
|
||||
# Now switch classes
|
||||
from_class = from_table.attr('class')
|
||||
from_table.attr('class', to_table.attr('class'))
|
||||
to_table.attr('class', from_class)
|
||||
|
||||
|
||||
console.log(e)
|
||||
@@ -168,10 +195,12 @@ root.Qsupplier=
|
||||
if response.ok then window.location.reload() else @alert(t(response.message))
|
||||
false
|
||||
mustache: (selector, locals)->
|
||||
html = $(selector).html()
|
||||
return '' unless html
|
||||
locs = $.extend(locals,
|
||||
currency: ->
|
||||
(val)->
|
||||
currency(Mustache.render(val, this))
|
||||
)
|
||||
Mustache.to_html($(selector).html(), locs)
|
||||
Mustache.to_html(html, locs)
|
||||
alert: Qwaiter.alert
|
||||
|
||||
@@ -7,7 +7,8 @@ class DashboardController < ApplicationController
|
||||
|
||||
# Testing action
|
||||
def select_qrcode
|
||||
@tables = Table.all.sample(2) | List.active.map(&:table)
|
||||
#@tables = Table.all.sample(2) | List.active.map(&:table)
|
||||
@tables = Supplier.first.tables.sample(2) | List.active.map(&:table)
|
||||
render layout: 'phone'
|
||||
end
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class UserController < ApplicationController
|
||||
end
|
||||
|
||||
# POST /user/create_list {table_id: 1234}
|
||||
#DEPRICATED
|
||||
#DEPRICATED, see order_selected_products, this one now handles list creation as well
|
||||
def create_list
|
||||
render nothing: true and return unless current_user.present?
|
||||
@table = Table.find(params[:table_id])
|
||||
|
||||
+9
-2
@@ -70,6 +70,7 @@ class List
|
||||
list.save
|
||||
user.active_list_id = list.id
|
||||
user.save
|
||||
# list_added is depricated, now handled by list_update
|
||||
#list.broadcast_supplier list.supplier_id, 'list_added', list.with_info_as_json
|
||||
list
|
||||
end
|
||||
@@ -96,8 +97,13 @@ class List
|
||||
end
|
||||
|
||||
def self.active_for_table(table_id, options = {})
|
||||
if table_id.is_a?(Array)
|
||||
database.view(active_by_table_id_view(options.reverse_merge(keys: table_id, reduce: false, include_docs: true)))
|
||||
else
|
||||
table_id = table_id.id if table_id.is_a?(SimplyStored::Couch)
|
||||
database.view(active_by_table_id_view(options.reverse_merge(key: table_id, reduce: false, include_docs: true)))
|
||||
end
|
||||
end
|
||||
|
||||
def self.for_user(user, options = {})
|
||||
total_entries = database.view(for_user_view({startkey: ["#{user.id}\u9999"], endkey: [user.id], include_docs: false, reduce: true, descending: true}))
|
||||
@@ -158,13 +164,14 @@ class List
|
||||
|
||||
def move_to_table! to_table
|
||||
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
|
||||
from_table = self.table_id.try(:dup)
|
||||
self.table = to_table
|
||||
self.section_id = to_table.section_id
|
||||
if save
|
||||
for user_id in user_ids
|
||||
broadcast_user user_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title)
|
||||
broadcast_user user_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title), from_table_id: from_table
|
||||
end
|
||||
broadcast_supplier supplier_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title)
|
||||
broadcast_supplier supplier_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title), from_table_id: from_table
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+6
-5
@@ -33,7 +33,8 @@ class Order
|
||||
|
||||
# Return all currently active orders for a given section
|
||||
def self.active_for_supplier_and_section(supplier, section_id)
|
||||
database.view(active_for_supplier_and_section_view(key: [supplier.id, section_id], reduce: false, include_docs: true))
|
||||
supplier_id = supplier.is_a?(SimplyStored::Couch) ? supplier.id : supplier
|
||||
database.view(active_for_supplier_and_section_view(key: [supplier_id, section_id], reduce: false, include_docs: true))
|
||||
end
|
||||
|
||||
def table_number
|
||||
@@ -53,9 +54,9 @@ class Order
|
||||
self.state = 'active'
|
||||
if save
|
||||
for user_id in list.user_ids
|
||||
broadcast_user user_id, 'order_being_processed', id: id
|
||||
broadcast_user user_id, 'order_being_processed', id: id, list_id: list_id
|
||||
end
|
||||
broadcast_supplier supplier_id, 'order_being_processed', id: id
|
||||
broadcast_supplier supplier_id, 'order_being_processed', id: id, list_id: list_id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,9 +64,9 @@ class Order
|
||||
self.state = 'delivered'
|
||||
if save
|
||||
for user_id in list.user_ids
|
||||
broadcast_user user_id, 'order_being_delivered', id: id
|
||||
broadcast_user user_id, 'order_being_delivered', id: id, list_id: list_id
|
||||
end
|
||||
broadcast_supplier supplier_id, 'order_being_delivered', id: id
|
||||
broadcast_supplier supplier_id, 'order_being_delivered', id: id, list_id: list_id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ class Section
|
||||
@active_lists = List.active_for_section(self.id)
|
||||
end
|
||||
|
||||
def active_orders
|
||||
@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
|
||||
@@ -66,9 +70,11 @@ class Section
|
||||
h[:tables] = []
|
||||
for table in tables
|
||||
ht = table.as_json
|
||||
table_list = active_lists.find{|l| l.table_id == table.id}
|
||||
ht[:occupied] = occupied_tables.include?(table)
|
||||
ht[:needs_help] = ht[:occupied] ? active_lists.find{|l| l.table_id == table.id}.try(:needs_help).present? : false
|
||||
ht[:needs_payment] = ht[:occupied] ? active_lists.find{|l| l.table_id == table.id}.try(:needs_payment).present? : false
|
||||
ht[:needs_help] = ht[:occupied] && table_list ? table_list.needs_help? : false
|
||||
ht[:needs_payment] = ht[:occupied] && table_list ? table_list.needs_payment? : false
|
||||
ht[:active_order] = ht[:occupied] && table_list ? active_orders.any?{|o| o.list_id == table_list.id } : false
|
||||
h[:tables] << ht
|
||||
end
|
||||
@for_tables_as_json = h
|
||||
|
||||
@@ -11,6 +11,7 @@ class Table
|
||||
has_many :lists
|
||||
|
||||
attr_protected :supplier_id
|
||||
attr_accessor :active_list_id
|
||||
|
||||
validates :supplier_id, presence: true
|
||||
#validates :list_id, presence: true
|
||||
@@ -45,6 +46,21 @@ class Table
|
||||
@is_occupied = !self.class.database.view(List.active_by_table_id_view(key: id, reduce: true)).zero?
|
||||
end
|
||||
|
||||
def self.enrich_active_list_id(tables)
|
||||
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)
|
||||
end
|
||||
tables
|
||||
else
|
||||
table = tables
|
||||
list = List.active_for_table(table).first
|
||||
table.active_list_id = list.id if list.present?
|
||||
table
|
||||
end
|
||||
end
|
||||
|
||||
def active_list
|
||||
@active_list ||= self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first)
|
||||
end
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
.span12
|
||||
.well.section-tables-container.section-tables-active
|
||||
.section-manage-tables.pull-right= link_to content_tag(:span, '', class: 'icon-pencil'), manage_tables_suppliers_section_path(@section), class: 'btn btn-mini'
|
||||
- for table in @section.tables
|
||||
.section-table.hide{ id="section-table-#{table.id}" data-position-x=table.position_x data-position-y=table.position_y data-table-id=table.id}
|
||||
- for table in Table.enrich_active_list_id(@section.tables)
|
||||
.section-table.hide[
|
||||
class="section-table-list-#{table.active_list_id}" id="section-table-#{table.id}"
|
||||
data-position-x=table.position_x data-position-y=table.position_y data-table-id=table.id]
|
||||
.table-number = link_to table.number, suppliers_table_path(table)
|
||||
.status-icons
|
||||
span.needs_payment.icon-flag
|
||||
@@ -24,5 +26,6 @@
|
||||
Qsupplier.position_table_in_active_section(active_section_container, $(this), false);
|
||||
});
|
||||
Qsupplier.update_section_tables_view('#{@section.id}');
|
||||
setInterval("Qsupplier.update_section_tables_view('#{@section.id}')", 7500);
|
||||
//setInterval("Qsupplier.update_section_tables_view('#{@section.id}')", 7500);
|
||||
Qsupplier.watch_events();
|
||||
});
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Table do
|
||||
describe 'for_supplier' do
|
||||
let(:supplier){ create(:supplier) }
|
||||
describe 'for_supplier' do
|
||||
let(:options){ Hash.new }
|
||||
subject{ Table.for_supplier(supplier, options) }
|
||||
it "should return an empty array by default" do
|
||||
@@ -46,4 +46,29 @@ describe Table do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'enrich_active_list_id' do
|
||||
before do
|
||||
@table1 = create :table, supplier: supplier, number: 2
|
||||
@list = create :list, supplier: supplier, table: @table1, state: 'active'
|
||||
end
|
||||
|
||||
# False passes can be possible when list is not valid
|
||||
it 'has created a list' do
|
||||
@list.id.should be_present
|
||||
end
|
||||
|
||||
it 'enriches active_list_id using a single object' do
|
||||
Table.enrich_active_list_id(@table1).active_list_id.should == @list.id
|
||||
end
|
||||
|
||||
it 'enriches active_list_id using an array' do
|
||||
Table.enrich_active_list_id([@table1]).first.active_list_id.should == @list.id
|
||||
end
|
||||
|
||||
it "does not enrich non active lists" do
|
||||
@list.update_attributes(state: 'closed')
|
||||
Table.enrich_active_list_id([@table1]).first.active_list_id.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user