Ensures there's no duplicate notifications and ensures that soft redirects occur for content blueprints too

This commit is contained in:
Shannon
2019-06-12 11:34:36 +10:00
parent 1307ee7ced
commit 2797011fb0
2 changed files with 16 additions and 1 deletions

View File

@@ -32,7 +32,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
var nonRoutingQueryStrings = ["mculture", "cculture", "lq"];
var retainedQueryStrings = ["mculture"];
//A list of trees that don't cause a route when creating new items (TODO: eventually all trees should do this!)
var nonRoutingTreesOnCreate = ["content"];
var nonRoutingTreesOnCreate = ["content", "contentblueprints"];
function setMode(mode) {
switch (mode) {

View File

@@ -1,10 +1,15 @@

using System.Linq;
using Umbraco.Core;
namespace Umbraco.Web.Models.ContentEditing
{
public static class MessagesExtensions
{
public static void AddNotification(this INotificationModel model, string header, string msg, NotificationStyle type)
{
if (model.Exists(header, msg, type)) return;
model.Notifications.Add(new Notification()
{
Header = header,
@@ -15,6 +20,8 @@ namespace Umbraco.Web.Models.ContentEditing
public static void AddSuccessNotification(this INotificationModel model, string header, string msg)
{
if (model.Exists(header, msg, NotificationStyle.Success)) return;
model.Notifications.Add(new Notification()
{
Header = header,
@@ -25,6 +32,8 @@ namespace Umbraco.Web.Models.ContentEditing
public static void AddErrorNotification(this INotificationModel model, string header, string msg)
{
if (model.Exists(header, msg, NotificationStyle.Error)) return;
model.Notifications.Add(new Notification()
{
Header = header,
@@ -35,6 +44,8 @@ namespace Umbraco.Web.Models.ContentEditing
public static void AddWarningNotification(this INotificationModel model, string header, string msg)
{
if (model.Exists(header, msg, NotificationStyle.Warning)) return;
model.Notifications.Add(new Notification()
{
Header = header,
@@ -45,6 +56,8 @@ namespace Umbraco.Web.Models.ContentEditing
public static void AddInfoNotification(this INotificationModel model, string header, string msg)
{
if (model.Exists(header, msg, NotificationStyle.Info)) return;
model.Notifications.Add(new Notification()
{
Header = header,
@@ -52,5 +65,7 @@ namespace Umbraco.Web.Models.ContentEditing
NotificationType = NotificationStyle.Info
});
}
private static bool Exists(this INotificationModel model, string header, string message, NotificationStyle notificationType) => model.Notifications.Any(x => x.Header.InvariantEquals(header) && x.Message.InvariantEquals(message) && x.NotificationType == notificationType);
}
}