mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Simplify logic in PageSelectionCtrl
This commit is contained in:
@@ -3,14 +3,14 @@ Darkswarm.controller "PageSelectionCtrl", ($scope, $location) ->
|
||||
# The path looks like `/contact` for the URL `https://ofn.org/shop#/contact`.
|
||||
# We remove the slash at the beginning.
|
||||
page = $location.path()[1..]
|
||||
if page in $scope.whitelist
|
||||
$scope.lastPage = page
|
||||
page
|
||||
else if page
|
||||
# The path points to an unrelated path like `/login`. Stay where we were.
|
||||
$scope.lastPage
|
||||
else
|
||||
$scope.whitelist[0]
|
||||
|
||||
return $scope.whitelist[0] unless page
|
||||
|
||||
# If the path points to an unrelated path like `/login`, stay where we were.
|
||||
return $scope.lastPage unless page in $scope.whitelist
|
||||
|
||||
$scope.lastPage = page
|
||||
page
|
||||
|
||||
$scope.whitelistPages = (pages) ->
|
||||
$scope.whitelist = pages
|
||||
|
||||
Reference in New Issue
Block a user