mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Moving navigation check to controller
This commit is contained in:
@@ -11,10 +11,13 @@ angular.module("admin.enterprises")
|
||||
# Provide a callback for generating warning messages displayed before leaving the page. This is passed in
|
||||
# from a directive "nav-check" in the page - if we pass it here it will be called in the test suite,
|
||||
# and on all new uses of this contoller, and we might not want that .
|
||||
$scope.enterpriseNavCallback = ->
|
||||
enterpriseNavCallback = ->
|
||||
if $scope.enterprise.$dirty
|
||||
"Your changes to the enterprise are not saved yet."
|
||||
|
||||
# Register the NavigationCheck callback
|
||||
NavigationCheck.register(enterpriseNavCallback)
|
||||
|
||||
for payment_method in $scope.PaymentMethods
|
||||
payment_method.selected = payment_method.id in $scope.Enterprise.payment_method_ids
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
angular.module("admin.utils").directive "navCheckCallback", (NavigationCheck)->
|
||||
restrict: 'A'
|
||||
scope:
|
||||
navCheckCallback: '&'
|
||||
link: (scope,element,attributes) ->
|
||||
# Provide a callback, otherwise this default will be used:
|
||||
callback = scope.navCheckCallback()
|
||||
callback ||= ->
|
||||
"You will lose any unsaved work!"
|
||||
NavigationCheck.register(callback)
|
||||
Reference in New Issue
Block a user