Fixes content blueprint creation

This commit is contained in:
Shannon
2019-06-12 12:22:14 +10:00
parent 2797011fb0
commit 8a19cd4bbc
3 changed files with 26 additions and 9 deletions

View File

@@ -242,9 +242,13 @@
}
if (!$scope.content.isChildOfListView) {
navigationService.syncTree({ tree: $scope.treeAlias, path: path.split(","), forceReload: initialLoad !== true }).then(function (syncArgs) {
$scope.page.menu.currentNode = syncArgs.node;
});
navigationService.syncTree({ tree: $scope.treeAlias, path: path.split(","), forceReload: initialLoad !== true })
.then(function (syncArgs) {
$scope.page.menu.currentNode = syncArgs.node;
}, function () {
//handle the rejection
console.log("A problem occurred syncing the tree! A path is probably incorrect.")
});
}
else if (initialLoad === true) {

View File

@@ -47,9 +47,13 @@ function ContentBlueprintEditController($scope, $routeParams, contentResource) {
//Bind to $routeUpdate which will execute anytime a location changes but the route is not triggered.
//This is so we can listen to changes on the cculture parameter since that will not cause a route change
// and then we can pass in the updated culture to the editor
//and then we can pass in the updated culture to the editor.
//This will also execute when we are redirecting from creating an item to a newly created item since that
//will not cause a route change and so we can update the isNew and contentId flags accordingly.
$scope.$on('$routeUpdate', function (event, next) {
$scope.culture = next.params.cculture ? next.params.cculture : $routeParams.mculture;
$scope.isNew = $routeParams.id === "-1";
$scope.contentId = $routeParams.id;
});
}

View File

@@ -576,8 +576,13 @@ namespace Umbraco.Web.Editors
Services.ContentService.SaveBlueprint(contentItem.PersistedContent, Security.CurrentUser.Id);
//we need to reuse the underlying logic so return the result that it wants
return OperationResult.Succeed(new EventMessages());
},
content =>
{
var display = MapToDisplay(content);
SetupBlueprint(display, content);
return display;
});
SetupBlueprint(contentItemDisplay, contentItemDisplay.PersistedContent);
return contentItemDisplay;
}
@@ -591,11 +596,15 @@ namespace Umbraco.Web.Editors
[OutgoingEditorModelEvent]
public ContentItemDisplay PostSave([ModelBinder(typeof(ContentItemBinder))] ContentItemSave contentItem)
{
var contentItemDisplay = PostSaveInternal(contentItem, content => Services.ContentService.Save(contentItem.PersistedContent, Security.CurrentUser.Id));
var contentItemDisplay = PostSaveInternal(
contentItem,
content => Services.ContentService.Save(contentItem.PersistedContent, Security.CurrentUser.Id),
MapToDisplay);
return contentItemDisplay;
}
private ContentItemDisplay PostSaveInternal(ContentItemSave contentItem, Func<IContent, OperationResult> saveMethod)
private ContentItemDisplay PostSaveInternal(ContentItemSave contentItem, Func<IContent, OperationResult> saveMethod, Func<IContent, ContentItemDisplay> mapToDisplay)
{
//Recent versions of IE/Edge may send in the full client side file path instead of just the file name.
//To ensure similar behavior across all browsers no matter what they do - we strip the FileName property of all
@@ -626,7 +635,7 @@ namespace Umbraco.Web.Editors
{
//ok, so the absolute mandatory data is invalid and it's new, we cannot actually continue!
// add the model state to the outgoing object and throw a validation message
var forDisplay = MapToDisplay(contentItem.PersistedContent);
var forDisplay = mapToDisplay(contentItem.PersistedContent);
forDisplay.Errors = ModelState.ToErrorDictionary();
throw new HttpResponseException(Request.CreateValidationErrorResponse(forDisplay));
}
@@ -757,7 +766,7 @@ namespace Umbraco.Web.Editors
}
//get the updated model
var display = MapToDisplay(contentItem.PersistedContent);
var display = mapToDisplay(contentItem.PersistedContent);
//merge the tracked success messages with the outgoing model
display.Notifications.AddRange(globalNotifications.Notifications);