diff --git a/src/Umbraco.Web/Models/ContentEditing/INotificationModel.cs b/src/Umbraco.Web/Models/ContentEditing/INotificationModel.cs new file mode 100644 index 0000000000..2ffd10d8b6 --- /dev/null +++ b/src/Umbraco.Web/Models/ContentEditing/INotificationModel.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Umbraco.Web.Models.ContentEditing +{ + public interface INotificationModel + { + /// + /// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes. + /// + List Notifications { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Models/ContentEditing/MessagesExtensions.cs b/src/Umbraco.Web/Models/ContentEditing/MessagesExtensions.cs new file mode 100644 index 0000000000..87371c8551 --- /dev/null +++ b/src/Umbraco.Web/Models/ContentEditing/MessagesExtensions.cs @@ -0,0 +1,57 @@ +using Umbraco.Web.UI; + +namespace Umbraco.Web.Models.ContentEditing +{ + public static class MessagesExtensions + { + public static void AddNotification(this INotificationModel model, string header, string msg, SpeechBubbleIcon type) + { + model.Notifications.Add(new Notification() + { + Header = header, + Message = msg, + NotificationType = type + }); + } + + public static void AddSuccessNotification(this INotificationModel model, string header, string msg) + { + model.Notifications.Add(new Notification() + { + Header = header, + Message = msg, + NotificationType = SpeechBubbleIcon.Success + }); + } + + public static void AddErrorNotification(this INotificationModel model, string header, string msg) + { + model.Notifications.Add(new Notification() + { + Header = header, + Message = msg, + NotificationType = SpeechBubbleIcon.Error + }); + } + + public static void AddWarningNotification(this INotificationModel model, string header, string msg) + { + model.Notifications.Add(new Notification() + { + Header = header, + Message = msg, + NotificationType = SpeechBubbleIcon.Warning + }); + } + + public static void AddInfoNotification(this INotificationModel model, string header, string msg) + { + model.Notifications.Add(new Notification() + { + Header = header, + Message = msg, + NotificationType = SpeechBubbleIcon.Info + }); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Models/ContentEditing/Notification.cs b/src/Umbraco.Web/Models/ContentEditing/Notification.cs new file mode 100644 index 0000000000..c5c5634442 --- /dev/null +++ b/src/Umbraco.Web/Models/ContentEditing/Notification.cs @@ -0,0 +1,16 @@ +using System.Runtime.Serialization; +using Umbraco.Web.UI; + +namespace Umbraco.Web.Models.ContentEditing +{ + [DataContract(Name = "notification", Namespace = "")] + public class Notification + { + [DataMember(Name = "header")] + public string Header { get; set; } + [DataMember(Name = "message")] + public string Message { get; set; } + [DataMember(Name = "type")] + public SpeechBubbleIcon NotificationType { get; set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 4b0088854d..9bbd85616f 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -308,7 +308,10 @@ + + +