Fix confirmation for permissions dialog

This commit is contained in:
Kenn Jacobsen
2019-06-19 11:57:07 +02:00
committed by Sebastiaan Janssen
parent 5ebd90aba5
commit a8b5d69be0
2 changed files with 24 additions and 27 deletions

View File

@@ -1,7 +1,7 @@
(function () {
"use strict";
function ContentRightsController($scope, $timeout, contentResource, localizationService, angularHelper, navigationService) {
function ContentRightsController($scope, $timeout, contentResource, localizationService, angularHelper, navigationService, overlayService) {
var vm = this;
var currentForm;
@@ -11,7 +11,6 @@
vm.removedUserGroups = [];
vm.viewState = "manageGroups";
vm.labels = {};
vm.showNotification = false;
vm.setViewSate = setViewSate;
vm.editPermissions = editPermissions;
@@ -20,7 +19,6 @@
vm.removePermissions = removePermissions;
vm.cancelManagePermissions = cancelManagePermissions;
vm.closeDialog = closeDialog;
vm.stay = stay;
vm.discardChanges = discardChanges;
function onInit() {
@@ -164,14 +162,31 @@
});
}
function stay() {
vm.showNotification = false;
}
function closeDialog() {
// check if form has been changed. If it has show discard changes notification
if (currentForm && currentForm.$dirty) {
vm.showNotification = true;
localizationService.localizeMany(["prompt_unsavedChanges", "prompt_unsavedChangesWarning", "prompt_discardChanges", "prompt_stay"]).then(
function(values) {
var overlay = {
"view": "default",
"title": values[0],
"content": values[1],
"disableBackdropClick": true,
"disableEscKey": true,
"submitButtonLabel": values[2],
"closeButtonLabel": values[3],
submit: function () {
overlayService.close();
navigationService.hideDialog();
},
close: function () {
overlayService.close();
}
};
overlayService.open(overlay);
}
);
} else {
navigationService.hideDialog();
}
@@ -187,4 +202,4 @@
angular.module("umbraco").controller("Umbraco.Editors.Content.RightsController", ContentRightsController);
})();
})();

View File

@@ -62,24 +62,6 @@
</umb-user-group-preview>
</div>
<div class="umb-notifications" style="bottom: 0;" ng-if="vm.showNotification">
<div class="umb-notification alert alert-block alert-form umb-notifications__notification animated -half-second fadeIn -no-border -extra-padding">
<h4 style="font-size: 16px;"><localize key="prompt_unsavedChanges"></localize></h4>
<p style="line-height: 1.6em; margin-bottom: 10px;"><localize key="prompt_unsavedChangesWarning"></localize></p>
<umb-button
label-key="prompt_discardChanges"
action="vm.discardChanges();"
type="button">
</umb-button>
<umb-button
label-key="prompt_stay"
action="vm.stay()"
type="button"
button-style="action">
</umb-button>
</div>
</div>
</form>
</div>