Add push buttons and support inactive products

This commit is contained in:
2015-03-24 14:53:02 +01:00
parent b0bab98be8
commit e720d6b31c
22 changed files with 74 additions and 21 deletions
@@ -2,7 +2,7 @@ App.MenuProductComponent = Ember.Component.extend
editMode: false
code_filter: ''
classNames: 'menu-product-container'
classNameBindings: ['menu_product_class', 'editMode:editing']
classNameBindings: ['menu_product_class', 'editMode:editing', 'product.active:active:inactive']
showProduct: (->
return true unless filter = @get('code_filter')
(@get('product.code') || "").toLowerCase().indexOf(filter.toLowerCase()) >= 0
@@ -16,7 +16,7 @@ App.MenuProductComponent = Ember.Component.extend
pre_code = code.substring(0,index)
highlight = code.substring(index,index + filter.length)
post_code = code.substring(index + filter.length)
new Ember.Handlebars.SafeString("#{pre_code}<span class='highlight'>#{highlight}</span>#{post_code}")
"#{pre_code}<span class='highlight'>#{highlight}</span>#{post_code}".htmlSafe()
else
code
).property('code_filter')
@@ -1,10 +1,11 @@
attr = DS.attr
App.Product = DS.Model.extend Ember.Validations.Mixin,
name: attr 'string'
price: attr 'number'
price: attr 'number', defaultValue: 0
code: attr 'string'
description: attr 'string'
visible: attr('boolean', defaultValue: true)
active: attr('boolean', defaultValue: true)
position: attr('number', defaultValue: 0)
image: attr()
product_category: DS.belongsTo('product_category')
@@ -23,5 +24,8 @@ App.Product = DS.Model.extend Ember.Validations.Mixin,
#true
#).property('price')
validations:
name: {presence: true}
price: {format: /^[+-]?\d+(\.?\d?\d)?$/}
name:
presence: true
price:
format:
width: /^[+-]?\d*(\.?\d?\d)?$/
@@ -4,13 +4,16 @@ if editMode
= input value=product.name placeholder=namePlaceholder action="save"
= errors product.errors.name
.small-3.columns.price
= edit-currency value=product.price validatePresence=true action="save"
= edit-currency value=product.price action="save"
= errors product.errors.price
.small-3.columns.code= input value=product.code placeholder=codePlaceholder
.small-3.columns.actions
a.rollback-product-action{action "rollbackProduct"}: span
a.destroy-product-action{action "destroyProduct" product}: span
a.save-product-action{action "save"}: span
.row
.small-4.large-2.columns= t 'attributes.product.active'
.small-8.large-10.columns: view boolean-switch value=product.active
.row.menu-product-container
.medium-4.small-6.columns
= view "upload-file" name="image" accept="image/*" file=product.image
@@ -27,5 +30,5 @@ else
= errors product.errors.price includeAttribute="product"
.small-3.columns: span= code_filter_display
.small-3.columns
span.fa.fa-edit{action "makeEditable"}
a.edit-product-action{action "makeEditable"}: span
/img src=product.image_src
@@ -11,7 +11,7 @@ each product_category in sorted_product_categories
span.title= product_category.name
span.availability= product_category.availability_text
can manage menu
a.edit-product-category-button{action "editProductCategory" product_category} href="#"
a.edit-product-category-button{action "editProductCategory" product_category} href="#": span
a.add-product-product_category-button{action "addProduct" product_category} href="#": span
each product in product_category.sorted_products
= menu-product product=product code_filter=product_code_filter
@@ -1,6 +1,6 @@
App.MenuProductComponent = Ember.Component.extend
tagName: 'li'
classNameBindings: ['specific_id']
classNameBindings: ['specific_id', 'product.active:active:inactive']
specific_id: (-> "order-product-#{@get('product.id')}").property('product.id')
orderProducts: false
target: -> @get('parentView.targetObject')
@@ -4,6 +4,7 @@ App.Product = DS.Model.extend
price: attr 'number'
description: attr 'string'
position: attr('number', defaultValue: 0)
active: attr 'boolean', defaultValue: true
image: attr()
product_category: DS.belongsTo('product_category')
product_orders: DS.hasMany('product_order')
@@ -4,9 +4,12 @@ if product.description
else
span.no-product-description
if orderProducts
a{action "addProduct" product}= product.name
button.add-product-to-list{action "addProduct" product}
span
if product.active
a{action "addProduct" product}= product.name
button.add-product-to-list{action "addProduct" product}
span
else
a{action "showProductDescription" product}= product.name
else
span= product.name
span.product-price.currency=currency product.price