end of day commit
This commit is contained in:
@@ -98,7 +98,7 @@ root.Qsupplier=
|
||||
)
|
||||
|
||||
load_active_lists: () ->
|
||||
$.get('/supplier/active_lists.json?section_id='+($('#current_section_selector').val() || ''), (res) =>
|
||||
$.get('/supplier/active_lists.json?section_id='+($('#section_selector').val() || ''), (res) =>
|
||||
body = $('#active-lists-table tbody')
|
||||
body.find('tr').remove()
|
||||
foot = $('#active-lists-table tfoot')
|
||||
@@ -113,13 +113,11 @@ root.Qsupplier=
|
||||
)
|
||||
|
||||
load_active_orders: () ->
|
||||
$.get('/supplier/active_orders.json?section_id='+($('#current_section_selector').val() || ''), (res) =>
|
||||
$.get('/supplier/active_orders.json?section_id='+($('#section_selector').val() || ''), (res) =>
|
||||
body = $('#active-orders-table tbody')
|
||||
body.html('')
|
||||
foot = $('#active-orders-table tfoot')
|
||||
if(!res.orders && !res.orders.length)
|
||||
alert('No orders in list')
|
||||
return
|
||||
return unless res.orders
|
||||
for order in res.orders
|
||||
ord = new Order(order)
|
||||
body.append @mustache('#active-order-template', ord)
|
||||
|
||||
@@ -67,7 +67,13 @@ var $translations = {
|
||||
body: '%{email} wants to join the table',
|
||||
reject: 'Reject',
|
||||
approve: 'Approve',
|
||||
waiting_for_confirmation: 'Waiting for approval of the person on this table...'
|
||||
requestor: {
|
||||
title: 'This table is occupied',
|
||||
go_back: 'Back',
|
||||
show_the_products: 'Show the menu',
|
||||
join_this_table: 'Join this table',
|
||||
waiting_for_confirmation: 'Waiting for approval of the person on this table...'
|
||||
}
|
||||
},
|
||||
move_table: {
|
||||
cannot_move_to_occupied_table: 'You cannot move to an occupied table',
|
||||
@@ -102,7 +108,13 @@ var $translations = {
|
||||
body: '%{email} wil ook op jouw lijst bestellen',
|
||||
reject: 'Afwijzen',
|
||||
approve: 'Toestaan',
|
||||
waiting_for_confirmation: 'Wachten op toestemming van huidige gebruikers om hier te kunnen bestellen...'
|
||||
requestor: {
|
||||
title: 'Deze tafel is bezet',
|
||||
go_back: 'Terug',
|
||||
show_the_products: 'Toon het menu',
|
||||
join_this_table: 'Ook bestellen aan deze tafel',
|
||||
waiting_for_confirmation: 'Wachten op toestemming van huidige gebruikers om hier te kunnen bestellen...'
|
||||
}
|
||||
},
|
||||
move_table: {
|
||||
cannot_move_to_occupied_table: 'Je kan niet verhuizen naar een tafel die reeds gebruikt wordt.',
|
||||
|
||||
@@ -386,7 +386,7 @@ class Quser
|
||||
cont = $('#join-occupied-table-progress-container')
|
||||
cont.html('')
|
||||
cont.append $($('<img />').attr('src', "#{$asset_path}spinner.gif"))
|
||||
cont.append $($('<p>').html(t('join_request.waiting_for_confirmation')))
|
||||
cont.append $($('<p data-t="join_request.requestor.waiting_for_confirmation">').html(t('join_request.requestor.waiting_for_confirmation')))
|
||||
@ensure_token =>
|
||||
$.post(data_host + '/user/join_occupied_table', $.extend({table_id: table_id}, @authentication_object))
|
||||
#setInterval('Quser.check_if_can_join_occupied_table("'+table_id+'")', 7500)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#qr-list
|
||||
margin: 0
|
||||
list-style: none
|
||||
li
|
||||
list-style: none
|
||||
margin-bottom: 8px
|
||||
@@ -14,7 +14,7 @@ class DashboardController < ApplicationController
|
||||
|
||||
|
||||
def demo_both
|
||||
render layout: 'twitter-bootstrap'
|
||||
render layout: 'demo-both'
|
||||
end
|
||||
|
||||
# Testing action
|
||||
|
||||
@@ -22,7 +22,7 @@ module Suppliers
|
||||
# GET /lists/1
|
||||
# GET /lists/1.json
|
||||
def show
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.json do
|
||||
@@ -36,6 +36,7 @@ module Suppliers
|
||||
def new
|
||||
@list = List.new
|
||||
@list.section_id = params[:section_id].presence
|
||||
@tables = current_supplier.active_tables
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
@@ -43,16 +44,36 @@ module Suppliers
|
||||
end
|
||||
end
|
||||
|
||||
# POST /lists
|
||||
# POST /lists.json
|
||||
def create
|
||||
@list = List.new(params[:list])
|
||||
@list.supplier = current_supplier
|
||||
|
||||
respond_to do |format|
|
||||
if @list.save
|
||||
format.html { redirect_to [:suppliers, @list.section || @list], notice: t('action.create.successfull', model: List.model_name.human) }
|
||||
format.json { render json: @list, status: :created, location: @list }
|
||||
else
|
||||
format.html do
|
||||
@tables = current_supplier.active_tables
|
||||
render action: "new"
|
||||
end
|
||||
format.json { render json: @list.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# GET /lists/1/edit
|
||||
def edit
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@tables = current_supplier.active_tables
|
||||
end
|
||||
|
||||
# PUT /lists/1
|
||||
# PUT /lists/1.json
|
||||
def update
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @list.update_attributes(params[:list])
|
||||
@@ -71,7 +92,7 @@ module Suppliers
|
||||
# DELETE /lists/1
|
||||
# DELETE /lists/1.json
|
||||
def destroy
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@list.destroy
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -15,7 +15,7 @@ module Suppliers
|
||||
# GET /products/1
|
||||
# GET /products/1.json
|
||||
def show
|
||||
@product = ProductDecorator.find(params[:id])
|
||||
@product = ProductDecorator.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
@@ -27,6 +27,7 @@ module Suppliers
|
||||
# GET /products/new.json
|
||||
def new
|
||||
@product = Product.new
|
||||
@product.add_product_category ProductCategory.find_by_supplier_id_and_id!(current_supplier.id, params[:product_category_id]) if params[:product_category_id].present?
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
@@ -59,7 +60,7 @@ module Suppliers
|
||||
# PUT /products/1
|
||||
# PUT /products/1.json
|
||||
def update
|
||||
@product = Product.find(params[:id])
|
||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @product.update_attributes(params[:product])
|
||||
@@ -75,7 +76,7 @@ module Suppliers
|
||||
# DELETE /products/1
|
||||
# DELETE /products/1.json
|
||||
def destroy
|
||||
@product = Product.find(params[:id])
|
||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@product.destroy
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -14,7 +14,7 @@ module Suppliers
|
||||
# GET /tables/1
|
||||
# GET /tables/1.json
|
||||
def show
|
||||
@table = Table.find(params[:id])
|
||||
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
@@ -59,7 +59,7 @@ module Suppliers
|
||||
# PUT /tables/1
|
||||
# PUT /tables/1.json
|
||||
def update
|
||||
@table = Table.find(params[:id])
|
||||
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @table.update_attributes(params[:table])
|
||||
@@ -77,7 +77,7 @@ module Suppliers
|
||||
# DELETE /tables/1
|
||||
# DELETE /tables/1.json
|
||||
def destroy
|
||||
@table = Table.find(params[:id])
|
||||
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@table.destroy
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -44,6 +44,12 @@ class List
|
||||
}
|
||||
}|, reduce_function: '_sum'
|
||||
|
||||
view :active_for_supplier_and_section_view, type: :custom, map_function: %[function(doc){
|
||||
if(doc.ruby_class == 'List' && doc.state == 'active'){
|
||||
emit([doc.supplier_id, doc.section_id], 1);
|
||||
}
|
||||
}], reduce_function: '_sum'
|
||||
|
||||
view :for_user_view, type: :custom, map_function: %|function(doc){
|
||||
if(doc.ruby_class == 'List' && doc.user_ids && doc.user_ids.length){
|
||||
doc.user_ids.forEach(function(uid){
|
||||
@@ -77,6 +83,11 @@ class List
|
||||
database.view(active_by_section_id_view(key: section_id, reduce: false, include_docs: true))
|
||||
end
|
||||
|
||||
# Return all currently active orders for a given section
|
||||
def self.active_for_supplier_and_section(supplier, section_id, options = {})
|
||||
database.view(active_for_supplier_and_section_view(key: [supplier.id, section_id], reduce: false, include_docs: true))
|
||||
end
|
||||
|
||||
def self.active_for_table(table_id, options = {})
|
||||
database.view(active_by_table_id_view(options.reverse_merge(key: table_id, reduce: false, include_docs: true)))
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@ class Product
|
||||
validates :name, presence: true
|
||||
validates :supplier_id, presence: true
|
||||
validates :price, presence: true, numericality: true
|
||||
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
|
||||
|
||||
after_save :persist_product_category_ids
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class Supplier
|
||||
|
||||
def active_lists(options = {})
|
||||
return @active_lists if @active_lists.present?
|
||||
@active_lists = List.active_for_supplier(id)
|
||||
@active_lists = options[:section_id].present? ? List.active_for_supplier_and_section(self, options[:section_id]) : List.active_for_supplier(id)
|
||||
@active_lists.include_relations(table: :section, orders: {product_orders: :product})
|
||||
@active_lists
|
||||
end
|
||||
|
||||
@@ -14,6 +14,7 @@ class Table
|
||||
validates :supplier_id, presence: true
|
||||
#validates :list_id, presence: true
|
||||
validates :number, numericality: {greater_than: 0}
|
||||
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
|
||||
|
||||
#validates_uniqueness_of :number
|
||||
#view :by_number, key: :number # For uniqueness validation
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
doctype html
|
||||
html lang="en"
|
||||
head
|
||||
meta charset="utf-8"
|
||||
meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"
|
||||
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||
title= content_for?(:title) ? yield(:title) : application_title
|
||||
= csrf_meta_tags
|
||||
|
||||
/! Le HTML5 shim, for IE6-8 support of HTML elements
|
||||
/[if lt IE 9]
|
||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||
= stylesheet_link_tag "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="/favicon.ico" rel="shortcut icon"
|
||||
body class=action_name
|
||||
.container
|
||||
.content
|
||||
.row
|
||||
.span12
|
||||
= yield
|
||||
@@ -35,4 +35,4 @@
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), suppliers_path, class: 'btn'
|
||||
= link_to t("helpers.links.cancel"), supplier_root_path, class: 'btn'
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
javascript:
|
||||
$(function(){
|
||||
$('#section_selector').change(function(){
|
||||
Qsupplier.load_active_orders();
|
||||
Qsupplier.load_active_lists();
|
||||
var el = $(this);
|
||||
var linker = $(this).siblings('a');
|
||||
if(el.val()){
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), tables_path, class: 'btn'
|
||||
= link_to t("helpers.links.cancel"), suppliers_tables_path, class: 'btn'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
.page-header
|
||||
h4= t('user.join_occupied_table.title')
|
||||
h4 data-t="join_request.requestor.title" = t('user.join_occupied_table.title')
|
||||
.form-actions
|
||||
= link_to t('user.join_occupied_table.back'), user_root_path, class: :btn
|
||||
= link_to t('user.join_occupied_table.back'), user_root_path, class: :btn, data: {t: 'join_request.requestor.go_back'}
|
||||
'
|
||||
button.btn.btn-primary onclick="Quser.show_table_products()" = t('user.join_occupied_table.show_the_products')
|
||||
button.btn.btn-primary onclick="Quser.show_table_products()" data-t='join_request.requestor.show_the_products'= t('user.join_occupied_table.show_the_products')
|
||||
'
|
||||
button.btn.btn-warning{onClick="Quser.join_occupied_table()"} = t('user.join_occupied_table.join_this_table')
|
||||
button.btn.btn-warning onClick="Quser.join_occupied_table()" data-t='join_request.requestor.join_this_table'= t('user.join_occupied_table.join_this_table')
|
||||
#join-occupied-table-progress-container
|
||||
- onload_javascript 'Quser.watch_events()'
|
||||
|
||||
Reference in New Issue
Block a user