From 262a8e75f967f2efffed3833442ff04b690b52ec Mon Sep 17 00:00:00 2001 From: Steve Pettitt Date: Sun, 10 Jan 2016 07:58:04 +0000 Subject: [PATCH] slugs --- .../controllers/distributor_node_controller.js.coffee | 4 ++-- app/serializers/api/orders_by_distributor_serializer.rb | 7 ++++++- app/views/spree/users/show.html.haml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/distributor_node_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/distributor_node_controller.js.coffee index 2c81833e2e..6705634771 100644 --- a/app/assets/javascripts/darkswarm/controllers/distributor_node_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/distributor_node_controller.js.coffee @@ -1,9 +1,9 @@ Darkswarm.controller "DistributorNodeCtrl", ($scope, HashNavigation, $anchorScroll) -> $scope.toggle = -> - HashNavigation.toggle $scope.distributor.id + HashNavigation.toggle $scope.distributor.hash $scope.open = -> - HashNavigation.active($scope.distributor.id) + HashNavigation.active($scope.distributor.hash) if $scope.open() $anchorScroll() diff --git a/app/serializers/api/orders_by_distributor_serializer.rb b/app/serializers/api/orders_by_distributor_serializer.rb index a333ff6ff4..640a8837d7 100644 --- a/app/serializers/api/orders_by_distributor_serializer.rb +++ b/app/serializers/api/orders_by_distributor_serializer.rb @@ -1,8 +1,13 @@ class Api::OrdersByDistributorSerializer < ActiveModel::Serializer - attributes :name, :id, :balance, :distributed_orders + attributes :name, :id, :hash, :balance, :distributed_orders has_many :distributed_orders, serializer: Api::OrderSerializer def balance object.distributed_orders.map(&:outstanding_balance).reduce(:+).to_money.to_s end + + def hash + object.to_param + end + end diff --git a/app/views/spree/users/show.html.haml b/app/views/spree/users/show.html.haml index d17eed637b..2827d64308 100644 --- a/app/views/spree/users/show.html.haml +++ b/app/views/spree/users/show.html.haml @@ -18,7 +18,7 @@ %distributor.active_table_node.row.animate-repeat{"ng-repeat" => "(key, distributor) in Orders.orders_by_distributor", "ng-controller" => "DistributorNodeCtrl", "ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !distributor.active}", - id: "{{distributor.id}}"} + id: "{{distributor.hash}}"} .small-12.columns = render partial: "spree/users/skinny" = render partial: "spree/users/fat"