mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix angular templates bug
Angular controller data was being partially preserved when switching back and forth between tab templates, causing the ProductsCtrl to hold duplicate datasets when it is re-initialized after going from the shop tab to another tab, then back again.
This commit is contained in:
@@ -80,3 +80,11 @@ Darkswarm.controller "ProductsCtrl", ($scope, $filter, $rootScope, Products, Ord
|
||||
$scope.query = ""
|
||||
$scope.taxonSelectors.clearAll()
|
||||
$scope.propertySelectors.clearAll()
|
||||
|
||||
$scope.refreshStaleData = ->
|
||||
# If the products template has already been loaded but the controller is being initialized
|
||||
# again after the template has switched, refresh loaded data to avoid conflicts
|
||||
if $scope.Products.products.length > 0
|
||||
$scope.Products.products = []
|
||||
$scope.update_filters()
|
||||
$scope.loadProducts()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.footer-pad.small-12.columns
|
||||
%products{"ng-controller" => "ProductsCtrl", "ng-show" => "order_cycle.order_cycle_id != null", "ng-cloak" => true }
|
||||
%products{"ng-controller" => "ProductsCtrl", "ng-init" => "refreshStaleData()", "ng-show" => "order_cycle.order_cycle_id != null", "ng-cloak" => true }
|
||||
|
||||
// TODO: Needs an ng-show to slide content down
|
||||
.row.animate-slide{ "ng-show" => "query || appliedPropertiesList() || appliedTaxonsList()" }
|
||||
|
||||
Reference in New Issue
Block a user