Fixes: U4-4592 U7.1 - You can trigger a lot "Unsaved changes" bars

This commit is contained in:
perploug
2014-04-03 11:50:50 +02:00
parent 256fa3385a
commit 807778a737
2 changed files with 26 additions and 13 deletions

View File

@@ -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();
}

View File

@@ -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,