Skip 'Unsaved changes dialog' if user is unauthenticated.
This commit is contained in:
parent
c8edbffe43
commit
c2bc287158
@ -18,17 +18,17 @@ export default angular.module('thingsboard.directives.confirmOnExit', [])
|
|||||||
.name;
|
.name;
|
||||||
|
|
||||||
/*@ngInject*/
|
/*@ngInject*/
|
||||||
function ConfirmOnExit($state, $mdDialog, $window, $filter) {
|
function ConfirmOnExit($state, $mdDialog, $window, $filter, userService) {
|
||||||
return {
|
return {
|
||||||
link: function ($scope) {
|
link: function ($scope) {
|
||||||
|
|
||||||
$window.onbeforeunload = function () {
|
$window.onbeforeunload = function () {
|
||||||
if (($scope.confirmForm && $scope.confirmForm.$dirty) || $scope.isDirty) {
|
if (userService.isAuthenticated() && (($scope.confirmForm && $scope.confirmForm.$dirty) || $scope.isDirty)) {
|
||||||
return $filter('translate')('confirm-on-exit.message');
|
return $filter('translate')('confirm-on-exit.message');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$scope.$on('$stateChangeStart', function (event, next, current, params) {
|
$scope.$on('$stateChangeStart', function (event, next, current, params) {
|
||||||
if (($scope.confirmForm && $scope.confirmForm.$dirty) || $scope.isDirty) {
|
if (userService.isAuthenticated() && (($scope.confirmForm && $scope.confirmForm.$dirty) || $scope.isDirty)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var confirm = $mdDialog.confirm()
|
var confirm = $mdDialog.confirm()
|
||||||
.title($filter('translate')('confirm-on-exit.title'))
|
.title($filter('translate')('confirm-on-exit.title'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user