bug fixes

This commit is contained in:
2012-12-11 13:45:47 +01:00
parent 009b84f7cd
commit 7a048125d1
11 changed files with 106 additions and 90 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

+9 -1
View File
@@ -8,6 +8,7 @@ window.Qwaiter=
content = options.content || 'Are you sure?'
title = options.title || 'Confirm'
wrapper = $('<div class="modal"></div>')
if typeof(options.ok) == 'function'
callback_wrapper = ->
wrapper.modal('hide')
options.ok()
@@ -18,9 +19,16 @@ window.Qwaiter=
.append('<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>')
.append('<h3>'+title+'</h3>').appendTo(wrapper)
body = $('<div class="modal-body"></div>').append('<p>'+content+'</p>').appendTo(wrapper)
ok_button = $('<a href="#" class="btn btn-primary">Yes</a>')
if typeof(options.ok) == 'function'
ok_button.click(callback_wrapper)
else
ok_button.click ->
eval(options.ok)
wrapper.modal('hide')
footer = $('<div class="modal-footer"></div>')
.append($('<a href="#" class="btn">Close</a>').click(callback_cancel_wrapper))
.append($('<a href="#" class="btn btn-primary">Yes</a>').click(callback_wrapper))
.append(ok_button)
.appendTo(wrapper)
wrapper.modal()
currency: (num) ->
@@ -28,6 +28,7 @@ root.Qsupplier=
$('#list-is-helped-button-'+list_id).addClass('hide')
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()
else if e.event == 'list_changed_table'
@@ -114,7 +115,7 @@ root.Qsupplier=
load_active_orders: () ->
$.get('/supplier/active_orders.json?section_id='+($('#current_section_selector').val() || ''), (res) =>
body = $('#active-orders-table tbody')
body.find('tr').remove()
body.html('')
foot = $('#active-orders-table tfoot')
if(!res.orders && !res.orders.length)
alert('No orders in list')
+26 -39
View File
@@ -10,7 +10,10 @@ class Quser
watch_events: ->
faye = new Faye.Client(event_host)
user_id = Qstorage.getItem('user_id')
return unless user_id && user_id.length > 0
unless user_id
@reset_user()
redirect_to 'obtain_token'
return false
faye.subscribe "/user/"+user_id, (e)=>
if(e.event == 'list_closed')
#redirect_to 'user_root', {list_closed: 'true'}
@@ -41,6 +44,8 @@ class Quser
$('.list-total-amount').html(currency(e.data.total_amount))
console.log(e)
false
ensure_json: (res)->
if typeof(res) == 'string' then JSON.parse(res) else res
reset_user: ->
Qstorage.removeItem('auth_token')
Qstorage.removeItem('user_id')
@@ -51,6 +56,7 @@ class Quser
return email.focus() unless email.val() && email.val().length > 0
return password.focus() unless password.val() && password.val().length > 0
$.post(data_host + '/user/obtain_token.json', {"user[email]": email.val(), "user[password]": password.val()}, (res)=>
res = @ensure_json(res)
if res.auth_token
Qstorage.setItem('auth_token', res.auth_token)
Qstorage.setItem('user_id', res.user_id)
@@ -111,37 +117,18 @@ class Quser
)).modal()
false
approve_join_request: (user_id)->
$.post(data_host + '/user/approve_join_request', $.extend({user_id: user_id}, authentication_object), -> window.join_request_active = false)
@ensure_token =>
$.post(data_host + '/user/approve_join_request', $.extend({user_id: user_id}, @authentication_object), -> window.join_request_active = false)
reject_join_request: (user_id)->
$.post(data_host + '/user/reject_join_request', $.extend({user_id: user_id}, authentication_object), -> window.join_request_active = false)
bogus1: ->
wrapper = $('<div class="modal"></div>')
join_callback = ( (request)->
->
$.post(data_host + '/user/approve_join_request', $.extend({user_id: request.user_id}, authentication_object), -> window.join_request_active = false; wrapper.modal('hide') )
)(join_request)
reject_callback = ( (request)->
->
$.post(data_host + '/user/reject_join_request', $.extend({user_id: request.user_id}, authentication_object), -> window.join_request_active = false; wrapper.modal('hide' ))
)(join_request)
header = $('<div class="modal-header"></div>')
.append('<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>')
.append($('<h3></h3>').text(t('join_request.title'))).appendTo(wrapper)
body = $('<div class="modal-body"></div>')
#body.append(join_request.user_email + ' wants to join the table')
body.text(t('join_request.body', {email: join_request.user_email}))
body.appendTo(wrapper)
footer = $('<div class="modal-footer"></div>')
.append($('<a href="#" class="btn"></a>').text(t('join_request.reject')).click(reject_callback))
.append($('<a href="#" class="btn btn-primary"></a>').text(t('join_request.approve')).click(join_callback))
.appendTo(wrapper)
wrapper.modal()
@ensure_token =>
$.post(data_host + '/user/reject_join_request', $.extend({user_id: user_id}, @authentication_object), -> window.join_request_active = false)
list_needs_help: ->
return unless window.active_list && !window.active_list.needs_help
@ensure_token =>
$.post(data_host + '/user/needs_help.json', @authentication_object, (res) => window.active_list = @ensure_json(res); @list_needs_help_default_action())
list_needs_help_default_action: (response)=>
response ||= window.active_list
window.active_list = response
needs_help_container = $('#list-needs-help-button')
if needs_help_container.length
if response.needs_help
@@ -158,15 +145,17 @@ class Quser
Qwaiter.confirm(
title: t('list_needs_help.title')
content: t('list_needs_help.content')
ok: window.Quser.list_needs_help
ok: 'Quser.list_needs_help()'
)
)
needs_help_container.data('click-initialized', true)
list_needs_help: ->
return unless window.active_list && !window.active_list.needs_help
$.post(data_host + '/user/needs_help.json', authentication_object, (res) => window.active_list = res; window.Quser.list_needs_help_default_action(res))
list_needs_payment: ->
return unless window.active_list && !window.active_list.needs_payment
@ensure_token =>
$.post(data_host + '/user/list_needs_payment.json', @authentication_object, (res) => window.active_list = @ensure_json(res); @list_needs_payment_default_action())
list_needs_payment_default_action: (response)->
response ||= window.active_list
window.active_list = response
needs_payment_container = $('#list-needs-payment-button')
if needs_payment_container.length
if response.needs_payment
@@ -183,13 +172,10 @@ class Quser
Qwaiter.confirm(
title: t('list_needs_payment.title')
content: t('list_needs_payment.content')
ok: window.Quser.list_needs_payment
ok: 'Quser.list_needs_payment()'
)
)
needs_payment_container.data('click-initialized', true)
list_needs_payment: ->
return unless window.active_list && !window.active_list.needs_payment
$.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: () ->
@ensure_token =>
$.getJSON(data_host + '/user/active_list.json?'+@authentication_string, (res) =>
@@ -350,8 +336,9 @@ class Quser
@build_product_list()
false
actions_for_table: (table)->
table = JSON.parse(table) if typeof(table) == 'string'
Qstorage.table_id = table.table_id
table = @ensure_json(table)
Qstorage.setItem('table_id', table.table_id)
@ensure_token =>
$.getJSON(data_host + '/user/table_info.json?'+@authentication_string+'&table_id='+table.table_id, (res)=>
if res.current_table_id
if res.other_supplier
@@ -17,3 +17,19 @@
margin-right: 7px
&.hide
display: none
#active-orders-table
tbody
tr
td
&:first-child
padding-left: 35px
background-position: 5px center
background-repeat: no-repeat
&.active
td
&:first-child
background-image: image-url('icons/order-check.png')
&.delivered
td
&:first-child
background-image: image-url('icons/order-doublecheck.png')
@@ -104,7 +104,12 @@ body
#list-needs-payment-button
span
background-image: image-url('icons/needs-payment.png')
&.active
span
background-image: image-url('icons/needs-payment-active.png')
#list-needs-help-button
span
background-image: image-url('icons/needs-help.png')
&.active
span
background-image: image-url('icons/needs-help-active.png')
@@ -1,4 +1,4 @@
<tr id="order-row-{{id}}" class="of-list-{{list_id}}">
<tr id="order-row-{{id}}" class="of-list-{{list_id}} {{state}}">
<td>{{display}}</td>
<td class="numeric table_number">{{table_number}}</td>
<td class="section_title">{{section_title}}</td>
@@ -7,4 +7,4 @@
<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>
</tr>
+1
View File
@@ -147,6 +147,7 @@ en:
obtain_token:
title: Authenticate Qwaiter
obtain: Authenticate
invalid_combination: The email password combination is incorrect
section:
first_section_title: Room
manage_tables:
+1
View File
@@ -160,6 +160,7 @@ nl:
obtain_token:
title: Aanmelden bij Qwaiter
obtain: Aanmelden
invalid_combination: De inloggegevens zijn onjuist
section:
first_section_title: Ruimte
manage_tables:
+4 -7
View File
@@ -3,11 +3,11 @@ require "spec_helper"
describe UserController do
describe "routing" do
it "routes root to #home" do
get("/user").should route_to("user#home")
it "routes root to #index" do
get("/user").should route_to("user#index")
end
it "routes to #home" do
get("/user/home").should route_to("user#home")
it "routes to #index" do
get("/user/index").should route_to("user#index")
end
it "routes to #active_list" do
get("/user/active_list").should route_to("user#active_list")
@@ -38,9 +38,6 @@ describe UserController do
it "routes to #history_list" do
get("/user/history_list").should route_to("user#history_list")
end
it "routes to #home" do
get("/user/home").should route_to("user#home")
end
it "routes to #order_selected_products" do
post("/user/order_selected_products").should route_to("user#order_selected_products")
end