From bdcb0d60b860bdd163999f3fc76c40fe86d024ff Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Tue, 16 Dec 2014 22:26:32 +0100 Subject: [PATCH] Remove list.showTotal duplication --- .../user/app/controllers/active_list_controller.js.coffee | 6 ------ .../user/app/controllers/application_controller.js.coffee | 1 - .../user/app/controllers/list_controller.js.coffee | 3 --- app/assets/javascripts/user/app/models/list.js.coffee | 4 ++++ .../javascripts/user/app/templates/_list_content.emblem | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/user/app/controllers/active_list_controller.js.coffee b/app/assets/javascripts/user/app/controllers/active_list_controller.js.coffee index 4f220aa6..f33758ae 100644 --- a/app/assets/javascripts/user/app/controllers/active_list_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/active_list_controller.js.coffee @@ -2,10 +2,4 @@ App.ActiveListController = Ember.ObjectController.extend #orders: (-> #@get('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') diff --git a/app/assets/javascripts/user/app/controllers/application_controller.js.coffee b/app/assets/javascripts/user/app/controllers/application_controller.js.coffee index a0912410..21efb5b7 100644 --- a/app/assets/javascripts/user/app/controllers/application_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/application_controller.js.coffee @@ -91,7 +91,6 @@ App.ApplicationController = Ember.Controller.extend if error_list = @store.all('list').findBy('id', 'current') error_list.eraseRecord() @set 'list', list - @controllerFor('active_list').set('model', list) if list.get('join_requests.length') @transitionToRoute 'join_requests' else if @currentRouteName is 'index' diff --git a/app/assets/javascripts/user/app/controllers/list_controller.js.coffee b/app/assets/javascripts/user/app/controllers/list_controller.js.coffee index 3b924779..1285fa64 100644 --- a/app/assets/javascripts/user/app/controllers/list_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/list_controller.js.coffee @@ -1,5 +1,2 @@ App.ListController = Ember.ObjectController.extend list: (-> @get('model')).property('model') - showTotal: (-> - if @get('list.orders.length') && @get('list.orders.length') > 1 then true else false - ).property('list.orders.length') diff --git a/app/assets/javascripts/user/app/models/list.js.coffee b/app/assets/javascripts/user/app/models/list.js.coffee index cdfef1c9..fca22a61 100644 --- a/app/assets/javascripts/user/app/models/list.js.coffee +++ b/app/assets/javascripts/user/app/models/list.js.coffee @@ -26,3 +26,7 @@ App.List = DS.Model.extend @get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0) ).property('relevant_orders.@each.total') active: (-> @get('state') is 'active' ).property('state') + + showTotal: (-> + if @get('orders.length') && @get('orders.length') > 1 then true else false + ).property('orders.length') diff --git a/app/assets/javascripts/user/app/templates/_list_content.emblem b/app/assets/javascripts/user/app/templates/_list_content.emblem index da117288..9499df56 100644 --- a/app/assets/javascripts/user/app/templates/_list_content.emblem +++ b/app/assets/javascripts/user/app/templates/_list_content.emblem @@ -17,7 +17,7 @@ if list.orders.isLoaded if list.sorted_orders .list-orders-container each order in list.sorted_orders: = view "list-order" contentBinding="order" - if showTotal + if list.showTotal .list-orders-total.total = t 'total' span.currency= currency list.total