Nearly have send to publish working, it's all wired up in the UI to the controller, just need to implement the logic.
This commit is contained in:
@@ -209,10 +209,9 @@ namespace Umbraco.Web.Editors
|
||||
// then we cannot continue saving, we can only display errors
|
||||
// * If there are validation errors and they were attempting to publish, we can only save, NOT publish and display
|
||||
// a message indicating this
|
||||
if (!ModelState.IsValid)
|
||||
if (ModelState.IsValid == false)
|
||||
{
|
||||
if (ValidationHelper.ModelHasRequiredForPersistenceErrors(contentItem)
|
||||
&& (contentItem.Action == ContentSaveAction.SaveNew || contentItem.Action == ContentSaveAction.PublishNew))
|
||||
if (ValidationHelper.ModelHasRequiredForPersistenceErrors(contentItem) && IsCreatingAction(contentItem.Action))
|
||||
{
|
||||
//ok, so the absolute mandatory data is invalid and it's new, we cannot actually continue!
|
||||
// add the modelstate to the outgoing object and throw a validation message
|
||||
@@ -242,6 +241,10 @@ namespace Umbraco.Web.Editors
|
||||
//save the item
|
||||
Services.ContentService.Save(contentItem.PersistedContent, (int)Security.CurrentUser.Id);
|
||||
}
|
||||
else if (contentItem.Action == ContentSaveAction.SendPublish || contentItem.Action == ContentSaveAction.SendPublishNew)
|
||||
{
|
||||
throw new NotSupportedException("Send to publish is currently not supported");
|
||||
}
|
||||
else
|
||||
{
|
||||
//publish the item and check if it worked, if not we will show a diff msg below
|
||||
@@ -262,9 +265,13 @@ namespace Umbraco.Web.Editors
|
||||
case ContentSaveAction.SaveNew:
|
||||
display.AddSuccessNotification(ui.Text("speechBubbles", "editContentSavedHeader"), ui.Text("speechBubbles", "editContentSavedText"));
|
||||
break;
|
||||
case ContentSaveAction.SendPublish:
|
||||
case ContentSaveAction.SendPublishNew:
|
||||
display.AddSuccessNotification(ui.Text("speechBubbles", "editContentSendToPublish"), ui.Text("speechBubbles", "editContentSendToPublishText"));
|
||||
break;
|
||||
case ContentSaveAction.Publish:
|
||||
case ContentSaveAction.PublishNew:
|
||||
ShowMessageForStatus(publishStatus.Result, display);
|
||||
ShowMessageForPublishStatus(publishStatus.Result, display);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -553,7 +560,7 @@ namespace Umbraco.Web.Editors
|
||||
return toMove;
|
||||
}
|
||||
|
||||
private void ShowMessageForStatus(PublishStatus status, ContentItemDisplay display)
|
||||
private void ShowMessageForPublishStatus(PublishStatus status, ContentItemDisplay display)
|
||||
{
|
||||
switch (status.StatusType)
|
||||
{
|
||||
|
||||
@@ -159,5 +159,15 @@ namespace Umbraco.Web.Editors
|
||||
: (TPersisted) Request.Properties[typeof (TPersisted).ToString()];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the action passed in means we need to create something new
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
internal static bool IsCreatingAction(ContentSaveAction action)
|
||||
{
|
||||
return (action.ToString().EndsWith("New"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,11 @@ namespace Umbraco.Web.Editors
|
||||
get { return _userService ?? ApplicationContext.Current.Services.UserService; }
|
||||
}
|
||||
|
||||
public override bool AllowMultiple
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override void OnActionExecuting(HttpActionContext actionContext)
|
||||
{
|
||||
var contentItem = (ContentItemSave)actionContext.ActionArguments["contentItem"];
|
||||
@@ -75,8 +80,31 @@ namespace Umbraco.Web.Editors
|
||||
contentToCheck = contentItem.PersistedContent;
|
||||
contentIdToCheck = contentToCheck.Id;
|
||||
break;
|
||||
case ContentSaveAction.SendPublish:
|
||||
permissionToCheck.Add(ActionToPublish.Instance.Letter);
|
||||
contentToCheck = contentItem.PersistedContent;
|
||||
contentIdToCheck = contentToCheck.Id;
|
||||
break;
|
||||
case ContentSaveAction.SaveNew:
|
||||
//Save new requires both ActionNew AND ActionUpdate
|
||||
|
||||
permissionToCheck.Add(ActionNew.Instance.Letter);
|
||||
permissionToCheck.Add(ActionUpdate.Instance.Letter);
|
||||
if (contentItem.ParentId != Constants.System.Root)
|
||||
{
|
||||
contentToCheck = ContentService.GetById(contentItem.ParentId);
|
||||
contentIdToCheck = contentToCheck.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
contentIdToCheck = contentItem.ParentId;
|
||||
}
|
||||
break;
|
||||
case ContentSaveAction.SendPublishNew:
|
||||
//Send new requires both ActionToPublish AND ActionUpdate
|
||||
|
||||
permissionToCheck.Add(ActionNew.Instance.Letter);
|
||||
permissionToCheck.Add(ActionToPublish.Instance.Letter);
|
||||
if (contentItem.ParentId != Constants.System.Root)
|
||||
{
|
||||
contentToCheck = ContentService.GetById(contentItem.ParentId);
|
||||
|
||||
@@ -71,8 +71,6 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
break;
|
||||
case ContentSaveAction.Publish:
|
||||
case ContentSaveAction.PublishNew:
|
||||
default:
|
||||
//we don't support this for media
|
||||
actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.NotFound);
|
||||
|
||||
@@ -74,8 +74,6 @@ namespace Umbraco.Web.Editors
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ContentSaveAction.Publish:
|
||||
case ContentSaveAction.PublishNew:
|
||||
default:
|
||||
//we don't support this for members
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
@@ -120,8 +118,6 @@ namespace Umbraco.Web.Editors
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ContentSaveAction.Publish:
|
||||
case ContentSaveAction.PublishNew:
|
||||
default:
|
||||
//we don't support this for members
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
Save = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Saves a new content item
|
||||
/// Creates a new content item
|
||||
/// </summary>
|
||||
SaveNew = 1,
|
||||
|
||||
@@ -21,8 +21,18 @@
|
||||
Publish = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Saves an publishes a new content item
|
||||
/// Creates and publishes a new content item
|
||||
/// </summary>
|
||||
PublishNew = 3
|
||||
PublishNew = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Saves and sends publish notification
|
||||
/// </summary>
|
||||
SendPublish = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Creates and sends publish notification
|
||||
/// </summary>
|
||||
SendPublishNew = 5
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ using Newtonsoft.Json.Serialization;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Editors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
@@ -163,16 +164,16 @@ namespace Umbraco.Web.WebApi.Binders
|
||||
});
|
||||
}
|
||||
|
||||
if (model.Action == ContentSaveAction.Publish || model.Action == ContentSaveAction.Save)
|
||||
{
|
||||
//finally, let's lookup the real content item and create the DTO item
|
||||
model.PersistedContent = GetExisting(model);
|
||||
}
|
||||
else
|
||||
if (ContentControllerBase.IsCreatingAction(model.Action))
|
||||
{
|
||||
//we are creating new content
|
||||
model.PersistedContent = CreateNew(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
//finally, let's lookup the real content item and create the DTO item
|
||||
model.PersistedContent = GetExisting(model);
|
||||
}
|
||||
|
||||
//create the dto from the persisted model
|
||||
if (model.PersistedContent != null)
|
||||
|
||||
Reference in New Issue
Block a user