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:
Shannon
2018-08-08 15:35:02 +10:00
parent 72b1fb1d60
commit 69acaabec1
3 changed files with 23 additions and 1 deletions

View File

@@ -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 = [];

View File

@@ -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);

View File

@@ -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)