Fix bug with unlinking user orders on lists load over active list
This commit is contained in:
@@ -9,4 +9,4 @@ App.Order = DS.Model.extend
|
|||||||
).property('product_orders.@each.quantity')
|
).property('product_orders.@each.quantity')
|
||||||
display: (->
|
display: (->
|
||||||
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
|
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
|
||||||
).property('product_orders.@each.quantity')
|
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.name')
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
attr = DS.attr
|
attr = DS.attr
|
||||||
App.ProductOrder = DS.Model.extend
|
App.ProductOrder = DS.Model.extend
|
||||||
quantity: attr 'number', defaultValue: 1
|
quantity: attr 'number', defaultValue: 1
|
||||||
product: DS.belongsTo('product')
|
price: attr 'number'
|
||||||
product_name: attr('string')
|
product_name: attr('string')
|
||||||
|
product: DS.belongsTo('product')
|
||||||
order: DS.belongsTo('order')
|
order: DS.belongsTo('order')
|
||||||
placed: attr('boolean', defaultValue: false)
|
placed: attr('boolean', defaultValue: false) # virtual attribute for new orders to be placed, should be more elegant
|
||||||
increment: ->
|
increment: ->
|
||||||
@set('quantity', @get('quantity') + 1)
|
@set('quantity', @get('quantity') + 1)
|
||||||
total: (-> @get('quantity') * @get('product.price')).property('quantity')
|
total: (-> @get('quantity') * @get('price')).property('quantity', 'price')
|
||||||
setOrder: (order)->
|
setOrder: (order)->
|
||||||
@set('placed', true)
|
@set('placed', true)
|
||||||
@set('order', order)
|
@set('order', order)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
App.Section = DS.Model.extend {}
|
||||||
@@ -1,50 +1,3 @@
|
|||||||
/.top-menu.off-canvas-wrap
|
|
||||||
.inner-wrap
|
|
||||||
nav.tab-bar
|
|
||||||
section.left-small
|
|
||||||
a.left-off-canvas-toggle.menu-icon
|
|
||||||
span
|
|
||||||
section.right.tab-bar-section
|
|
||||||
= link-to 'index'
|
|
||||||
= image_tag 'icons/logo-small.png'
|
|
||||||
a{ action "openDebugger"} alt=""
|
|
||||||
span.fa.fa-wrench.fa-lg
|
|
||||||
.right
|
|
||||||
if list.id
|
|
||||||
App.MenuItemView route="active_list"
|
|
||||||
App.MenuItemView route='table' route_param=list.table.id
|
|
||||||
App.MenuItemListNeedsHelpView
|
|
||||||
App.MenuItemListNeedsPaymentView
|
|
||||||
aside.left-off-canvas-menu
|
|
||||||
ul.off-canvas-list
|
|
||||||
li: h3 Menu
|
|
||||||
li
|
|
||||||
= link-to 'index'
|
|
||||||
span Home
|
|
||||||
li
|
|
||||||
a{action scanQr bubbles=false}
|
|
||||||
span Scan QR
|
|
||||||
if list.id
|
|
||||||
li
|
|
||||||
=link-to 'table' list.table.id
|
|
||||||
span= t 'list_products.title'
|
|
||||||
li
|
|
||||||
=link-to 'active_list'
|
|
||||||
span= t 'active_list.title'
|
|
||||||
li
|
|
||||||
=link-to 'lists'
|
|
||||||
span= t 'models.plural.list'
|
|
||||||
li
|
|
||||||
=link-to 'join_requests'
|
|
||||||
span= t 'models.plural.join_request'
|
|
||||||
section.main-section
|
|
||||||
if notice
|
|
||||||
#notice.alert-box{action clearNotice} data-alert=true
|
|
||||||
a.right href="#"
|
|
||||||
span.fa.fa-times.fa-lg
|
|
||||||
span= notice
|
|
||||||
= outlet
|
|
||||||
a.exit-off-canvas
|
|
||||||
header.top-menu
|
header.top-menu
|
||||||
.toggle-side-menu
|
.toggle-side-menu
|
||||||
span
|
span
|
||||||
@@ -85,16 +38,16 @@ aside.side-menu
|
|||||||
span Scan QR
|
span Scan QR
|
||||||
if list.id
|
if list.id
|
||||||
li
|
li
|
||||||
=link-to 'table' list.table.id
|
=link-to 'table' list.table.id class="side-menu-list-products"
|
||||||
span.fa.fa-cutlery
|
span.fa.fa-cutlery
|
||||||
span.fa.fa-glass
|
span.fa.fa-glass
|
||||||
= t 'list_products.title'
|
= t 'list_products.title'
|
||||||
li
|
li
|
||||||
=link-to 'active_list'
|
=link-to 'active_list' class="side-menu-active-list"
|
||||||
span.active-list-icon
|
span.active-list-icon
|
||||||
span= t 'active_list.title'
|
span= t 'active_list.title'
|
||||||
li
|
li
|
||||||
=link-to 'lists'
|
=link-to 'lists' class="side-menu-lists"
|
||||||
span= t 'models.plural.list'
|
span= t 'models.plural.list'
|
||||||
li
|
li
|
||||||
=link-to 'join_requests'
|
=link-to 'join_requests'
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
.row
|
.row
|
||||||
h2=t 'models.plural.list'
|
h2=t 'models.plural.list'
|
||||||
each list in controller
|
each list in controller
|
||||||
.lists-overview-entry{action showList list}
|
.lists-overview-entry{action "showList" list}
|
||||||
span.created_at=time list.created_at
|
span.created_at=time list.created_at
|
||||||
span.price.currency= currency list.price
|
span.price.currency= currency list.price
|
||||||
span.name= list.supplier_name
|
span.name= list.supplier_name
|
||||||
hr
|
hr
|
||||||
.clearfix
|
.clearfix
|
||||||
if hasMore
|
if hasMore
|
||||||
button{action showMore} Show more
|
button{action "showMore"}=t 'lists.show_more'
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ $green: #7BB459 //Heineken
|
|||||||
//$wood: image-url('textures/wood001-vertical.jpg')
|
//$wood: image-url('textures/wood001-vertical.jpg')
|
||||||
$wood: image-url('textures/theme1.jpg')
|
$wood: image-url('textures/theme1.jpg')
|
||||||
$background-brown: #57351f
|
$background-brown: #57351f
|
||||||
|
$active-link-color: #ff0
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ header.top-menu
|
|||||||
margin-top: 10px
|
margin-top: 10px
|
||||||
color: #999
|
color: #999
|
||||||
&.active
|
&.active
|
||||||
color: yellow
|
color: $active-link-color
|
||||||
border-color: yellow
|
border-color: $active-link-color
|
||||||
&.callout
|
&.callout
|
||||||
color: #f70
|
color: #f70
|
||||||
border-color: #f70
|
border-color: #f70
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ aside.side-menu
|
|||||||
margin-right: 18px
|
margin-right: 18px
|
||||||
@extend .fa
|
@extend .fa
|
||||||
@extend .fa-list
|
@extend .fa-list
|
||||||
|
a.active
|
||||||
|
color: $active-link-color
|
||||||
|
|
||||||
.toggle-side-menu
|
.toggle-side-menu
|
||||||
position: absolute
|
position: absolute
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module Users
|
|||||||
#lists = current_user.lists.include_relation(:supplier, :table)
|
#lists = current_user.lists.include_relation(:supplier, :table)
|
||||||
lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25).include_relation(:supplier, :table)
|
lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25).include_relation(:supplier, :table)
|
||||||
#lists.include_relation(:supplier)
|
#lists.include_relation(:supplier)
|
||||||
|
lists.include_relation(:users, :orders)
|
||||||
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ class UserExtendedSupplierSerializer < Qwaiter::Serializer
|
|||||||
embed :ids, include: true
|
embed :ids, include: true
|
||||||
attributes :extended_version, :open, :name, :orders_in_process_count, :orders_placed_count
|
attributes :extended_version, :open, :name, :orders_in_process_count, :orders_placed_count
|
||||||
has_many :product_categories
|
has_many :product_categories
|
||||||
|
has_many :products
|
||||||
|
|
||||||
def extended_version
|
def extended_version
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class UserListSerializer < Qwaiter::Serializer
|
class UserListSerializer < Qwaiter::Serializer
|
||||||
# user ids for facebook pictures
|
# user ids for facebook pictures
|
||||||
#embed :ids
|
embed :ids
|
||||||
attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name, :closed_at, :supplier_id
|
attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name, :closed_at, :supplier_id
|
||||||
|
|
||||||
#def has_active_orders
|
#def has_active_orders
|
||||||
@@ -9,4 +9,6 @@ class UserListSerializer < Qwaiter::Serializer
|
|||||||
def supplier_name
|
def supplier_name
|
||||||
object.supplier.name
|
object.supplier.name
|
||||||
end
|
end
|
||||||
|
has_many :users
|
||||||
|
has_many :orders
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -88,3 +88,5 @@ en:
|
|||||||
list:
|
list:
|
||||||
active: 'Active'
|
active: 'Active'
|
||||||
closed: 'Closed'
|
closed: 'Closed'
|
||||||
|
lists:
|
||||||
|
show_more: Show more
|
||||||
|
|||||||
@@ -86,3 +86,5 @@ nl:
|
|||||||
list:
|
list:
|
||||||
active: 'Actief'
|
active: 'Actief'
|
||||||
closed: 'Afgesloten'
|
closed: 'Afgesloten'
|
||||||
|
lists:
|
||||||
|
show_more: Meer tonen
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
Feature: Active list view
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Loading lists and switching back to the active list
|
||||||
|
Given There is an open supplier with a menu
|
||||||
|
And there is a signed in user with an active order
|
||||||
|
And the user is on the active list page
|
||||||
|
When the user opens the side menu
|
||||||
|
And the user clicks on the lists link in the side menu
|
||||||
|
And the user opens the side menu again
|
||||||
|
And the user clicks on the active list link in the side menu
|
||||||
|
Then the user should see the order in the active list view
|
||||||
@@ -9,6 +9,9 @@ end
|
|||||||
|
|
||||||
step "the user has an active list" do
|
step "the user has an active list" do
|
||||||
@list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id]
|
@list = create :list, supplier: @supplier, table: @table, user_ids: [@user.id]
|
||||||
|
@product ||= create :product, supplier: @supplier, name: 'Beer', price: 2.34
|
||||||
|
@order = create :order, supplier: @supplier, list: @list
|
||||||
|
@product_order = create :product_order, order: @order, product: @product, quantity: 2, price: 2.34
|
||||||
@user.reload
|
@user.reload
|
||||||
@user.active_list_id = @list.id
|
@user.active_list_id = @list.id
|
||||||
@user.save
|
@user.save
|
||||||
@@ -29,4 +32,3 @@ end
|
|||||||
step "I am signed in as a user" do
|
step "I am signed in as a user" do
|
||||||
step "I visit the user obtain token path"
|
step "I visit the user obtain token path"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
step "the user is on the active list page" do
|
||||||
|
visit "/user#/active_list"
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user should see the order in the active list view" do
|
||||||
|
page.evaluate_script(%|$('.order-row-#{@order.id}').text()|).first(14).should == '2 x Beer€ 4.68'
|
||||||
|
end
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
step "the user opens the side menu" do
|
||||||
|
page.execute_script %|$('.toggle-side-menu').click()|
|
||||||
|
sleep 1
|
||||||
|
end
|
||||||
|
step "the user opens the side menu again" do
|
||||||
|
step "the user opens the side menu"
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user clicks on the lists link in the side menu" do
|
||||||
|
page.execute_script %|$('.side-menu-lists').click()|
|
||||||
|
end
|
||||||
|
|
||||||
|
step "the user clicks on the active list link in the side menu" do
|
||||||
|
page.execute_script %|$('.side-menu-active-list').click()|
|
||||||
|
end
|
||||||
@@ -14,4 +14,8 @@ module SpecEmberHelpers
|
|||||||
SCRIPT
|
SCRIPT
|
||||||
JSON.parse(h)
|
JSON.parse(h)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def js_path
|
||||||
|
page.evaluate_script 'location.pathname + location.hash'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user