From 2c9256c6724d2e840b0b267657a3db930f00e225 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Sun, 30 Sep 2018 18:50:33 +0200 Subject: [PATCH] Don't let the same doctype be selectable twice in the Nested Content configuration --- .../nestedcontent/nestedcontent.controller.js | 12 ++++++++++++ .../nestedcontent/nestedcontent.doctypepicker.html | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) 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 0a44a9fcaa..7be141362e 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 @@ -37,6 +37,18 @@ }); }); + $scope.selectableDocTypesFor = function (config) { + // return all doctypes that are: + // 1. either already selected for this config, or + // 2. not selected in any other config + return _.filter($scope.model.docTypes, function (docType) { + return docType.alias === config.ncAlias || !_.find($scope.model.value, function(c) { + return docType.alias === c.ncAlias; + }); + }); + + } + if (!$scope.model.value) { $scope.model.value = []; $scope.add(); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html index 0617331682..e0a16d8687 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/nestedcontent/nestedcontent.doctypepicker.html @@ -22,7 +22,7 @@