case insensitive product code filter
This commit is contained in:
@@ -3,12 +3,15 @@ App.MenuProductComponent = Ember.Component.extend
|
|||||||
code_filter: ''
|
code_filter: ''
|
||||||
classNames: 'menu-product-container'
|
classNames: 'menu-product-container'
|
||||||
classNameBindings: ['menu_product_class', 'editMode:editing']
|
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')
|
menu_product_class: (-> "menu-product-#{@get('product.id') || 'new'}").property('product.id')
|
||||||
code_filter_display: (->
|
code_filter_display: (->
|
||||||
return new Ember.Handlebars.SafeString(' ') unless code = @get('product.code')
|
return new Ember.Handlebars.SafeString(' ') unless code = @get('product.code')
|
||||||
return code unless filter = @get('code_filter')
|
return code unless filter = @get('code_filter')
|
||||||
index = code.indexOf(filter)
|
index = code.toLowerCase().indexOf(filter.toLowerCase())
|
||||||
if index >= 0
|
if index >= 0
|
||||||
pre_code = code.substring(0,index)
|
pre_code = code.substring(0,index)
|
||||||
highlight = code.substring(index,index + filter.length)
|
highlight = code.substring(index,index + filter.length)
|
||||||
|
|||||||
Reference in New Issue
Block a user