diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js index 9c46f2853e..97415c2838 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js @@ -70,9 +70,11 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not path = decodeURIComponent(path); } - var msg = { view: "confirmroutechange", args: { path: path, listener: locationEvent } }; - notificationsService.add(msg); - + if(!notificationsService.hasView()){ + var msg = { view: "confirmroutechange", args: { path: path, listener: locationEvent } }; + notificationsService.add(msg); + } + event.preventDefault(); } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js b/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js index ac6cda9695..8bd1f87c3b 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js @@ -25,6 +25,18 @@ angular.module('umbraco.services') .factory('notificationsService', function ($rootScope, $timeout, angularHelper) { var nArray = []; + function setViewPath(view){ + if(view.indexOf('/') < 0) + { + view = "views/common/notifications/" + view; + } + + if(view.indexOf('.html') < 0) + { + view = view + ".html"; + } + return view; + } var service = { @@ -50,16 +62,7 @@ angular.module('umbraco.services') angularHelper.safeApply($rootScope, function () { if(item.view){ - if(item.view.indexOf('/') < 0) - { - item.view = "views/common/notifications/" + item.view; - } - - if(item.view.indexOf('.html') < 0) - { - item.view = item.view + ".html"; - } - + item.view = setViewPath(item.view); item.sticky = true; item.type = "form"; item.headline = null; @@ -100,6 +103,14 @@ angular.module('umbraco.services') }, + hasView : function(view){ + if(!view){ + return _.find(nArray, function(notification){ return notification.view;}); + }else{ + view = setViewPath(view).toLowerCase(); + return _.find(nArray, function(notification){ return notification.view.toLowerCase() === view;}); + } + }, addView: function(view, args){ var item = { args: args,