diff --git a/src/Umbraco.Web.UI.Client/src/common/services/formhelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/formhelper.service.js index 647f124be6..0e5fdc3916 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/formhelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/formhelper.service.js @@ -95,6 +95,13 @@ function formHelper(angularHelper, serverValidationManager, $timeout, notificati throw "args.scope cannot be null"; } + //if no statusPropertyName is set we'll default to formStatus. + if (!args.statusPropertyName) { + args.statusPropertyName = "formStatus"; + } + //clear the status + args.scope[args.statusPropertyName] = null; + if (angular.isArray(args.notifications)) { for (var i = 0; i < args.notifications.length; i++) { notificationsService.showNotification(args.notifications[i]); diff --git a/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs b/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs index 3ff80a8b17..19d14fa4fa 100644 --- a/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs +++ b/src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs @@ -111,6 +111,8 @@ namespace Umbraco.Web.Cache Macro.AfterSave += MacroAfterSave; Macro.AfterDelete += MacroAfterDelete; + MacroService.Saved += MacroServiceSaved; + MacroService.Deleted += MacroServiceDeleted; //Bind to member events @@ -498,6 +500,23 @@ namespace Umbraco.Web.Cache #endregion #region Macro event handlers + + void MacroServiceDeleted(IMacroService sender, Core.Events.DeleteEventArgs e) + { + foreach (var entity in e.DeletedEntities) + { + DistributedCache.Instance.RemoveMacroCache(entity); + } + } + + void MacroServiceSaved(IMacroService sender, Core.Events.SaveEventArgs e) + { + foreach (var entity in e.SavedEntities) + { + DistributedCache.Instance.RefreshMacroCache(entity); + } + } + /// /// Flush macro from cache /// diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs index a8958b35c5..2d2d3cef36 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs @@ -310,7 +310,35 @@ namespace Umbraco.Web.Cache //NOTE: The 'false' ensure that it will only refresh on the current server, not post to all servers dc.RefreshAll(new Guid(DistributedCache.MacroCacheRefresherId), false); } - + + /// + /// Refreshes the cache amongst servers for a macro item + /// + /// + /// + public static void RefreshMacroCache(this DistributedCache dc, IMacro macro) + { + if (macro != null) + { + dc.RefreshByJson(new Guid(DistributedCache.MacroCacheRefresherId), + MacroCacheRefresher.SerializeToJsonPayload(macro)); + } + } + + /// + /// Removes the cache amongst servers for a macro item + /// + /// + /// + public static void RemoveMacroCache(this DistributedCache dc, IMacro macro) + { + if (macro != null) + { + dc.RefreshByJson(new Guid(DistributedCache.MacroCacheRefresherId), + MacroCacheRefresher.SerializeToJsonPayload(macro)); + } + } + /// /// Refreshes the cache amongst servers for a macro item /// diff --git a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs index 48005bd8c2..ee77161ccc 100644 --- a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs @@ -2,10 +2,11 @@ using System.Web.Script.Serialization; using Umbraco.Core; using Umbraco.Core.Cache; +using Umbraco.Core.Models; using umbraco; -using umbraco.cms.businesslogic.macro; using umbraco.interfaces; using System.Linq; +using Macro = umbraco.cms.businesslogic.macro.Macro; namespace Umbraco.Web.Cache { @@ -62,6 +63,19 @@ namespace Umbraco.Web.Cache return json; } + /// + /// Creates the custom Json payload used to refresh cache amongst the servers + /// + /// + /// + internal static string SerializeToJsonPayload(params IMacro[] macros) + { + var serializer = new JavaScriptSerializer(); + var items = macros.Select(FromMacro).ToArray(); + var json = serializer.Serialize(items); + return json; + } + /// /// Creates the custom Json payload used to refresh cache amongst the servers /// @@ -75,6 +89,21 @@ namespace Umbraco.Web.Cache return json; } + /// + /// Converts a macro to a jsonPayload object + /// + /// + /// + private static JsonPayload FromMacro(IMacro macro) + { + var payload = new JsonPayload + { + Alias = macro.Alias, + Id = macro.Id + }; + return payload; + } + /// /// Converts a macro to a jsonPayload object /// diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 9a1380b14a..961a452180 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -315,7 +315,7 @@ namespace Umbraco.Web.Editors /// does not have Publish access to this node. /// /// - [EnsureUserPermissionForContent("id", 'P')] + [EnsureUserPermissionForContent("id", 'U')] public HttpResponseMessage PostPublishById(int id) { var foundContent = GetObjectFromRequest(() => Services.ContentService.GetById(id));