mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
The login modal changes the URL to `#/login` which interfers with our shop pages. In order to show the right shop page, we need to know which pages are valid and where we have been before we clicked on Login.
18 lines
575 B
CoffeeScript
18 lines
575 B
CoffeeScript
Darkswarm.controller "PageSelectionCtrl", ($scope, $location) ->
|
|
$scope.selectedPage = ->
|
|
# 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]
|
|
|
|
$scope.whitelistPages = (pages) ->
|
|
$scope.whitelist = pages
|
|
$scope.lastPage = pages[0]
|