diff --git a/app/assets/javascripts/qrammer.js.coffee b/app/assets/javascripts/qrammer.js.coffee
index ff7bf860..610c3fc7 100644
--- a/app/assets/javascripts/qrammer.js.coffee
+++ b/app/assets/javascripts/qrammer.js.coffee
@@ -107,17 +107,28 @@ root.Qrammer =
Qrammer.handle_active_user_list_default_actions()
)
handle_active_user_list_default_actions: ->
+ Qrammer.list_needs_payment_default_action()
Qrammer.list_needs_help_default_action()
list_needs_help_default_action: ->
needs_help_container = $('#list-needs-help-button')
if needs_help_container.length
if window.active_list.needs_help
- needs_help_container.html('Help requested')
+ needs_help_container.html('')
else
needs_help_container.html($('').click(Qrammer.list_needs_help)) #TODO TEXT
list_needs_help: ->
return unless window.active_list && !window.active_list.needs_help
$.post('/active_user_list_needs_help.json', (res) -> window.active_list = res; Qrammer.list_needs_help_default_action())
+ list_needs_payment_default_action: ->
+ needs_payment_container = $('#list-needs-payment-button')
+ if needs_payment_container.length
+ if window.active_list.needs_payment
+ needs_payment_container.html('')
+ else
+ needs_payment_container.html($('').click(Qrammer.list_needs_payment)) #TODO TEXT
+ list_needs_payment: ->
+ return unless window.active_list && !window.active_list.needs_payment
+ $.post('/active_user_list_needs_payment.json', (res) -> window.active_list = res; Qrammer.list_needs_payment_default_action())
load_active_lists: (supplier_id) ->
$.get('/suppliers/'+supplier_id+'/active_lists.json', (res) ->
@@ -158,6 +169,8 @@ root.Qrammer =
)
active_user_list: (list_id) ->
$.get('/lists/'+list_id+'/current.json', (res) ->
+ window.active_list = res
+ Qrammer.handle_active_user_list_default_actions()
body = $('#active-list-table tbody')
foot = $('#active-list-table tfoot')
body.find('tr').remove()
diff --git a/app/assets/stylesheets/structure.css.sass b/app/assets/stylesheets/structure.css.sass
index 2529a79d..9fee012c 100644
--- a/app/assets/stylesheets/structure.css.sass
+++ b/app/assets/stylesheets/structure.css.sass
@@ -66,6 +66,10 @@ table
#list-needs-help-button
button
margin-left: 5px
+ i
+ padding-left: 5px
#list-needs-payment-button
button
margin-left: 5px
+ i
+ padding-left: 5px
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 36688fb3..a0d750a7 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -80,7 +80,7 @@ class DashboardController < ApplicationController
redirect_to active_lists_supplier_path(Supplier.first)
end
- # POST /active_user_list_needs_help
+ # POST /active_user_list_needs_help.json
def active_user_list_needs_help
respond_to do |format|
format.json do
@@ -91,4 +91,16 @@ class DashboardController < ApplicationController
end
end
end
+
+ # POST /active_user_list_needs_payment.json
+ def active_user_list_needs_payment
+ respond_to do |format|
+ format.json do
+ render json: {list_active: false} and return unless session[:active_list_id].present?
+ active_list.needs_payment = true
+ active_list.save
+ render json: active_list.as_json.merge(list_active: true)
+ end
+ end
+ end
end
diff --git a/app/views/dashboard/show_products.html.slim b/app/views/dashboard/show_products.html.slim
index 6ef68332..867829b2 100644
--- a/app/views/dashboard/show_products.html.slim
+++ b/app/views/dashboard/show_products.html.slim
@@ -33,15 +33,15 @@ table#active-order-table.table.table-striped.hide
body.append('
'+category+' |
');
var category_ref = window.products[category];
for(var iproduct = 0; iproduct < window.products[category].length; iproduct++){
- var product_index = iproduct;
+ var product = window.products[category][iproduct];
row = $('
');
button = $('');
- var callback = (function(ref){
- return function(){ Qrammer.add_product(ref[product_index]) }
- })(category_ref)
+ var callback = (function(prod){
+ return function(){ Qrammer.add_product(prod) }
+ })(product)
button.click(callback);
- row.append(''+window.products[category][iproduct].name+' | ');
- row.append(''+Qrammer.currency(window.products[category][iproduct].price)+' | ');
+ row.append(''+product.name+' | ');
+ row.append(''+Qrammer.currency(product.price)+' | ');
row.append($(' | ').append(button));
body.append(row);
}
diff --git a/app/views/layouts/tablet.html.slim b/app/views/layouts/tablet.html.slim
index 0ced2b9a..837260ef 100644
--- a/app/views/layouts/tablet.html.slim
+++ b/app/views/layouts/tablet.html.slim
@@ -29,10 +29,10 @@ html lang="en"
span.icon-bar
span.icon-bar
a.brand href=supplier_root_path Qrammer
- .container.nav-collapse-disabled
- ul.nav#top-navigation-list
- li= link_to t('supplier.menu.active_orders', orders: Order.model_name.human_plural), supplier_orders_path
- li= link_to t('supplier.menu.active_lists', lists: List.model_name.human_plural), supplier_lists_path
+ ul.nav#top-navigation-list
+ li= link_to t('supplier.menu.active_orders', orders: Order.model_name.human_plural), supplier_orders_path
+ li= link_to t('supplier.menu.active_lists', lists: List.model_name.human_plural), supplier_lists_path
+ .container.nav-collapse
.container
diff --git a/app/views/lists/_form.html.slim b/app/views/lists/_form.html.slim
index e6ca7ce9..d162e0ca 100644
--- a/app/views/lists/_form.html.slim
+++ b/app/views/lists/_form.html.slim
@@ -4,10 +4,10 @@
= f.label :state, class: 'control-label'
.controls
= f.text_field :state, class: 'text_field'
- .control-group class=(@list.errors[:need_help].any? ? 'error' : nil)
- = f.label :need_help, class: 'control-label'
+ .control-group class=(@list.errors[:needs_help].any? ? 'error' : nil)
+ = f.label :needs_help, class: 'control-label'
.controls
- = f.check_box :need_help, class: 'check_box'
+ = f.check_box :needs_help, class: 'check_box'
.control-group class=(@list.errors[:needs_payment].any? ? 'error' : nil)
= f.label :needs_payment, class: 'control-label'
.controls
diff --git a/app/views/lists/index.html.slim b/app/views/lists/index.html.slim
index 99f9fe0c..f60f2329 100644
--- a/app/views/lists/index.html.slim
+++ b/app/views/lists/index.html.slim
@@ -5,7 +5,7 @@ div.page-header= title :index, model_class
thead
tr
th= model_class.human_attribute_name(:state)
- th= model_class.human_attribute_name(:need_help)
+ th= model_class.human_attribute_name(:needs_help)
th= model_class.human_attribute_name(:needs_payment)
th= model_class.human_attribute_name(:closed_at)
th= Table.model_name.human
@@ -15,7 +15,7 @@ div.page-header= title :index, model_class
- @lists.each do |list|
tr
td= link_to list.state, list
- td= list.need_help
+ td= list.needs_help
td= list.needs_payment
td= list.closed_at
td= link_to_if list.table.present?, list.table.try(:number), list.table
diff --git a/app/views/lists/show.html.slim b/app/views/lists/show.html.slim
index c4a6e225..d56f7fdf 100644
--- a/app/views/lists/show.html.slim
+++ b/app/views/lists/show.html.slim
@@ -4,8 +4,8 @@
dl.dl-horizontal.show-list
dt= model_class.human_attribute_name(:state)
dd= @list.state
- dt= model_class.human_attribute_name(:need_help)
- dd= @list.need_help
+ dt= model_class.human_attribute_name(:needs_help)
+ dd= @list.needs_help
dt= model_class.human_attribute_name(:needs_payment)
dd= @list.needs_payment
dt= model_class.human_attribute_name(:closed_at)
diff --git a/app/views/suppliers/active_lists.html.slim b/app/views/suppliers/active_lists.html.slim
index 1f849c08..8aad4320 100644
--- a/app/views/suppliers/active_lists.html.slim
+++ b/app/views/suppliers/active_lists.html.slim
@@ -1,4 +1,4 @@
-.page-header= title 'Active lists'
+.page-header= title t('supplier.active_lists.title', lists: List.model_name.human_plural)
table#active-lists-table.table.table-striped
thead
tr
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2280f940..bc4ee6e1 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -51,6 +51,8 @@ en:
supplier:
menu:
active_lists: Active %{lists}
+ active_lists:
+ title: Active %{lists}
user:
active_list:
title: Active %{list}
diff --git a/config/routes.rb b/config/routes.rb
index ef7b62c0..c053da4c 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -38,6 +38,7 @@ Qrammer::Application.routes.draw do
match '/user_history' => 'dashboard#user_history', as: :user_history
match '/show_products' => 'dashboard#show_products', as: :user_products
post '/active_user_list_needs_help' => 'dashboard#active_user_list_needs_help', as: :active_user_list_needs_help
+ post '/active_user_list_needs_payment' => 'dashboard#active_user_list_needs_payment', as: :active_user_list_needs_payment
match "/:action", controller: 'dashboard'
# The priority is based upon order of creation: