move towards mobile deployable app
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
//= require_directory .
|
||||
//= require_self
|
||||
var path_mapping = {
|
||||
user_root: '/user',
|
||||
user_root: '/user/home',
|
||||
join_occupied_table: '/user/join_occupied_table',
|
||||
list_products_for_table: '/user/list_products_for_table',
|
||||
list_products: '/user/list_products'
|
||||
@@ -67,7 +67,7 @@ function redirect_to(mapping, variables){
|
||||
for(var name in variables){
|
||||
vars.push(name + '=' +variables[name])
|
||||
}
|
||||
window.location = path_mapping[mapping] + '.html?' + vars.join('&')
|
||||
window.location = root_url + path_mapping[mapping] + '.html?' + vars.join('&')
|
||||
}
|
||||
function currency(num) {
|
||||
return Qwaiter.currency(num);
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
data_host = ''
|
||||
data_host = window.data_host
|
||||
root_url = window.root_url
|
||||
window.Quser=
|
||||
format_date: (utc) ->
|
||||
formatted = ''
|
||||
formatted += utc.substr(0,10)
|
||||
formatted += ' '
|
||||
formatted += utc.substr(11, 5)
|
||||
formatted
|
||||
home_loader: ->
|
||||
$.getJSON(data_host + '/user/list_info.json', (res) -> Quser.handle_active_list_default_actions(res))
|
||||
handle_active_list: (callback) ->
|
||||
$.get(data_host + '/user/list_info.json', (res) ->
|
||||
$.getJSON(data_host + '/user/list_info.json', (res) ->
|
||||
if !res.list_active
|
||||
redirect_to 'user_root', {list_closed: 'true'}
|
||||
return
|
||||
@@ -15,6 +24,10 @@ window.Quser=
|
||||
$('.table-number').text(response.table_number)
|
||||
if response.supplier_name
|
||||
$('.supplier-name').text(response.supplier_name)
|
||||
if response.not_present
|
||||
$('.home-link').hide()
|
||||
else
|
||||
$('.home-link').show()
|
||||
Quser.list_needs_payment_default_action(response)
|
||||
Quser.list_needs_help_default_action(response)
|
||||
# join_request_active is to ensure that there are no more modals loaded when one is still active
|
||||
@@ -98,10 +111,10 @@ window.Quser=
|
||||
return unless window.active_list && !window.active_list.needs_payment
|
||||
$.post(data_host + '/user/list_needs_payment.json', (res) -> window.active_list = res; Quser.list_needs_payment_default_action(res))
|
||||
load_active_list: () ->
|
||||
$.get(data_host + '/user/active_list.json', (res) ->
|
||||
$.getJSON(data_host + '/user/active_list.json', (res) ->
|
||||
window.active_list = res
|
||||
unless res.list_active
|
||||
window.location = '/user/list_history/'+res._id + '.html?list_closed=true'
|
||||
window.location = root_url + '/user/list_history/'+res._id + '.html?list_closed=true'
|
||||
return
|
||||
Quser.handle_active_list_default_actions(res)
|
||||
body = $('#active-list-table tbody')
|
||||
@@ -109,15 +122,17 @@ window.Quser=
|
||||
Quser.build_list_table(body, foot, res)
|
||||
)
|
||||
load_history_list: () ->
|
||||
match = window.document.URL.toString().match('([0-9a-zA-Z]+)(\\?|$)')
|
||||
match = window.document.URL.toString().match('([0-9a-zA-Z]+)(.html)?(\\?|$)')
|
||||
if match
|
||||
list_id = match[1]
|
||||
else
|
||||
return
|
||||
$.get(data_host + '/user/list_history/'+list_id+'.json', (res) ->
|
||||
$.getJSON(data_host + '/user/list_history/'+list_id+'.json', (res) ->
|
||||
body = $('#history-list-table tbody')
|
||||
foot = $('#history-list-table tfoot')
|
||||
Quser.build_list_table(body, foot, res)
|
||||
$('.list-created-at').text(Quser.format_date(res.created_at))
|
||||
$('.supplier-name').text(res.supplier_name)
|
||||
)
|
||||
load_list_history: ->
|
||||
match = window.document.URL.toString().match('page=([0-9]+)')
|
||||
@@ -125,7 +140,7 @@ window.Quser=
|
||||
page = match[1]
|
||||
else
|
||||
page = 1
|
||||
$.get(data_host + '/user/list_history.json?page='+page, (res) ->
|
||||
$.getJSON(data_host + '/user/list_history.json?page='+page, (res) ->
|
||||
Quser.paginate(res, '/user/list_history.html')
|
||||
container = $('#list-history-container')
|
||||
for list in res.lists
|
||||
@@ -134,9 +149,7 @@ window.Quser=
|
||||
link.attr('href', '/user/list_history/'+list._id + '.html')
|
||||
txt = list.supplier_name
|
||||
txt += ' - '
|
||||
txt += list.created_at.substr(0,10)
|
||||
txt += ' '
|
||||
txt += list.created_at.substr(11, 5)
|
||||
txt += Quser.format_date(list.created_at)
|
||||
link.text(txt)
|
||||
)
|
||||
paginate: (wrapper, src) ->
|
||||
@@ -222,7 +235,7 @@ window.Quser=
|
||||
return
|
||||
Quser.populate_products_table('/user/list_products_for_table.json?table_id='+table_id)
|
||||
populate_products_table: (src)->
|
||||
$.get(data_host + src, (res) ->
|
||||
$.getJSON(data_host + src, (res) ->
|
||||
if res.has_occupied_info
|
||||
include_order_buttons = !res.is_occupied
|
||||
delete(res['has_occupied_info'])
|
||||
@@ -272,7 +285,7 @@ window.Quser=
|
||||
)
|
||||
actions_for_table: (table)->
|
||||
table = JSON.parse(table) if typeof(table) == 'string'
|
||||
$.get(data_host + '/user/table_info.json?table_id='+table.table_id, (res)->
|
||||
$.getJSON(data_host + '/user/table_info.json?table_id='+table.table_id, (res)->
|
||||
if res.current_table_id
|
||||
if res.other_supplier
|
||||
redirect_to 'user_root', {message: 'table_is_from_other_supplier'}
|
||||
|
||||
@@ -19,6 +19,8 @@ $side-spacing: 5px
|
||||
text-indent: -5000px
|
||||
&.active
|
||||
background-color: $qbrown-active
|
||||
&.hide
|
||||
display: none
|
||||
|
||||
html
|
||||
background-image: $wood
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
class UserController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :allow_mobile #, :authenticate_user!
|
||||
layout 'phone'
|
||||
|
||||
alias :list :active_list
|
||||
|
||||
def allow_mobile
|
||||
headers['Access-Control-Allow-Origin'] = '*'
|
||||
headers['Access-Control-Request-Method'] = '*'
|
||||
end
|
||||
|
||||
def home
|
||||
handle_message_params
|
||||
end
|
||||
@@ -159,13 +164,17 @@ class UserController < ApplicationController
|
||||
def list_info
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
if !list.try(:active?)
|
||||
current_user.list_is_closed!
|
||||
render json: {list_active: false}
|
||||
return
|
||||
if list.present?
|
||||
if !list.try(:active?)
|
||||
current_user.list_is_closed!
|
||||
render json: {list_active: false}
|
||||
return
|
||||
else
|
||||
list_obj = list.as_json.merge(list_active: list.active? ).merge(list.join_requests_as_json)
|
||||
render json: list_obj
|
||||
end
|
||||
else
|
||||
list_obj = list.as_json.merge(list_active: list.active? ).merge(list.join_requests_as_json)
|
||||
render json: list_obj
|
||||
render json: {not_present: true}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -223,7 +232,7 @@ class UserController < ApplicationController
|
||||
format.html do
|
||||
end
|
||||
format.json do
|
||||
render json: @list.with_orders_as_json
|
||||
render json: @list.with_orders_as_json.merge(supplier_name: @list.supplier.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,13 +11,15 @@ html lang="en"
|
||||
/[if lt IE 9]
|
||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||
= stylesheet_link_tag "user/application", :media => "all"
|
||||
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-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-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-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
||||
link href="/images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
|
||||
link href="/favicon.ico" rel="shortcut icon"
|
||||
javascript:
|
||||
var QMobile;
|
||||
var data_host = 'http://localhost:3000';
|
||||
var root_url = 'file:///Users/bterkuile/Documents/workspace/Qwaiter/assets';
|
||||
// Dummy holder when Qmobile object is not supplied by the mobile phone
|
||||
QMobile || (QMobile = {
|
||||
scanQr: function(){window.location = '/select_qrcode'},
|
||||
@@ -33,7 +35,7 @@ html lang="en"
|
||||
span.icon-bar
|
||||
span.icon-bar
|
||||
span.icon-bar
|
||||
a.brand href=user_root_path = image_tag 'icons/logo-small.png', alt: application_title
|
||||
= link_to image_tag('icons/logo-small.png', alt: application_title), user_root_path, class: :brand
|
||||
.container.nav-collapse
|
||||
ul.nav#top-navigation-list
|
||||
li= link_to 'View history', user_list_history_path
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.page-header= title t('user.history_list.title', list: List.model_name.human)
|
||||
dl.dl-horizontal
|
||||
dt= List.human_attribute_name(:created_at)
|
||||
dd= l @list.created_at, format: :short
|
||||
dd.list-created-at
|
||||
dt= Supplier.model_name.human
|
||||
dd= @list.supplier.name
|
||||
dd.supplier-name
|
||||
.well
|
||||
table#history-list-table.table
|
||||
thead
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
a href="#" onClick="QMobile.scanQr()" = image_tag 'scan-logo.png'
|
||||
.home-footer
|
||||
.home-footer-content
|
||||
- if list_open?
|
||||
= link_to 'P', user_list_products_path, class: 'home-menu-link'
|
||||
= link_to 'L', user_active_list_path, class: 'home-list-link'
|
||||
= link_to 'P', user_list_products_path, class: [:hide, 'home-link', 'home-menu-link']
|
||||
= link_to 'L', user_active_list_path, class: [:hide, 'home-link', 'home-list-link']
|
||||
- content_for :footer do
|
||||
javascript:
|
||||
$(function(){
|
||||
Quser.home_loader();
|
||||
setInterval("Quser.home_loader()", 7500);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.page-header
|
||||
.table-number= @table.number
|
||||
.supplier-name= @table.supplier.name
|
||||
.table-number
|
||||
.supplier-name
|
||||
h4= t('user.show_products.title', products: Product.model_name.human_plural)
|
||||
.well
|
||||
table#products-table.table.table-hover
|
||||
|
||||
Reference in New Issue
Block a user