Skip to content

Commit 807778a

Browse files
author
perploug
committed
Fixes: U4-4592 U7.1 - You can trigger a lot "Unsaved changes" bars
1 parent 256fa33 commit 807778a

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not
7070
path = decodeURIComponent(path);
7171
}
7272

73-
var msg = { view: "confirmroutechange", args: { path: path, listener: locationEvent } };
74-
notificationsService.add(msg);
75-
73+
if(!notificationsService.hasView()){
74+
var msg = { view: "confirmroutechange", args: { path: path, listener: locationEvent } };
75+
notificationsService.add(msg);
76+
}
77+
7678
event.preventDefault();
7779
}
7880

src/Umbraco.Web.UI.Client/src/common/services/notifications.service.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ angular.module('umbraco.services')
2525
.factory('notificationsService', function ($rootScope, $timeout, angularHelper) {
2626

2727
var nArray = [];
28+
function setViewPath(view){
29+
if(view.indexOf('/') < 0)
30+
{
31+
view = "views/common/notifications/" + view;
32+
}
33+
34+
if(view.indexOf('.html') < 0)
35+
{
36+
view = view + ".html";
37+
}
38+
return view;
39+
}
2840

2941
var service = {
3042

@@ -50,16 +62,7 @@ angular.module('umbraco.services')
5062
angularHelper.safeApply($rootScope, function () {
5163

5264
if(item.view){
53-
if(item.view.indexOf('/') < 0)
54-
{
55-
item.view = "views/common/notifications/" + item.view;
56-
}
57-
58-
if(item.view.indexOf('.html') < 0)
59-
{
60-
item.view = item.view + ".html";
61-
}
62-
65+
item.view = setViewPath(item.view);
6366
item.sticky = true;
6467
item.type = "form";
6568
item.headline = null;
@@ -100,6 +103,14 @@ angular.module('umbraco.services')
100103

101104
},
102105

106+
hasView : function(view){
107+
if(!view){
108+
return _.find(nArray, function(notification){ return notification.view;});
109+
}else{
110+
view = setViewPath(view).toLowerCase();
111+
return _.find(nArray, function(notification){ return notification.view.toLowerCase() === view;});
112+
}
113+
},
103114
addView: function(view, args){
104115
var item = {
105116
args: args,

0 commit comments

Comments
 (0)