refactor and move to selenium
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
App.MenuProductCategoriesComponent = Ember.Component.extend
|
||||
orderProducts: false
|
||||
timestamp: 0 # invalidation param
|
||||
active_product_categories: (->
|
||||
list = @get('product_categories')
|
||||
).property('product_categories.@each', 'timestamp')
|
||||
|
||||
actions:
|
||||
toggleProductCategory: (product_category) -> product_category.toggleProperty('collapsed')
|
||||
@@ -0,0 +1,14 @@
|
||||
App.MenuProductComponent = Ember.Component.extend
|
||||
tagName: 'li'
|
||||
classNameBindings: ['specific_id']
|
||||
specific_id: (-> "order-product-#{@get('product.id')}").property('product.id')
|
||||
orderProducts: false
|
||||
target: -> @get('parentView.targetObject')
|
||||
actions:
|
||||
addProduct: (product)->
|
||||
if existing = @target().store.all('product_order').find((po)-> po.get('product') == product and not po.get('order'))
|
||||
existing.increment()
|
||||
else
|
||||
@target().store.createRecord 'product_order', product: product, price: product.get('price')
|
||||
showProductDescription: (product)->
|
||||
@target().modal 'product_info', model: product, title: product.get('name')
|
||||
@@ -108,6 +108,8 @@ App.ApplicationController = Ember.Controller.extend
|
||||
if error_list = @store.all('list').findBy('id', 'current')
|
||||
error_list.eraseRecord()
|
||||
@set 'list', null
|
||||
@redirect_to 'index'
|
||||
switch @currentRouteName
|
||||
when 'table' then # nothing
|
||||
else @redirect_to 'index'
|
||||
|
||||
@store.find('list', 'current').then(success, error)
|
||||
|
||||
@@ -17,15 +17,6 @@ App.TableController = Ember.ObjectController.extend
|
||||
if @get('model.occupied') then true else false # no point in joining tables that are not occupied
|
||||
).property('controllers.application.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'controllers.application.list.table.id')
|
||||
actions:
|
||||
addProduct: (product)->
|
||||
if existing = @store.all('product_order').find((po)-> po.get('product') == product and not po.get('order'))
|
||||
existing.increment()
|
||||
else
|
||||
@store.createRecord 'product_order', product: product, price: product.get('price')
|
||||
joinOccupiedTable: ->
|
||||
Ember.$.post("#{$data_host}/user/join_occupied_table.json", table_id: @get('model.id'))
|
||||
@set 'controllers.application.join_request_sent', true # keeps the button deactivated
|
||||
toggleProductCategory: (product_category)->
|
||||
product_category.set 'collapsed', not product_category.get('collapsed')
|
||||
showProductDescription: (product)->
|
||||
@modal 'product_info', model: product, title: product.get('name')
|
||||
|
||||
@@ -3,7 +3,7 @@ ControllerExtensions = Ember.Mixin.create
|
||||
ajaxError: (callback)->
|
||||
handler = (emberError)=>
|
||||
console.log "Error: status #{emberError.status}"
|
||||
if emberError.status == 401
|
||||
if emberError.status is 401
|
||||
App.__container__.lookup('route:application').unauthorized()
|
||||
else
|
||||
callback.call(@, emberError)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
each product_category in active_product_categories
|
||||
.product-category-container
|
||||
if orderProducts
|
||||
h4 OderProducts
|
||||
if product_category.products
|
||||
h4.product_category-title{action "toggleProductCategory" product_category}
|
||||
if product_category.collapsed
|
||||
span.icon.collapsed
|
||||
else
|
||||
span.icon
|
||||
= product_category.name
|
||||
unless product_category.collapsed
|
||||
ul.product_category-products
|
||||
each product in product_category.products
|
||||
= menu-product product=product orderProducts=orderProducts
|
||||
@@ -0,0 +1,12 @@
|
||||
if product.description
|
||||
button.show-product-description{action "showProductDescription" product}
|
||||
span
|
||||
else
|
||||
span.no-product-description
|
||||
if orderProducts
|
||||
a{action "addProduct" product}= product.name
|
||||
button.add-product-to-list{action "addProduct" product}
|
||||
span
|
||||
else
|
||||
span= product.name
|
||||
span.product-price.currency=currency product.price
|
||||
@@ -12,41 +12,7 @@
|
||||
else
|
||||
button.join-table-button{action "joinOccupiedTable"}=t 'join_request.requestor.join_this_table'
|
||||
if tableCanTakeOrders
|
||||
.large-6.columns
|
||||
each product_category in supplier.product_categories
|
||||
.product-category-container
|
||||
if product_category.products
|
||||
h4.product_category-title{action "toggleProductCategory" product_category}
|
||||
if product_category.collapsed
|
||||
span.icon.collapsed
|
||||
else
|
||||
span.icon
|
||||
= product_category.name
|
||||
unless product_category.collapsed
|
||||
ul.product_category-products
|
||||
each product in product_category.products
|
||||
li class="order-product-#{unbound product.id}"
|
||||
if product.description
|
||||
button.show-product-description{action "showProductDescription" product}
|
||||
span
|
||||
else
|
||||
span.no-product-description
|
||||
a{action "addProduct" product}= product.name
|
||||
button.add-product-to-list{action "addProduct" product}
|
||||
span
|
||||
span.product-price.currency=currency product.price
|
||||
.large-6.columns= menu-product-categories product_categories=supplier.product_categories orderProducts=true
|
||||
.large-6.columns= render 'product_orders'
|
||||
else
|
||||
.large12
|
||||
each product_category in supplier.product_categories
|
||||
if product_category.products
|
||||
.product_category-container
|
||||
h4.product-category-title= product_category.name
|
||||
ul.product_category-products
|
||||
each product in product_category.products
|
||||
li class="order-product-#{unbound product.id}"
|
||||
if product.description
|
||||
button.show-product-description{action "showProductDescription" product}
|
||||
span
|
||||
span= product.name
|
||||
span.right.currency=currency product.price
|
||||
.large12= menu-product-categories product_categories=supplier.product_categories orderProducts=false
|
||||
|
||||
Reference in New Issue
Block a user