mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
use a directive for navigation check to attach it to the page instead of the controller
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
angular.module("admin.enterprises")
|
||||
.controller "enterpriseCtrl", ($scope, longDescription, Enterprise, PaymentMethods, ShippingMethods, NavigationCheck) ->
|
||||
.controller "enterpriseCtrl", ($scope, longDescription, Enterprise, PaymentMethods, ShippingMethods) ->
|
||||
$scope.Enterprise = Enterprise.enterprise
|
||||
$scope.PaymentMethods = PaymentMethods.paymentMethods
|
||||
$scope.ShippingMethods = ShippingMethods.shippingMethods
|
||||
# htmlVariable is used by textAngular wysiwyg for the long descrtiption.
|
||||
$scope.htmlVariable = longDescription
|
||||
# Provide a callback for a warning message displayed when leaving the page.
|
||||
navigationCallback = ->
|
||||
$scope.navigationCallback = ->
|
||||
"You are editing an enterprise!"
|
||||
|
||||
NavigationCheck.register navigationCallback
|
||||
|
||||
for payment_method in $scope.PaymentMethods
|
||||
payment_method.selected = payment_method.id in $scope.Enterprise.payment_method_ids
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
angular.module("admin.utils").directive "navigationCheck", (NavigationCheck)->
|
||||
link: ($scope) ->
|
||||
# Define navigationCallback on the controller.
|
||||
NavigationCheck.register($scope.navigationCallback)
|
||||
Reference in New Issue
Block a user