31 lines
1.4 KiB
CoffeeScript
31 lines
1.4 KiB
CoffeeScript
App.MenuController = Ember.Controller.extend
|
|
product_code_filter: ''
|
|
product_categories: (-> @store.peekAll('product_category')).property()
|
|
filter: null
|
|
sorted_product_categories: (->
|
|
list = @get('product_categories')
|
|
if filter_day = @get('filter.day')
|
|
list = list.filterBy "active_on_#{filter_day}"
|
|
if filter_minute = @get('filter.minute_of_day')
|
|
list = list.filter (r) -> r.get('full_day') or (filter_minute >= r.get('start_from') and filter_minute <= r.get('end_on'))
|
|
|
|
list.sortBy('position')
|
|
).property('product_categories.[]', 'product_categories.@each.position', 'filter.day', 'filter.minute_of_day')
|
|
product_code_filter_placeholder: t('product.code_filter.placeholder')
|
|
actions:
|
|
editProductCategory: (product_category)->
|
|
@modal 'product_category_edit',
|
|
model: product_category
|
|
close: -> product_category.rollbackAttributes()
|
|
destroy_text_path: 'product_category.modal.destroy_confirm_text'
|
|
|
|
moveProductCategory: (product_category)->
|
|
@modal 'product_category_move',
|
|
model: product_category
|
|
newProductCategory: ->
|
|
@modal 'product_category_new',
|
|
model: @store.createRecord('product_category', position: @get('product_categories.length'))
|
|
close: -> @get('model').deleteRecord()
|
|
addProduct: (product_category)->
|
|
product_category.get('products').addObject @store.createRecord 'product', position: product_category.get('products.length')
|