move to evented mustache system
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require jquery-ui
|
//= require jquery-ui
|
||||||
//= require twitter/bootstrap
|
//= require twitter/bootstrap
|
||||||
|
//= require mustache
|
||||||
//= require_directory .
|
//= require_directory .
|
||||||
//= require_self
|
//= require_self
|
||||||
var path_mapping = {
|
var path_mapping = {
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
class List
|
||||||
|
constructor: (@attributes)->
|
||||||
|
id: -> @attributes.id || @attributes._id
|
||||||
|
table_number: -> @attributes.table_number
|
||||||
|
total_amount: -> @attributes.total_amount
|
||||||
|
section_title: -> @attributes.section_title
|
||||||
|
needs_help: -> @attributes.needs_help
|
||||||
|
needs_payment: -> @attributes.needs_payment
|
||||||
|
active: -> @attributes.state == 'active'
|
||||||
|
products: -> @attributes.products || []
|
||||||
|
|
||||||
|
@List = List
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
class Order
|
||||||
|
constructor: (@attributes)->
|
||||||
|
table_number: -> @attributes.table_number
|
||||||
|
id: -> @attributes.id || @attributes._id
|
||||||
|
total_amount: -> @attributes.total_amount
|
||||||
|
section_title: -> @attributes.section_title
|
||||||
|
list_id: -> @attributes.list_id
|
||||||
|
state: -> @attributes.state
|
||||||
|
display: ->
|
||||||
|
order_txts = []
|
||||||
|
return '' unless @attributes.products
|
||||||
|
for product in @attributes.products
|
||||||
|
order_txts.push(product.name + ' (' + product.number + ')')
|
||||||
|
order_txts.join(', ')
|
||||||
|
can_process: -> @attributes.state == 'placed'
|
||||||
|
|
||||||
|
@Order = Order
|
||||||
@@ -1,6 +1,37 @@
|
|||||||
root = exports ? this
|
root = exports ? this
|
||||||
data_host = ''
|
|
||||||
root.Qsupplier=
|
root.Qsupplier=
|
||||||
|
watch_events: ->
|
||||||
|
faye = new Faye.Client('http://localhost:9292/faye')
|
||||||
|
faye.subscribe "/supplier/"+supplier_id, (e)=>
|
||||||
|
if(e.event == 'new_order')
|
||||||
|
body = $('#active-orders-table tbody')
|
||||||
|
order = new Order(e.data)
|
||||||
|
body.append @mustache('#active-order-template', 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')
|
||||||
|
else if(e.event == 'list_needs_payment')
|
||||||
|
$('#list-needs-payment-indicator-'+e.data.id).removeClass('hide')
|
||||||
|
else if(e.event == 'list_added')
|
||||||
|
$('#active-lists-table tbody').append @mustache('#active-list-template', new List(e.data))
|
||||||
|
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)
|
||||||
|
else if e.event == 'list_closed'
|
||||||
|
$('#list-row-'+e.data.id).remove()
|
||||||
|
$('.of-list-'+e.data.id).remove()
|
||||||
|
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')
|
||||||
|
else if e.event == 'order_being_processed'
|
||||||
|
$('#order-in-process-button-'+e.data.id).hide()
|
||||||
|
else if e.event == 'order_being_delivered'
|
||||||
|
$('#order-row-'+e.data.id).remove()
|
||||||
|
console.log(e)
|
||||||
|
false
|
||||||
move_table_to_active_section: (table_id)->
|
move_table_to_active_section: (table_id)->
|
||||||
table_container = $('#section-table-'+table_id)
|
table_container = $('#section-table-'+table_id)
|
||||||
section_container = $('.section-tables-active')
|
section_container = $('.section-tables-active')
|
||||||
@@ -14,7 +45,7 @@ root.Qsupplier=
|
|||||||
data: {table: {section_id: current_section_id}},
|
data: {table: {section_id: current_section_id}},
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
)
|
)
|
||||||
position_table_in_active_section: (section_container, table_container, make_draggable)->
|
position_table_in_active_section: (section_container, table_container, make_draggable)->
|
||||||
make_draggable ||= false
|
make_draggable ||= false
|
||||||
button_container = table_container.find('.action-button-container')
|
button_container = table_container.find('.action-button-container')
|
||||||
button_container.html('')
|
button_container.html('')
|
||||||
@@ -55,84 +86,39 @@ root.Qsupplier=
|
|||||||
data: {table: {section_id: ''}},
|
data: {table: {section_id: ''}},
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
)
|
)
|
||||||
|
|
||||||
load_active_lists: () ->
|
load_active_lists: () ->
|
||||||
$.get('/supplier/active_lists.json?section_id='+($('#current_section_selector').val() || ''), (res) ->
|
$.get('/supplier/active_lists.json?section_id='+($('#current_section_selector').val() || ''), (res) =>
|
||||||
body = $('#active-lists-table tbody')
|
body = $('#active-lists-table tbody')
|
||||||
body.find('tr').remove()
|
body.find('tr').remove()
|
||||||
foot = $('#active-lists-table tfoot')
|
foot = $('#active-lists-table tfoot')
|
||||||
for list in res.lists
|
for list in res.lists
|
||||||
order_txts = []
|
body.append @mustache('#active-list-template', new List(list))
|
||||||
row = $('<tr></tr>').appendTo(body)
|
)
|
||||||
close_btn = $('<button class="btn btn-warning">Close!</button>')
|
mark_list_as_helped: (list_id)->
|
||||||
close_callback = ( (lst, r) ->
|
$.post('/supplier/mark_list_as_helped', {list_id: list_id}, (res)->
|
||||||
->
|
)
|
||||||
my_btn = $(this)
|
close_list: (list_id)->
|
||||||
$.post('/supplier/close_list', {list_id: list._id}, (res)-> r.slideUp('slow'))
|
$.post('/supplier/close_list', {list_id: list_id}, (res)->
|
||||||
)(list, row)
|
|
||||||
close_btn.click(close_callback)
|
|
||||||
|
|
||||||
needs_help_btn = $('<button class="btn btn-info">Question answered!</button>')
|
|
||||||
needs_help_callback = ( (lst, r) ->
|
|
||||||
->
|
|
||||||
my_btn = $(this)
|
|
||||||
$.post('/supplier/mark_list_as_helped', {list_id: list._id}, (res)-> my_btn.remove() )
|
|
||||||
)(list, row)
|
|
||||||
needs_help_btn.click(needs_help_callback)
|
|
||||||
|
|
||||||
|
|
||||||
icons_td = $('<td class="status-icons"></td>').appendTo(row)
|
|
||||||
icons_td.append('<i class="icon-hand-up"></i>').append(' ') if list.needs_help # or icon-bell
|
|
||||||
icons_td.append('<i class="icon-check"></i>') if list.needs_payment
|
|
||||||
|
|
||||||
row.append($('<td class="numeric"></td>').append($('<a href="/supplier/lists/'+list._id+'"></a>').text(list.table_number)))
|
|
||||||
row.append($('<td></td>').text(list.section_title))
|
|
||||||
row.append($('<td class="currency"></td>').html(currency(list.total_amount)))
|
|
||||||
td_buttons = $('<td class="actions"></td>')
|
|
||||||
td_buttons.append(needs_help_btn).append(' ') if list.needs_help
|
|
||||||
td_buttons.append(close_btn)
|
|
||||||
row.append(td_buttons)
|
|
||||||
#foot.append('<tr><td></td><td class="currency"><strong>'+currency(res.total_amount)+'</strong></td></tr>');
|
|
||||||
)
|
)
|
||||||
|
|
||||||
load_active_orders: () ->
|
load_active_orders: () ->
|
||||||
$.get('/supplier/active_orders.json?section_id='+($('#current_section_selector').val() || ''), (res) ->
|
$.get('/supplier/active_orders.json?section_id='+($('#current_section_selector').val() || ''), (res) =>
|
||||||
body = $('#active-orders-table tbody')
|
body = $('#active-orders-table tbody')
|
||||||
body.find('tr').remove()
|
body.find('tr').remove()
|
||||||
foot = $('#active-orders-table tfoot')
|
foot = $('#active-orders-table tfoot')
|
||||||
if(!res.orders && !res.orders.length)
|
if(!res.orders && !res.orders.length)
|
||||||
alert('No orders in list');
|
alert('No orders in list')
|
||||||
return;
|
return
|
||||||
for order in res.orders
|
for order in res.orders
|
||||||
order_txts = []
|
ord = new Order(order)
|
||||||
row = $('<tr></tr>').appendTo(body)
|
body.append @mustache('#active-order-template', ord)
|
||||||
process_btn = $('<button class="btn btn-success">In process!</button>')
|
|
||||||
process_callback = ( (ord) ->
|
|
||||||
->
|
|
||||||
my_btn = $(this)
|
|
||||||
$.post('/supplier/mark_order_in_process', {order_id: ord.id}, (res)-> my_btn.remove())
|
|
||||||
)(order)
|
|
||||||
process_btn.click(process_callback)
|
|
||||||
|
|
||||||
delivered_btn = $('<button class="btn btn-inverse">Is delivered!</button>')
|
|
||||||
delivered_callback = ( (ord, r) ->
|
|
||||||
->
|
|
||||||
my_btn = $(this)
|
|
||||||
$.post('/supplier/order_is_delivered', {order_id: ord.id}, (res)-> r.slideUp('slow'))
|
|
||||||
)(order, row)
|
|
||||||
delivered_btn.click(delivered_callback)
|
|
||||||
for product in order.products
|
|
||||||
order_txts.push(product.name + ' (' + product['number'] + ')')
|
|
||||||
row.append($('<td></td>').text(order_txts.join(', ')))
|
|
||||||
row.append($('<td class="numeric"></td>').text(order.table_number))
|
|
||||||
row.append($('<td></td>').text(order.section_title))
|
|
||||||
row.append($('<td class="currency"></td>').html(currency(order.total_amount)))
|
|
||||||
td_buttons = $('<td class="actions"></td>')
|
|
||||||
td_buttons.append(process_btn).append(' ') if order.state == 'placed'
|
|
||||||
td_buttons.append(delivered_btn)
|
|
||||||
row.append(td_buttons)
|
|
||||||
#foot.append('<tr><td></td><td class="currency"><strong>'+currency(res.total_amount)+'</strong></td></tr>');
|
|
||||||
)
|
)
|
||||||
|
mark_order_in_process: (order_id)->
|
||||||
|
$.post('/supplier/mark_order_in_process', {order_id: order_id})
|
||||||
|
mark_order_delivered: (order_id)->
|
||||||
|
$.post('/supplier/order_is_delivered', {order_id: order_id})
|
||||||
|
|
||||||
load_list: (list_id) ->
|
load_list: (list_id) ->
|
||||||
$.get(data_host + '/supplier/lists/'+list_id+'.json', (res) ->
|
$.get(data_host + '/supplier/lists/'+list_id+'.json', (res) ->
|
||||||
body = $('#list-table tbody')
|
body = $('#list-table tbody')
|
||||||
@@ -140,23 +126,13 @@ root.Qsupplier=
|
|||||||
Qsupplier.build_list_table(body, foot, res)
|
Qsupplier.build_list_table(body, foot, res)
|
||||||
)
|
)
|
||||||
build_list_table: (body, foot, res) ->
|
build_list_table: (body, foot, res) ->
|
||||||
body.find('tr').remove()
|
|
||||||
foot.find('tr').remove()
|
|
||||||
if !res.orders && !res.orders.length
|
if !res.orders && !res.orders.length
|
||||||
alert('No orders in list')
|
alert('No orders in list')
|
||||||
return
|
return
|
||||||
|
body.html('')
|
||||||
for order in res.orders
|
for order in res.orders
|
||||||
order_txts = []
|
body.append @mustache('#list-order-template', new Order(order))
|
||||||
row = $('<tr></tr>').appendTo(body)
|
foot.find('.list-total').html(currency(res.total_amount))
|
||||||
row.addClass(order.state)
|
|
||||||
#if(order.state == 'placed') row.addClass('info');
|
|
||||||
#if(order.state == 'delivered') row.addClass('success');
|
|
||||||
row.addClass('error') if order.state == 'cancelled'
|
|
||||||
for product in order.products
|
|
||||||
order_txts.push(product.name + ' (' + product['number'] + ')')
|
|
||||||
row.append($('<td></td>').text(order_txts.join(', ')))
|
|
||||||
row.append($('<td class="currency"></td>').html(currency(order.total_amount)))
|
|
||||||
foot.append('<tr><td></td><td class="currency"><strong>'+currency(res.total_amount)+'</strong></td></tr>')
|
|
||||||
update_section_tables_view: (section_id)->
|
update_section_tables_view: (section_id)->
|
||||||
$.get(data_host + '/supplier/sections/'+section_id+'/tables_view.json', (res)->
|
$.get(data_host + '/supplier/sections/'+section_id+'/tables_view.json', (res)->
|
||||||
for table in res.tables
|
for table in res.tables
|
||||||
@@ -181,3 +157,10 @@ root.Qsupplier=
|
|||||||
return alert('Please fill in a positive number representing the number of tables per column') unless by_column_count && by_column_count > 0
|
return alert('Please fill in a positive number representing the number of tables per column') unless by_column_count && by_column_count > 0
|
||||||
$.post('/supplier/sections/'+current_section_id+'/arrange_tables', {option: option, row_count: by_row_count, column_count: by_column_count}, -> window.location.reload())
|
$.post('/supplier/sections/'+current_section_id+'/arrange_tables', {option: option, row_count: by_row_count, column_count: by_column_count}, -> window.location.reload())
|
||||||
false
|
false
|
||||||
|
mustache: (selector, locals)->
|
||||||
|
locs = $.extend(locals,
|
||||||
|
currency: ->
|
||||||
|
(val)->
|
||||||
|
currency(Mustache.render(val, this))
|
||||||
|
)
|
||||||
|
Mustache.to_html($(selector).html(), locs)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
//= require twitter/bootstrap/bootstrap-typeahead
|
//= require twitter/bootstrap/bootstrap-typeahead
|
||||||
//= require twitter/bootstrap/bootstrap-affix
|
//= require twitter/bootstrap/bootstrap-affix
|
||||||
//= require qwaiter
|
//= require qwaiter
|
||||||
|
//= require supplier/order
|
||||||
//= require mustache
|
//= require mustache
|
||||||
//= require_directory .
|
//= require_directory .
|
||||||
//= require_self
|
//= require_self
|
||||||
|
|||||||
@@ -11,11 +11,19 @@ class Quser
|
|||||||
formatted
|
formatted
|
||||||
watch_events: ->
|
watch_events: ->
|
||||||
faye = new Faye.Client('http://localhost:9292/faye')
|
faye = new Faye.Client('http://localhost:9292/faye')
|
||||||
faye.subscribe "/user/"+QMobile.user_id(), (e)->
|
faye.subscribe "/user/"+QMobile.user_id(), (e)=>
|
||||||
debugger
|
|
||||||
if(e.event == 'list_closed')
|
if(e.event == 'list_closed')
|
||||||
redirect_to 'user_root', {list_closed: 'true'}
|
#redirect_to 'user_root', {list_closed: 'true'}
|
||||||
console.log(data)
|
redirect_to 'history_list', {list_id: e.data.id, list_closed: true}
|
||||||
|
if(e.event == 'list_helped')
|
||||||
|
window.active_list.needs_help = false
|
||||||
|
@list_needs_help_default_action()
|
||||||
|
if(e.event == 'order_being_processed')
|
||||||
|
$('#order-row-'+e.data.id).addClass('active')
|
||||||
|
if(e.event == 'order_being_delivered')
|
||||||
|
$('#order-row-'+e.data.id).addClass('delivered')
|
||||||
|
console.log(e)
|
||||||
|
false
|
||||||
home_loader: ->
|
home_loader: ->
|
||||||
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) => @handle_active_list_default_actions(res))
|
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) => @handle_active_list_default_actions(res))
|
||||||
handle_active_list: (callback) ->
|
handle_active_list: (callback) ->
|
||||||
@@ -34,14 +42,12 @@ class Quser
|
|||||||
if(response.ok == false && response.status && response.status == 401)
|
if(response.ok == false && response.status && response.status == 401)
|
||||||
direct_to_site('obtain_user_token')
|
direct_to_site('obtain_user_token')
|
||||||
return
|
return
|
||||||
if response.table_number
|
|
||||||
$('.table-number').text(response.table_number)
|
$('.table-number').text(response.table_number) if response.table_number
|
||||||
if response.supplier_name
|
$('.supplier-name').text(response.supplier_name) if response.supplier_name
|
||||||
$('.supplier-name').text(response.supplier_name)
|
|
||||||
if response.not_present
|
if response.not_present || response.list_active == false then $('.home-link').hide() else $('.home-link').show()
|
||||||
$('.home-link').hide()
|
|
||||||
else
|
|
||||||
$('.home-link').show()
|
|
||||||
@list_needs_payment_default_action(response)
|
@list_needs_payment_default_action(response)
|
||||||
@list_needs_help_default_action(response)
|
@list_needs_help_default_action(response)
|
||||||
# join_request_active is to ensure that there are no more modals loaded when one is still active
|
# join_request_active is to ensure that there are no more modals loaded when one is still active
|
||||||
@@ -126,9 +132,9 @@ class Quser
|
|||||||
$.post(data_host + '/user/list_needs_payment.json', authentication_object, (res) => window.active_list = res; window.Quser.list_needs_payment_default_action(res))
|
$.post(data_host + '/user/list_needs_payment.json', authentication_object, (res) => window.active_list = res; window.Quser.list_needs_payment_default_action(res))
|
||||||
load_active_list: () ->
|
load_active_list: () ->
|
||||||
$.getJSON(data_host + '/user/active_list.json?'+authentication_string, (res) =>
|
$.getJSON(data_host + '/user/active_list.json?'+authentication_string, (res) =>
|
||||||
window.active_list = res
|
window.active_list = res if res._id
|
||||||
unless res.list_active
|
unless res.list_active
|
||||||
redirect_to 'history_list', {list_id: res._id, list_closed: true}
|
redirect_to 'history_list', {list_id: window.active_list._id, list_closed: true}
|
||||||
return
|
return
|
||||||
@handle_active_list_default_actions(res)
|
@handle_active_list_default_actions(res)
|
||||||
body = $('#active-list-table tbody')
|
body = $('#active-list-table tbody')
|
||||||
@@ -146,6 +152,7 @@ class Quser
|
|||||||
foot = $('#history-list-table tfoot')
|
foot = $('#history-list-table tfoot')
|
||||||
@build_list_table(body, foot, res)
|
@build_list_table(body, foot, res)
|
||||||
$('.list-created-at').text(@format_date(res.created_at))
|
$('.list-created-at').text(@format_date(res.created_at))
|
||||||
|
$('.list-closed-at').text(@format_date(res.closed_at))
|
||||||
$('.supplier-name').text(res.supplier_name)
|
$('.supplier-name').text(res.supplier_name)
|
||||||
)
|
)
|
||||||
load_list_history: ->
|
load_list_history: ->
|
||||||
@@ -196,12 +203,7 @@ class Quser
|
|||||||
alert('No orders in list')
|
alert('No orders in list')
|
||||||
return
|
return
|
||||||
m_obj = res
|
m_obj = res
|
||||||
for order in m_obj.orders
|
body.append @mustache('#active-list-order-template', new Order(order)) for order in m_obj.orders
|
||||||
order_txts = []
|
|
||||||
for product in order.products
|
|
||||||
order_txts.push(product.name + ' (' + product['number'] + ')')
|
|
||||||
order.products_display = order_txts.join(', ')
|
|
||||||
body.append @mustache('#active-list-orders-template', m_obj)
|
|
||||||
foot.append @mustache('#active-list-orders-footer-template', m_obj)
|
foot.append @mustache('#active-list-orders-footer-template', m_obj)
|
||||||
|
|
||||||
order_selected_products: ()->
|
order_selected_products: ()->
|
||||||
@@ -211,7 +213,6 @@ class Quser
|
|||||||
h['table_id'] = match[1] if match
|
h['table_id'] = match[1] if match
|
||||||
for product_id, number of window.active_products_list
|
for product_id, number of window.active_products_list
|
||||||
h['products['+product_id+']'] = number
|
h['products['+product_id+']'] = number
|
||||||
debugger
|
|
||||||
$.post(data_host + '/user/order_selected_products', $.extend(h, authentication_object), ((res) => @handle_response(res)), 'json')
|
$.post(data_host + '/user/order_selected_products', $.extend(h, authentication_object), ((res) => @handle_response(res)), 'json')
|
||||||
handle_response: (res) ->
|
handle_response: (res) ->
|
||||||
if(typeof(res) == 'string')
|
if(typeof(res) == 'string')
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
.list-status
|
||||||
|
.list-needs-help-indicator
|
||||||
|
display: inline-block
|
||||||
|
width: 30px
|
||||||
|
color: #400
|
||||||
|
background-color: #aaf
|
||||||
|
text-align: center
|
||||||
|
margin-right: 7px
|
||||||
|
&.hide
|
||||||
|
display: none
|
||||||
|
.list-needs-payment-indicator
|
||||||
|
display: inline-block
|
||||||
|
width: 30px
|
||||||
|
color: #440
|
||||||
|
background-color: #faa
|
||||||
|
text-align: center
|
||||||
|
margin-right: 7px
|
||||||
|
&.hide
|
||||||
|
display: none
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
*= require 'twitter-bootstrap/bootstrap_overrides'
|
*= require 'twitter-bootstrap/bootstrap_overrides'
|
||||||
*= require 'jquery-ui-1.8.23.custom.css'
|
*= require 'jquery-ui-1.8.23.custom.css'
|
||||||
*= require 'general'
|
*= require 'general'
|
||||||
|
*= require user/active_list
|
||||||
*= require_directory .
|
*= require_directory .
|
||||||
*= require_self
|
*= require_self
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#active-list-table
|
.list-table, #active-list-table
|
||||||
tbody
|
tbody
|
||||||
tr
|
tr
|
||||||
td
|
td
|
||||||
|
|||||||
@@ -7,6 +7,16 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def broadcast_user(uid, event, data = {})
|
||||||
|
message = {channel: "/user/#{uid}", data: {event: event, data: data}}
|
||||||
|
uri = URI.parse("http://localhost:9292/faye")
|
||||||
|
Net::HTTP.post_form(uri, :message => message.to_json)
|
||||||
|
end
|
||||||
|
def broadcast_supplier(sid, event, data = {})
|
||||||
|
message = {channel: "/supplier/#{sid}", data: {event: event, data: data}}
|
||||||
|
uri = URI.parse("http://localhost:9292/faye")
|
||||||
|
Net::HTTP.post_form(uri, :message => message.to_json)
|
||||||
|
end
|
||||||
def set_locale
|
def set_locale
|
||||||
I18n.locale = :nl
|
I18n.locale = :nl
|
||||||
end
|
end
|
||||||
@@ -14,7 +24,7 @@ class ApplicationController < ActionController::Base
|
|||||||
def layout_by_resource
|
def layout_by_resource
|
||||||
if devise_controller?
|
if devise_controller?
|
||||||
case session[:user_return_to]
|
case session[:user_return_to]
|
||||||
when /\/user\// then ''
|
when /\/user\// then 'obtain_token'
|
||||||
when /obtain_token/ then 'obtain_token'
|
when /obtain_token/ then 'obtain_token'
|
||||||
else 'theme1'
|
else 'theme1'
|
||||||
end
|
end
|
||||||
@@ -50,9 +60,4 @@ class ApplicationController < ActionController::Base
|
|||||||
{ok: true, message: message}.merge(options).to_json
|
{ok: true, message: message}.merge(options).to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcast_user(uid, event, data = {})
|
|
||||||
message = {channel: channel, data: {event: event, data: data}}
|
|
||||||
uri = URI.parse("http://localhost:9292/faye")
|
|
||||||
Net::HTTP.post_form(uri, :message => message.to_json)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class DashboardController < ApplicationController
|
|||||||
|
|
||||||
# Testing action
|
# Testing action
|
||||||
def select_qrcode
|
def select_qrcode
|
||||||
@tables = Table.all
|
@tables = Table.all.sample(2)
|
||||||
render layout: 'phone'
|
render layout: 'phone'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,8 @@ class SupplierController < ApplicationController
|
|||||||
h[:lists] = []
|
h[:lists] = []
|
||||||
grand_total = 0.0
|
grand_total = 0.0
|
||||||
for list in @supplier.active_lists(section_id: params[:section_id].presence)
|
for list in @supplier.active_lists(section_id: params[:section_id].presence)
|
||||||
hl = list.as_json
|
hl = list.with_info_as_json
|
||||||
hl[:total_amount] = list.orders.inject(0.0){|sum, o| sum + o.product_orders.inject(0.0){|s, po| s + (po.amount * po.price).round(2)}}.round(2)
|
|
||||||
grand_total += hl[:total_amount]
|
grand_total += hl[:total_amount]
|
||||||
hl[:section_title] = list.table.section.try(:title)
|
|
||||||
h[:lists] << hl
|
h[:lists] << hl
|
||||||
end
|
end
|
||||||
h[:total_amount] = grand_total.round(2)
|
h[:total_amount] = grand_total.round(2)
|
||||||
@@ -87,17 +85,13 @@ class SupplierController < ApplicationController
|
|||||||
def close_list
|
def close_list
|
||||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
||||||
@list.close!
|
@list.close!
|
||||||
for user_id in @list.user_ids
|
|
||||||
broadcast_user user_id, 'list_closed', @list
|
|
||||||
end
|
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /orders/1/is_helped
|
# POST /orders/1/is_helped
|
||||||
def mark_list_as_helped
|
def mark_list_as_helped
|
||||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
||||||
@list.needs_help = false
|
@list.is_helped!
|
||||||
@list.save
|
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,27 @@ class UserController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def list_products_for_table
|
||||||
|
@table = Table.find(params[:table_id])
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
|
end
|
||||||
|
format.json do
|
||||||
|
products = @table.supplier.products
|
||||||
|
products.include_relation(:product_categories)
|
||||||
|
products.sort_by!{|p| p.product_category.try(:position) || 90000}
|
||||||
|
h = products.inject({
|
||||||
|
table_number: @table.number,
|
||||||
|
supplier_name: @table.supplier.name,
|
||||||
|
has_occupied_info: true,
|
||||||
|
is_occupied: @table.occupied?
|
||||||
|
}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
|
||||||
|
render json: h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def join_occupied_table
|
def join_occupied_table
|
||||||
@table = Table.find(params[:table_id])
|
@table = Table.find(params[:table_id])
|
||||||
end
|
end
|
||||||
@@ -149,26 +170,6 @@ class UserController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_products_for_table
|
|
||||||
@table = Table.find(params[:table_id])
|
|
||||||
respond_to do |format|
|
|
||||||
format.html do
|
|
||||||
end
|
|
||||||
format.json do
|
|
||||||
products = @table.supplier.products
|
|
||||||
products.include_relation(:product_categories)
|
|
||||||
products.sort_by!{|p| p.product_category.try(:position) || 90000}
|
|
||||||
h = products.inject({
|
|
||||||
table_number: @table.number,
|
|
||||||
supplier_name: @table.supplier.name,
|
|
||||||
has_occupied_info: true,
|
|
||||||
is_occupied: @table.occupied?
|
|
||||||
}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
|
|
||||||
render json: h
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /user/current_list.json
|
# GET /user/current_list.json
|
||||||
# Information about the currently active list
|
# Information about the currently active list
|
||||||
# This information includes detailed order information
|
# This information includes detailed order information
|
||||||
@@ -214,6 +215,7 @@ class UserController < ApplicationController
|
|||||||
render json: {list_active: false} and return unless list.present?
|
render json: {list_active: false} and return unless list.present?
|
||||||
list.needs_help = true
|
list.needs_help = true
|
||||||
list.save
|
list.save
|
||||||
|
broadcast_supplier(list.supplier_id, 'list_needs_help', id: list.id)
|
||||||
render json: list.as_json.merge(list_active: list.active?)
|
render json: list.as_json.merge(list_active: list.active?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -224,8 +226,7 @@ class UserController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
render json: {list_active: false} and return unless list.present?
|
render json: {list_active: false} and return unless list.present?
|
||||||
list.needs_payment = true
|
list.needs_payment!
|
||||||
list.save
|
|
||||||
render json: list.as_json.merge(list_active: list.active?)
|
render json: list.as_json.merge(list_active: list.active?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+46
-6
@@ -60,6 +60,7 @@ class List
|
|||||||
list.save
|
list.save
|
||||||
user.active_list_id = list.id
|
user.active_list_id = list.id
|
||||||
user.save
|
user.save
|
||||||
|
#list.broadcast_supplier list.supplier_id, 'list_added', list.with_info_as_json
|
||||||
list
|
list
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -95,7 +96,34 @@ class List
|
|||||||
orders.map(&:close!)
|
orders.map(&:close!)
|
||||||
self.state = 'closed'
|
self.state = 'closed'
|
||||||
self.closed_at = Time.now
|
self.closed_at = Time.now
|
||||||
save
|
if save
|
||||||
|
for user in users
|
||||||
|
user.active_list_id = nil
|
||||||
|
user.save
|
||||||
|
broadcast_user user.id, 'list_closed', id: id
|
||||||
|
end
|
||||||
|
broadcast_supplier supplier_id, 'list_closed', id: id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_helped!
|
||||||
|
self.needs_help = false
|
||||||
|
if save
|
||||||
|
for user_id in user_ids
|
||||||
|
broadcast_user user_id, 'list_helped', id: id
|
||||||
|
end
|
||||||
|
broadcast_supplier supplier_id, 'list_helped', id: id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def needs_payment!
|
||||||
|
self.needs_payment = true
|
||||||
|
if save
|
||||||
|
for user_id in user_ids
|
||||||
|
broadcast_user user_id, 'list_needs_payment', id: id
|
||||||
|
end
|
||||||
|
broadcast_supplier supplier_id, 'list_needs_payment', id: id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_price
|
def set_price
|
||||||
@@ -121,15 +149,17 @@ class List
|
|||||||
def place_order(user, products)
|
def place_order(user, products)
|
||||||
return false unless products.any?
|
return false unless products.any?
|
||||||
return false unless user
|
return false unless user
|
||||||
@order = Order.create list: self, supplier: supplier, user: user, section_id: section_id
|
order = Order.create list: self, supplier: supplier, user: user, section_id: section_id
|
||||||
return unless @order.id
|
return unless order.id
|
||||||
loaded_products = self.class.database.load_document products.keys
|
loaded_products = self.class.database.load_document products.keys
|
||||||
products.each do |product_id, number|
|
products.each do |product_id, number|
|
||||||
number = number.to_i
|
number = number.to_i
|
||||||
product = loaded_products.find{|p| p.id == product_id} # to get the price
|
product = loaded_products.find{|p| p.id == product_id} # to get the price
|
||||||
ProductOrder.create order: @order, product_id: product_id, amount: number, price: product.price if number > 0
|
ProductOrder.create order: order, product_id: product_id, amount: number, price: product.price if number > 0
|
||||||
end
|
end
|
||||||
@order
|
broadcast_supplier supplier.id, 'new_order', order.with_products_as_json
|
||||||
|
broadcast_supplier supplier.id, 'list_update', with_info_as_json
|
||||||
|
order
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_to_table to_table
|
def move_to_table to_table
|
||||||
@@ -139,7 +169,7 @@ class List
|
|||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json
|
def as_json(*args)
|
||||||
super.merge(table_number: table_number)
|
super.merge(table_number: table_number)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -152,6 +182,8 @@ class List
|
|||||||
list_total = 0.0
|
list_total = 0.0
|
||||||
for order in orders
|
for order in orders
|
||||||
ho = {products: []}
|
ho = {products: []}
|
||||||
|
ho[:id] = order.id
|
||||||
|
ho[:state] = order.state
|
||||||
order_total = 0.0
|
order_total = 0.0
|
||||||
for product_order in order.product_orders
|
for product_order in order.product_orders
|
||||||
order_total += (product_order.amount * product_order.price).round(2)
|
order_total += (product_order.amount * product_order.price).round(2)
|
||||||
@@ -184,4 +216,12 @@ class List
|
|||||||
end
|
end
|
||||||
@join_requests_as_json = h
|
@join_requests_as_json = h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def with_info_as_json
|
||||||
|
return @with_info_as_json if @with_info_as_json.present?
|
||||||
|
hl = as_json
|
||||||
|
hl[:total_amount] = orders.inject(0.0){|sum, o| sum + o.product_orders.inject(0.0){|s, po| s + (po.amount * po.price).round(2)}}.round(2)
|
||||||
|
hl[:section_title] = table.section.try(:title)
|
||||||
|
@with_info_as_json = hl
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+33
-2
@@ -50,16 +50,47 @@ class Order
|
|||||||
|
|
||||||
def is_being_processed!
|
def is_being_processed!
|
||||||
self.state = 'active'
|
self.state = 'active'
|
||||||
save
|
if save
|
||||||
|
for user_id in list.user_ids
|
||||||
|
broadcast_user user_id, 'order_being_processed', id: id
|
||||||
|
end
|
||||||
|
broadcast_supplier supplier_id, 'order_being_processed', id: id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_delivered!
|
def is_delivered!
|
||||||
self.state = 'delivered'
|
self.state = 'delivered'
|
||||||
save
|
if save
|
||||||
|
for user_id in list.user_ids
|
||||||
|
broadcast_user user_id, 'order_being_delivered', id: id
|
||||||
|
end
|
||||||
|
broadcast_supplier supplier_id, 'order_being_delivered', id: id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def close!
|
def close!
|
||||||
self.state = 'closed' if placed? || active?
|
self.state = 'closed' if placed? || active?
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_json(*args)
|
||||||
|
h = super.with_indifferent_access
|
||||||
|
h[:table_number] = table_number
|
||||||
|
h[:section_title] = list.table.section.try(:title)
|
||||||
|
h
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_products_as_json
|
||||||
|
return @with_products_as_json if @with_products_as_json.present?
|
||||||
|
product_orders.include_relation(:product)
|
||||||
|
ho = as_json
|
||||||
|
ho[:products] = []
|
||||||
|
order_total = 0.0
|
||||||
|
for product_order in product_orders
|
||||||
|
order_total += (product_order.amount * product_order.price).round(2)
|
||||||
|
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.price}
|
||||||
|
end
|
||||||
|
ho[:total_amount] = order_total.round(2)
|
||||||
|
@with_products_as_json = ho
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<tr id="list-row-{{id}}">
|
||||||
|
<td class="list-status">
|
||||||
|
<span id="list-needs-help-indicator-{{id}}" class="list-needs-help-indicator {{^needs_help}}hide{{/needs_help}}">?</span>
|
||||||
|
<span id="list-needs-payment-indicator-{{id}}" class="list-needs-payment-indicator {{^needs_payment}}hide{{/needs_payment}}">€</span>
|
||||||
|
</td>
|
||||||
|
<td class="numeric"><a href="/supplier/lists/{{id}}">{{table_number}}</a></td>
|
||||||
|
<td>{{section_title}}</td>
|
||||||
|
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</td>
|
||||||
|
<td class="actions">
|
||||||
|
<button id="list-is-helped-button-{{id}}" class="btn btn-info {{^needs_help}}hide{{/needs_help}}" onclick="Qsupplier.mark_list_as_helped('{{id}}')">Question answered!</button>
|
||||||
|
<button class="btn btn-warning" onclick="Qsupplier.close_list('{{id}}')">Close!</button>
|
||||||
|
<a href="/supplier/lists/{{id}}" class="btn icon-list"></a>
|
||||||
|
</td>
|
||||||
|
<tr>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<tr id="order-row-{{id}}" class="of-list-{{list_id}}">
|
||||||
|
<td>{{display}}</td>
|
||||||
|
<td class="numeric">{{table_number}}</td>
|
||||||
|
<td>{{section_title}}</td>
|
||||||
|
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</td>
|
||||||
|
<td class="actions">
|
||||||
|
<button id="order-in-process-button-{{id}}" class="btn btn-success {{^can_process}}hide{{/can_process}}" onclick="Qsupplier.mark_order_in_process('{{id}}')">In process!</button>
|
||||||
|
<button class="btn btn-inverse" onclick="Qsupplier.mark_order_delivered('{{id}}')">Is delivered!</button>
|
||||||
|
</td>
|
||||||
|
<tr>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<tr id="order-row-{{id}}" class="{{state}}">
|
||||||
|
<td>{{display}}</td>
|
||||||
|
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</td>
|
||||||
|
</tr>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<tr id="order-row-{{id}}" class="{{state}}">
|
||||||
|
<td>{{display}}</td>
|
||||||
|
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</td>
|
||||||
|
</tr>
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{{#orders}}
|
|
||||||
<tr class="{{state}}">
|
|
||||||
<td>{{products_display}}</td>
|
|
||||||
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</td>
|
|
||||||
</tr>
|
|
||||||
{{/orders}}
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<button class="btn btn-primary" onClick="Quser.handle_active_list(function(){Quser.order_selected_products()})" data-t="selected_products.order"></button>
|
<button class="btn btn-primary" onClick="Quser.order_selected_products()" data-t="selected_products.order"></button>
|
||||||
<button class="btn btn btn-warning" onClick="Quser.clear_selected_products()" data-t="selected_products.clear"></button>
|
<button class="btn btn btn-warning" onClick="Quser.clear_selected_products()" data-t="selected_products.clear"></button>
|
||||||
</td>
|
</td>
|
||||||
<td class="currency"><strong id="active-order-total">{{#currency}}{{total}}{{/currency}}</strong></td>
|
<td class="currency"><strong id="active-order-total">{{#currency}}{{total}}{{/currency}}</strong></td>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ html lang="en"
|
|||||||
link href="/favicon.ico" rel="shortcut icon"
|
link href="/favicon.ico" rel="shortcut icon"
|
||||||
javascript:
|
javascript:
|
||||||
var data_host = '#{Rails.env == 'development' ? 'http://qwaiter.dev' : 'http://data.qwaiter.com' }';
|
var data_host = '#{Rails.env == 'development' ? 'http://qwaiter.dev' : 'http://data.qwaiter.com' }';
|
||||||
//var data_host = 'http://localhost:3000';
|
var data_host = 'http://localhost:3000';
|
||||||
//data_host = 'http://192.168.1.148:3000';
|
//data_host = 'http://192.168.1.148:3000';
|
||||||
var $locale = 'en';
|
var $locale = 'en';
|
||||||
var $url_vars = null;
|
var $url_vars = null;
|
||||||
|
|||||||
@@ -11,11 +11,17 @@ html lang="en"
|
|||||||
/[if lt IE 9]
|
/[if lt IE 9]
|
||||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||||
= stylesheet_link_tag "supplier/application", :media => "all"
|
= stylesheet_link_tag "supplier/application", :media => "all"
|
||||||
|
= javascript_include_tag 'http://localhost:9292/faye.js'
|
||||||
link href="/images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
link href="/images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
||||||
link href="/images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
link href="/images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
||||||
link href="/images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
link href="/images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
||||||
link href="/images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
|
link href="/images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
|
||||||
link href="/favicon.ico" rel="shortcut icon"
|
link href="/favicon.ico" rel="shortcut icon"
|
||||||
|
|
||||||
|
javascript:
|
||||||
|
var supplier_id = '#{current_supplier.id}';
|
||||||
|
var data_host = ''
|
||||||
|
|
||||||
= yield :head
|
= yield :head
|
||||||
|
|
||||||
body
|
body
|
||||||
|
|||||||
@@ -10,11 +10,5 @@
|
|||||||
th.currency= t('supplier.active_lists.price')
|
th.currency= t('supplier.active_lists.price')
|
||||||
th.actions
|
th.actions
|
||||||
tbody
|
tbody
|
||||||
- content_for :footer do
|
script#active-list-template[type="text/html"]= render 'active_list.mustache'
|
||||||
javascript:
|
|
||||||
var active_lists_interval;
|
|
||||||
jQuery(function(){
|
|
||||||
Qsupplier.load_active_lists()
|
|
||||||
active_lists_interval = setInterval('Qsupplier.load_active_lists()', 7500);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,4 @@
|
|||||||
th.currency= t('supplier.active_orders.price')
|
th.currency= t('supplier.active_orders.price')
|
||||||
th.actions
|
th.actions
|
||||||
tbody
|
tbody
|
||||||
- content_for :footer do
|
script#active-order-template[type="text/html"]= render 'active_order.mustache'
|
||||||
javascript:
|
|
||||||
jQuery(function(){
|
|
||||||
Qsupplier.load_active_orders()
|
|
||||||
setInterval( 'Qsupplier.load_active_orders()', 7500);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,4 +17,7 @@
|
|||||||
linker.hide();
|
linker.hide();
|
||||||
}
|
}
|
||||||
}).change();
|
}).change();
|
||||||
|
Qsupplier.load_active_orders()
|
||||||
|
Qsupplier.load_active_lists()
|
||||||
|
Qsupplier.watch_events();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ dl.dl-horizontal
|
|||||||
dt= List.human_attribute_name(:created_at)
|
dt= List.human_attribute_name(:created_at)
|
||||||
dd= l @list.created_at, format: :short
|
dd= l @list.created_at, format: :short
|
||||||
.well
|
.well
|
||||||
table#list-table.table
|
table#list-table.table.list-table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th= Order.model_name.human
|
th= Order.model_name.human
|
||||||
@@ -12,6 +12,11 @@ dl.dl-horizontal
|
|||||||
tr
|
tr
|
||||||
td colspan=2 = slider_image
|
td colspan=2 = slider_image
|
||||||
tfoot
|
tfoot
|
||||||
|
tr
|
||||||
|
td
|
||||||
|
td.currency
|
||||||
|
strong.list-total
|
||||||
|
script#list-order-template[type="text/html"]= render 'supplier/list_order.mustache'
|
||||||
.form-actions
|
.form-actions
|
||||||
= link_to t("helpers.links.back"), suppliers_lists_path(date: @list.created_at.strftime('%Y-%m-%d')), class: 'btn'
|
= link_to t("helpers.links.back"), suppliers_lists_path(date: @list.created_at.strftime('%Y-%m-%d')), class: 'btn'
|
||||||
'
|
'
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
tr
|
tr
|
||||||
td colspan=2 = slider_image
|
td colspan=2 = slider_image
|
||||||
tfoot
|
tfoot
|
||||||
script#active-list-orders-template[type="text/html"]= render 'active_list_orders.mustache'
|
script#active-list-order-template[type="text/html"]= render 'active_list_order.mustache'
|
||||||
script#active-list-orders-footer-template[type="text/html"]= render 'active_list_orders_footer.mustache'
|
script#active-list-orders-footer-template[type="text/html"]= render 'active_list_orders_footer.mustache'
|
||||||
- content_for :footer do
|
- content_for :footer do
|
||||||
javascript:
|
javascript:
|
||||||
jQuery(function(){
|
jQuery(function(){
|
||||||
Quser.load_active_list();
|
Quser.load_active_list();
|
||||||
setInterval( "Quser.load_active_list()", 7500);
|
Quser.watch_events();
|
||||||
|
//setInterval( "Quser.load_active_list()", 7500);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
dl.dl-horizontal
|
dl.dl-horizontal
|
||||||
dt= List.human_attribute_name(:created_at)
|
dt= List.human_attribute_name(:created_at)
|
||||||
dd.list-created-at
|
dd.list-created-at
|
||||||
|
dt= List.human_attribute_name(:closed_at)
|
||||||
|
dd.list-closed-at
|
||||||
dt= Supplier.model_name.human
|
dt= Supplier.model_name.human
|
||||||
dd.supplier-name
|
dd.supplier-name
|
||||||
.well
|
.well
|
||||||
table#history-list-table.table
|
table#history-list-table.table.list-table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th= Order.model_name.human
|
th= Order.model_name.human
|
||||||
@@ -14,7 +16,7 @@ dl.dl-horizontal
|
|||||||
tr
|
tr
|
||||||
td colspan=2 = slider_image
|
td colspan=2 = slider_image
|
||||||
tfoot
|
tfoot
|
||||||
script#active-list-orders-template[type="text/html"]= render 'active_list_orders.mustache'
|
script#active-list-order-template[type="text/html"]= render 'active_list_order.mustache'
|
||||||
script#active-list-orders-footer-template[type="text/html"]= render 'active_list_orders_footer.mustache'
|
script#active-list-orders-footer-template[type="text/html"]= render 'active_list_orders_footer.mustache'
|
||||||
- content_for :footer do
|
- content_for :footer do
|
||||||
javascript:
|
javascript:
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ script#active-order-template[type="text/html"]= render 'active_order.mustache'
|
|||||||
jQuery(function(){
|
jQuery(function(){
|
||||||
Quser.handle_active_list(function(){
|
Quser.handle_active_list(function(){
|
||||||
Quser.load_active_list_products();
|
Quser.load_active_list_products();
|
||||||
setInterval('Quser.handle_active_list()', 7500);
|
Quser.watch_events();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
require 'simply_stored/couch'
|
||||||
|
module ModelBroadcast
|
||||||
|
def broadcast_supplier(*args)
|
||||||
|
ApplicationController.new.send(:broadcast_supplier, *args)
|
||||||
|
end
|
||||||
|
def broadcast_user(*args)
|
||||||
|
ApplicationController.new.send(:broadcast_user, *args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
SimplyStored::Couch.send(:include, ModelBroadcast)
|
||||||
|
SimplyStored::Couch.send(:extend, ModelBroadcast)
|
||||||
Reference in New Issue
Block a user