case insensitive product code filter

This commit is contained in:
2015-01-14 09:00:08 +01:00
parent 8304a3b11e
commit 9e1d716974
@@ -3,12 +3,15 @@ App.MenuProductComponent = Ember.Component.extend
code_filter: ''
classNames: 'menu-product-container'
classNameBindings: ['menu_product_class', 'editMode:editing']
showProduct: (-> !@get('code_filter') or (@get('product.code') || "").match(@get('code_filter'))).property('code_filter')
showProduct: (->
return true unless filter = @get('code_filter')
(@get('product.code') || "").toLowerCase().indexOf(filter.toLowerCase()) >= 0
).property('code_filter')
menu_product_class: (-> "menu-product-#{@get('product.id') || 'new'}").property('product.id')
code_filter_display: (->
return new Ember.Handlebars.SafeString(' ') unless code = @get('product.code')
return code unless filter = @get('code_filter')
index = code.indexOf(filter)
index = code.toLowerCase().indexOf(filter.toLowerCase())
if index >= 0
pre_code = code.substring(0,index)
highlight = code.substring(index,index + filter.length)