Remove list.showTotal duplication

This commit is contained in:
2014-12-16 22:26:32 +01:00
parent 6a8d517727
commit bdcb0d60b8
5 changed files with 5 additions and 11 deletions
@@ -2,10 +2,4 @@ App.ActiveListController = Ember.ObjectController.extend
#orders: (-> #orders: (->
#@get('list.orders') #@get('list.orders')
#).property('list.orders') #).property('list.orders')
#list: (->
#@get('controllers.application.list')
#).property('controllers.application.list')
showTotal: (-> @get('model.orders.length') and @get('model.orders.length') > 1 ).property('model.orders.length')
list: (-> @get('controllers.application.list') ).property('controllers.application.list') list: (-> @get('controllers.application.list') ).property('controllers.application.list')
@@ -91,7 +91,6 @@ App.ApplicationController = Ember.Controller.extend
if error_list = @store.all('list').findBy('id', 'current') if error_list = @store.all('list').findBy('id', 'current')
error_list.eraseRecord() error_list.eraseRecord()
@set 'list', list @set 'list', list
@controllerFor('active_list').set('model', list)
if list.get('join_requests.length') if list.get('join_requests.length')
@transitionToRoute 'join_requests' @transitionToRoute 'join_requests'
else if @currentRouteName is 'index' else if @currentRouteName is 'index'
@@ -1,5 +1,2 @@
App.ListController = Ember.ObjectController.extend App.ListController = Ember.ObjectController.extend
list: (-> @get('model')).property('model') list: (-> @get('model')).property('model')
showTotal: (->
if @get('list.orders.length') && @get('list.orders.length') > 1 then true else false
).property('list.orders.length')
@@ -26,3 +26,7 @@ App.List = DS.Model.extend
@get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0) @get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
).property('relevant_orders.@each.total') ).property('relevant_orders.@each.total')
active: (-> @get('state') is 'active' ).property('state') active: (-> @get('state') is 'active' ).property('state')
showTotal: (->
if @get('orders.length') && @get('orders.length') > 1 then true else false
).property('orders.length')
@@ -17,7 +17,7 @@ if list.orders.isLoaded
if list.sorted_orders if list.sorted_orders
.list-orders-container .list-orders-container
each order in list.sorted_orders: = view "list-order" contentBinding="order" each order in list.sorted_orders: = view "list-order" contentBinding="order"
if showTotal if list.showTotal
.list-orders-total.total .list-orders-total.total
= t 'total' = t 'total'
span.currency= currency list.total span.currency= currency list.total