mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Use save bar directive in enterprise editing page
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
angular.module("admin.enterprises")
|
||||
.controller "enterpriseCtrl", ($scope, NavigationCheck, enterprise, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu) ->
|
||||
.controller "enterpriseCtrl", ($scope, NavigationCheck, enterprise, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu, StatusMessage) ->
|
||||
$scope.Enterprise = enterprise
|
||||
$scope.PaymentMethods = EnterprisePaymentMethods.paymentMethods
|
||||
$scope.ShippingMethods = EnterpriseShippingMethods.shippingMethods
|
||||
@@ -8,6 +8,16 @@ angular.module("admin.enterprises")
|
||||
$scope.menu = SideMenu
|
||||
$scope.newManager = { id: '', email: (t('add_manager')) }
|
||||
|
||||
$scope.StatusMessage = StatusMessage
|
||||
|
||||
$scope.$watch 'enterprise_form.$dirty', (newValue) ->
|
||||
console.log newValue
|
||||
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
|
||||
|
||||
$scope.setFormDirty = ->
|
||||
$scope.$apply ->
|
||||
$scope.enterprise_form.$setDirty()
|
||||
|
||||
# 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 .
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
-# Not all inputs are ng inputs, they don't make the ng-form dirty on change.
|
||||
-# ng-change is only valid for inputs, not for a form.
|
||||
-# So we use onchange and have to get the scope to access the ng controller
|
||||
= form_for [main_app, :admin, @enterprise], html: { name: "enterprise",
|
||||
= form_for [main_app, :admin, @enterprise], html: { name: "enterprise_form",
|
||||
"ng-app" => 'admin.enterprises',
|
||||
"ng-submit" => "navClear()",
|
||||
"ng-controller" => 'enterpriseCtrl',
|
||||
'onchange' => 'angular.element(enterprise).scope().enterprise.$setDirty()',
|
||||
'onchange' => 'angular.element(enterprise_form).scope().setFormDirty()',
|
||||
} do |f|
|
||||
|
||||
%save-bar{ buttons: "[{ text: 'Update', action: submit, param: null }]", form: "enterprise_form" }
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
.four.columns.alpha
|
||||
|
||||
Reference in New Issue
Block a user