Fixes creating doc types, some null checks missing and an issue with how umbgridselector is responsible for syncing the template alias on a new doc type
This commit is contained in:
@@ -305,6 +305,9 @@
|
||||
// reformat allowed content types to array if id's
|
||||
vm.contentType.allowedContentTypes = contentTypeHelper.createIdArray(vm.contentType.allowedContentTypes);
|
||||
|
||||
//if this is a new item and it's creating a template, ensure that the template alias is synced correctly
|
||||
syncTemplateAlias(vm.contentType);
|
||||
|
||||
return contentEditingHelper.contentEditorPerformSave({
|
||||
saveMethod: contentTypeResource.save,
|
||||
scope: $scope,
|
||||
@@ -411,6 +414,24 @@
|
||||
vm.contentType = contentType;
|
||||
}
|
||||
|
||||
/** Syncs the template alias for new doc types before saving if a template is to be created */
|
||||
function syncTemplateAlias(contentType) {
|
||||
if (!noTemplate && contentType.id === 0) {
|
||||
//sync default template that had the placeholder flag
|
||||
if (contentType.defaultTemplate !== null && contentType.defaultTemplate.placeholder) {
|
||||
contentType.defaultTemplate.name = contentType.name;
|
||||
contentType.defaultTemplate.alias = contentType.alias;
|
||||
}
|
||||
//sync allowed templates that had the placeholder flag
|
||||
angular.forEach(contentType.allowedTemplates, function (allowedTemplate) {
|
||||
if (allowedTemplate.placeholder) {
|
||||
allowedTemplate.name = contentType.name;
|
||||
allowedTemplate.alias = contentType.alias;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function convertLegacyIcons(contentType) {
|
||||
// make array to store contentType icon
|
||||
var contentTypeArray = [];
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace Umbraco.Web.Editors
|
||||
catch (Exception ex)
|
||||
{
|
||||
var responseEx = CreateInvalidCompositionResponseException<TContentTypeDisplay, TContentTypeSave, TPropertyType>(ex, contentTypeSave, ct, ctId);
|
||||
if (responseEx != null) throw responseEx;
|
||||
throw responseEx ?? ex;
|
||||
}
|
||||
|
||||
var exResult = CreateCompositionValidationExceptionIfInvalid<TContentTypeSave, TPropertyType, TContentTypeDisplay>(contentTypeSave, newCt);
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
dest.AllowedTemplates = source.AllowedTemplates
|
||||
.Where(x => x != null)
|
||||
.Select(fileService.GetTemplate)
|
||||
.Where(x => x != null)
|
||||
.ToArray();
|
||||
|
||||
if (source.DefaultTemplate != null)
|
||||
|
||||
Reference in New Issue
Block a user