Don't let the same doctype be selectable twice in the Nested Content configuration

This commit is contained in:
Kenn Jacobsen
2018-09-30 18:50:33 +02:00
parent 25aa74b4cd
commit 2c9256c672
2 changed files with 13 additions and 1 deletions

View File

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

View File

@@ -22,7 +22,7 @@
</td>
<td>
<select id="{{model.alias}}_doctype_select"
ng-options="dt.alias as dt.name for dt in model.docTypes | orderBy: 'name'"
ng-options="dt.alias as dt.name for dt in selectableDocTypesFor(config) | orderBy: 'name'"
ng-model="config.ncAlias" required></select>
</td>
<td>