From 93f991b140a7fc8c66068ef9081987e931e65884 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Wed, 16 Jan 2019 13:05:16 +0100 Subject: [PATCH] Only allow element types in the NC editor --- .../nestedcontent/nestedcontent.controller.js | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js index 79e00fa453..d6cc35bacd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.controller.js @@ -285,28 +285,31 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.NestedContent.Prop $scope.scaffolds = []; _.each($scope.model.config.contentTypes, function (contentType) { contentResource.getScaffold(-20, contentType.ncAlias).then(function (scaffold) { - // remove all tabs except the specified tab - var tabs = scaffold.variants[0].tabs; - var tab = _.find(tabs, function (tab) { - return tab.id != 0 && (tab.alias.toLowerCase() == contentType.ncTabAlias.toLowerCase() || contentType.ncTabAlias == ""); - }); - scaffold.tabs = []; - if (tab) { - scaffold.tabs.push(tab); + // make sure it's an element type before allowing the user to create new ones + if (scaffold.isElement) { + // remove all tabs except the specified tab + var tabs = scaffold.variants[0].tabs; + var tab = _.find(tabs, function (tab) { + return tab.id != 0 && (tab.alias.toLowerCase() == contentType.ncTabAlias.toLowerCase() || contentType.ncTabAlias == ""); + }); + scaffold.tabs = []; + if (tab) { + scaffold.tabs.push(tab); - angular.forEach(tab.properties, - function (property) { - if (_.find(notSupported, function (x) { return x === property.editor; })) { - property.notSupported = true; - //TODO: Not supported message to be replaced with 'content_nestedContentEditorNotSupported' dictionary key. Currently not possible due to async/timing quirk. - property.notSupportedMessage = "Property " + property.label + " uses editor " + property.editor + " which is not supported by Nested Content."; - } - }); + angular.forEach(tab.properties, + function (property) { + if (_.find(notSupported, function (x) { return x === property.editor; })) { + property.notSupported = true; + //TODO: Not supported message to be replaced with 'content_nestedContentEditorNotSupported' dictionary key. Currently not possible due to async/timing quirk. + property.notSupportedMessage = "Property " + property.label + " uses editor " + property.editor + " which is not supported by Nested Content."; + } + }); + } + + // Store the scaffold object + $scope.scaffolds.push(scaffold); } - // Store the scaffold object - $scope.scaffolds.push(scaffold); - scaffoldsLoaded++; initIfAllScaffoldsHaveLoaded(); }, function (error) {